我尝试使用this tutorial,但在脚手架生成代码方面存在一些问题。
application.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
从this topic获取解决方案,但不能很好地解决此问题。
日志:
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'
答案 0 :(得分: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。
答案 1 :(得分:0)
Rails资产管道在Rails 3.1及更高版本之前不可用。我猜测在C:/Users/Evgeny/Rails_projects/demo_app/config/application.rb的第55行,你有一个导致问题的config.assets行。删除该行或升级到Rails 3.1或3.2