0

我尝试使用本教程,但在脚手架生成代码方面存在一些问题。

应用程序.rb

Bundler.require(:default, Rails.env) if defined?(Bundler) 
#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

从此主题中获取解决方案,但不适用于此问题。

日志:

C:\Users\Evgeny\Rails_projects\demo_app>rails generate scaffold User name:string
 email:string
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.0.9/lib/rails/ra
iltie/configuration.rb:77:in `method_missing': undefined method `assets' for #<R
ails::Application::Configuration:0x3a03248> (NoMethodError)
        from C:/Users/Evgeny/Rails_projects/demo_app/config/application.rb:55:in
 `<class:Application>'
        from C:/Users/Evgeny/Rails_projects/demo_app/config/application.rb:14:in
 `<module:DemoApp>'
        from C:/Users/Evgeny/Rails_projects/demo_app/config/application.rb:13:in
 `<top (required)>'
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.0.9
/lib/rails/commands.rb:15:in `require'
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.0.9
/lib/rails/commands.rb:15:in `<top (required)>'
        from script/rails:6:in `require'
        from script/rails:6:in `<main>'

配置应用程序:

source 'http://rubygems.org'

gem 'rails', '3.0.9'
gem 'sqlite3', '1.3.3'
4

2 回答 2

1

Rails 资产管道在 Rails 3.1 及更高版本之前不可用。我猜在 C:/Users/Evgeny/Rails_projects/demo_app/config/application.rb 的第 55 行,你有一个导致问题的 config.assets 行。删除该行或升级到 Rails 3.1 或 3.2

于 2012-04-23T01:42:27.433 回答
0

这是有资产的东西。我认为您至少需要将 Rails 升级到 3.1。3.2.3更好。

尝试使用最新版本的 rails 3.2.3 创建新项目。

或尝试此解决方案http://railscasts.com/episodes/282-upgrading-to-rails-3-1或教程书的最后一章http://russian.railstutorial.org/chapters/rails-3-1#top .

无需升级的另一种解决方案,但我不确定。在您的 config/application.rb 中尝试找到 config.assets.enabled 并将其设置为 false。

于 2012-04-22T22:07:10.743 回答