Ruby on Rails教程第3.4节

时间:2014-01-04 23:41:37

标签: ruby-on-rails-3

大家好我刚刚学习了这个教程,由于某种原因,我被困在这一部分。自从编写教程以来,我意识到它们可能会发生变化。

它要求生成静态页面,如下所示:

" rails生成控制器StaticPages主页帮助--no-test-framework"

命令响应...

C:\ Sites \ rails_projects \ sample_app> rails生成控制器static_pages C:/Sites/rails_projects/sample_app/config/application.rb:7:in require': cannot load such file -- active_resource/railtie (LoadError) from C:/Sites/rails_projects/sample_app/config/application.rb:7:in'         来自C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-4.0。 /lib/rails/commands.rb:43:in require' from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-4.0. /lib/rails/commands.rb:43:in'         来自script / rails:6:require' from script/rails:6:in'


非常感谢任何帮助。谢谢!

尝试使用相同的结果进行捆绑安装。这是application.rb

require File.expand_path('../boot', __FILE__)

# Pick the frameworks you want:
require "active_record/railtie"
require "action_controller/railtie"
require "action_mailer/railtie"
require "active_resource/railtie"
require "sprockets/railtie"
# require "rails/test_unit/railtie"

if defined?(Bundler)
# If you precompile assets before deploying to production, use this line
Bundler.require(*Rails.groups(:assets => %w(development test)))
# If you want your assets lazily compiled in production, use this line
# Bundler.require(:default, :assets, Rails.env)
end

module SampleApp
class Application < Rails::Application

1 个答案:

答案 0 :(得分:0)

尝试使用bundle install。如果这不起作用,请在此config/application.rb粘贴。

请记住:您需要Ruby 2.0.0才能使用Rails 4

使用RVM升级到ruby 2:

  1. Install RVM \curl -sSL https://get.rvm.io | bash

  2. 检查rvm get stable

  3. rvm use ruby-2.0.0 --dafault

  4. 请记住在列表顶部指定Ruby an rails版本:

      

    来源'https://rubygems.org'

         

    ruby​​'2.0.0'

         

    gem'trail','4.0.2'

    然后在rails项目中再次运行'bundle install'并开心。