我在将我的应用程序从开发(Rails 3.2、Ruby 1.8.7、Webrick)转移到产品(Rails 3.2、Ruby 1.8.7、Passenger)时遇到问题。我目前有两个问题,我没有任何快乐的解决方法。一个是我的路线:
Started PUT "/clubs/myclub"
ActionController::RoutingError (No route matches [PUT] "/myclub"):
actionpack (3.2.2) lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call'
actionpack (3.2.2) lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
railties (3.2.2) lib/rails/rack/logger.rb:26:in `call_app'
railties (3.2.2) lib/rails/rack/logger.rb:16:in `call'
actionpack (3.2.2) lib/action_dispatch/middleware/request_id.rb:22:in `call'
rack (1.4.1) lib/rack/methodoverride.rb:21:in `call'
rack (1.4.1) lib/rack/runtime.rb:17:in `call'
activesupport (3.2.2) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
rack (1.4.1) lib/rack/lock.rb:15:in `call'
actionpack (3.2.2) lib/action_dispatch/middleware/static.rb:61:in `call'
rack-cache (1.2) lib/rack/cache/context.rb:136:in `forward'
rack-cache (1.2) lib/rack/cache/context.rb:143:in `pass'
rack-cache (1.2) lib/rack/cache/context.rb:155:in `invalidate'
rack-cache (1.2) lib/rack/cache/context.rb:71:in `call!'
rack-cache (1.2) lib/rack/cache/context.rb:51:in `call'
railties (3.2.2) lib/rails/engine.rb:479:in `call'
railties (3.2.2) lib/rails/application.rb:220:in `call'
railties (3.2.2) lib/rails/railtie/configurable.rb:30:in `send'
railties (3.2.2) lib/rails/railtie/configurable.rb:30:in `method_missing'
passenger (3.0.18) lib/phusion_passenger/rack/request_handler.rb:96:in `process_request'
passenger (3.0.18) lib/phusion_passenger/abstract_request_handler.rb:516:in
执行以下命令,我看到路线在那里:
[~/prod/current]# RAILS_ENV=production bundle exec rake routes | grep clubs
clubs GET /clubs(.:format) clubs#index
POST /clubs(.:format) clubs#create
new_club GET /clubs/new(.:format) clubs#new
edit_club GET /clubs/:id/edit(.:format) clubs#edit
club GET /clubs/:id(.:format) clubs#show
PUT /clubs/:id(.:format) clubs#update
DELETE /clubs/:id(.:format) clubs#destroy
当我比较 DEV 设置中的路线时,我看不出有任何区别。
我得到的第二个问题是:
NoMethodError (undefined method `pageType=' for #<StaticPage:0x2b228afb8df8>):
app/controllers/static_pages_controller.rb:34:in `showbyType'
app/controllers/static_pages_controller.rb:22:in `show'
现在有趣的是 pageType 不是方法,它是一个变量。
@static_page = StaticPage.new
@static_page.pageType = params[:pageType]
最后一行是第 34 行。我检查了我的模型中的 StaticPage 及其声明
attr_accessible :title, :content ,:pageType
我在开发中没有看到任何这些问题,就在我处于生产状态时。这些错误让我觉得它们是我应该在开发中看到的那种,但我没有任何问题。
如果有人能指出我正确的方向,我将不胜感激。
- -更新
只是对它的更新。我改变了作业的完成方式。我创建了一个专门分配页面类型的方法。看起来像这样
@static_page.set_page_type( params[:pageType])
Rails 不再抱怨,但是当我看到它时它会爆炸
ActionView::Template::Error (undefined method `pageType' for #<StaticPage:0x2ba1008d50f0>):
5: <%= f.inputs do %>
6: <%= f.input :title %>
7: <%= f.input :content %>
8: <%= f.input :pageType , :as => :hidden %>
9:
10: <% end %>
这导致相信,我不知何故不同步。“pageType”存在于数据库中。它存在于我的模型类中,但不知何故,rails 认为它不存在。有什么想法我应该在哪里看或我应该如何解决它?