新手问题 /config/environment.rb:6:in `<top (required)>': undefined local variable or method `config' for main:Object (NameError)

villins · 2012年05月26日 · 最后由 villins 回复于 2012年05月26日 · 6548 次阅读

我在 environment.rb 中添加了一句 config.gem 'tiny_mce',具体如下:

Load the rails application

require File.expand_path('../application', FILE)

Initialize the rails application

MyBlog::Application.initialize! config.gem 'tiny_mce'

一启动服务就出现如下错误:

/home/villins/MyBlog/config/environment.rb:6:in <top (required)>': undefined local variable or methodconfig' for main:Object (NameError) from /home/villins/MyBlog/config.ru:4:in require' from /home/villins/MyBlog/config.ru:4:inblock in

' from /home/villins/.rvm/gems/ruby-1.9.3-p194/gems/rack-1.4.1/lib/rack/builder.rb:51:in instance_eval' from /home/villins/.rvm/gems/ruby-1.9.3-p194/gems/rack-1.4.1/lib/rack/builder.rb:51:ininitialize' from /home/villins/MyBlog/config.ru:1:in new' from /home/villins/MyBlog/config.ru:1:in' from /home/villins/.rvm/gems/ruby-1.9.3-p194/gems/rack-1.4.1/lib/rack/builder.rb:40:in eval' from /home/villins/.rvm/gems/ruby-1.9.3-p194/gems/rack-1.4.1/lib/rack/builder.rb:40:inparse_file' from /home/villins/.rvm/gems/ruby-1.9.3-p194/gems/rack-1.4.1/lib/rack/server.rb:200:in app' from /home/villins/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.3/lib/rails/commands/server.rb:46:inapp' from /home/villins/.rvm/gems/ruby-1.9.3-p194/gems/rack-1.4.1/lib/rack/server.rb:301:in wrapped_app' from /home/villins/.rvm/gems/ruby-1.9.3-p194/gems/rack-1.4.1/lib/rack/server.rb:252:instart' from /home/villins/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.3/lib/rails/commands/server.rb:70:in start' from /home/villins/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.3/lib/rails/commands.rb:55:inblock in ' from /home/villins/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.3/lib/rails/commands.rb:50:in tap' from /home/villins/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.3/lib/rails/commands.rb:50:in' from script/rails:6:in require' from script/rails:6:in'

请问有什么解决方法吗?

rails3 用 gemfile

config.gemfile 'tiny_mce' 这样吗?也是报同样的错误

是在 gemfile 里用 gem 'tiny_mce'

需要 登录 后方可回复, 如果你还没有账号请 注册新账号