草庐IT

Railstutorial

全部标签

ruby-on-rails - Railstutorial : db:populate vs. 工厂女孩

在railstutorial中,作者为什么选择使用这个(代码list10.25):http://ruby.railstutorial.org/chapters/updating-showing-and-deleting-usersnamespace:dbdodesc"Filldatabasewithsampledata"task:populate=>:environmentdoRake::Task['db:reset'].invokeUser.create!(:name=>"ExampleUser",:email=>"example@railstutorial.org",:passwo

ruby-on-rails - 我现在(2010 年 1 月)应该使用哪个版本的 Ruby?

我有1.8.6附带的VanillaMacOSXLeopard。我是RoR的新手,所以会学习网上的教程。在使用更高版本的Ruby时,我是否可能会发现遵循它们的问题?我目前正在查看提到1.8.6和1.8.7的这个-http://www.railstutorial.org/book 最佳答案 RoR教程对两者都适用,但如果您正在学习Ruby,则应该学习1.9。Rails3将不支持1.8.6,所以我会选择1.8.7或1.9。我还推荐使用RVM在Ruby版本之间切换。 关于ruby-on-rail

ruby-on-rails - RailsTutorial - 第 8.4.3 章 - 在集成测试中添加用户后未清除测试数据库

我被这个难住了。到目前为止教程中的一切都进行得很顺利,但是当我将这段代码添加到我的/spec/requests/users_spec.rb文件中时,事情开始变得糟糕:describe"success"doit"shouldmakeanewuser"dolambdadovisitsignup_pathfill_in"Name",:with=>"ExampleUser"fill_in"Email",:with=>"ryan@example.com"fill_in"Password",:with=>"foobar"fill_in"Confirmation",:with=>"foobar"cl

Ruby Guard 问题 - 'Please install the sqlite3 adapter' - railstutorial.org

我正在关注RubyonRailsTutorial并且在测试部分变得有些困惑,特别是-3.6.2-AutomatedtestswithGuard按照部署到Heroku的教程说明,我已切换到Postgresql并从我的gemfile中删除了sqlite3,并进行了捆绑安装以进行更新。但是,一旦我运行bundleexecguard我收到消息:/Users/username/.rvm/gems/ruby-1.9.3-p125@global/gems/bundler-1.1.3/lib/bundler/rubygems_integration.rb:147:inblockinreplace_ge

ruby-on-rails - railstutorial 调试信息来自哪里

在第7章中,我使用获得以下输出---!ruby/hash-with-ivars:ActionController::Parameterselements:controller:static_pagesaction:homeivars::@permitted:false谁能解释一下hash-with-ivars的来源以及什么是ivars::@permitted:false是什么意思? 最佳答案 有趣的问题!我在一个Rails项目的所有库资源中搜索了'hash-with-ivars'并且只出现了一个地方:psychrubylibrary

ruby-on-rails - railstutorial.org 中的 SessionsHelper : Should helpers be general-purpose modules for code not needed in views?

railstutorial.org有一个让我觉得有点奇怪的建议。Itsuggeststhiscode:classApplicationControllerincludeSessionsHelper使方法在ApplicationController中可用,是的,但它也使它们在任何View中都可用。我知道身份验证/授权是交叉的,但这真的是最好的地方吗?在我看来,这可能范围太广了。将实现有条件重定向(如railstutorial.org示例所做的)的before_filter的代码放在更通常包含View助手的模块中似乎令人惊讶。将View中不需要的功能放在ApplicationControl

ruby - 为什么我不能得到 rake db :migrate to work for ruby. railstutorial.org

我决定完成教程。在我创建一个新的应用程序并添加新的user:stringemail:string然后在应用程序目录中执行rakedb:migrate之后,我得到了这个输出:rakeaborted!undefinedmethod`task'for#/usr/local/rvm/gems/ruby-1.9.2-p180@rails3tutorial/gems/railties-3.0.7/lib/rails/application.rb:215:in`initialize_tasks'/usr/local/rvm/gems/ruby-1.9.2-p180@rails3tutorial/ge

ruby-on-rails - RailsTutorial 登录 flash 不工作

我正在尝试让错误闪现出现在railstutorial.org示例应用程序中。到目前为止,这就是我所做的。谁能帮我找出错误:我的RSPEC测试失败:1)SessionsControllerPOST'create'invalidsigninshouldhaveaflash.nowmessageFailure/Error:flash.now[:error].should=~/invalid/iexpected:/invalid/igot:nil(using=~)./spec/controllers/sessions_controller_spec.rb:27Controller代码:defc

ruby-on-rails - 关闭浏览器时 session 未被破坏 - RailsTutorial.org

在阅读MichaelHartl的railstutorial.org时,我进入了第8章(特别是8.2.3)。当前的问题是实现一个session以保持用户在多个View中登录,但是本节中实现的功能应该是一个临时session,当浏览器窗口打开时该session过期(注销用户)关闭了。这是教科书中的声明:Ifyouquityourbrowsercompletely,youshouldalsobeabletoverifythattheapplicationforgetsyourloginstatus,requiringyoutologinagaintoseethechangesdescribe

ruby-on-rails - Railstutorial(Michael Hartl): Exercise 4. 6

我没有从Hartl的Rails教程中得到以下练习的答案:ByreplacingthequestionmarksinListing4.10withtheappropriatemethods,combinesplit,shuffle,andjointowriteafunctionthatshufflesthelettersinagivenstring.list4.10:>>defstring_shuffle(s)>>s.split('').?.?>>end=>nil>>string_shuffle("foobar")有人可以帮帮我吗?提前致谢! 最佳答案
12