Prod Vs Dev:路线问题

时间:2013-10-16 21:11:35

标签: ruby-on-rails-3.2

我在将我的应用程序从开发(Rails 3.2,Ruby 1.8.7,Webrick)带到prod(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

我没有在开发中看到任何这些问题,就在我生产的时候。这些错误让我觉得它们是我应该在dev中看到的,但我没有任何问题。

如果有人能指出我正确的方向,我会很感激。

---更新

只是对它的更新。我改变了作业的方式。我创建了一个专门分配页面类型的方法。看起来像这样

@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 %>

这导致相信,我不知何故不同步。 DB中存在“pageType”。它存在于我的模型类中,但不知何故rails认为它不存在。我应该看看的任何想法或我应该如何解决它?

0 个答案:

没有答案