Heroku的错误 - NoMethodError(未定义的方法'更新'? [英] heroku error - NoMethodError (undefined method `updated?'
问题描述
我有一个滑轨3.1的应用程序在Heroku上,我不断收到一个500错误在生产中,我不能在开发重建。
I've a rails 3.1 app on Heroku, I keep getting an 500 error in production which I can't recreate in dev.
当我试图在我的控制器中的一个执行更新操作,我收到了500。我从Heroku的日志如下 -
When I try to perform an update action in one of my controllers I get a 500. I get the following from heroku logs -
2011-12-05T13:52:35+00:00 app[web.1]: Completed 500 Internal Server Error in 15ms
2011-12-05T13:52:35+00:00 app[web.1]:
2011-12-05T13:52:35+00:00 app[web.1]: NoMethodError (undefined method `updated?' for #<ActiveRecord::Associations::HasOneAssociation:0x00000004058800>):
2011-12-05T13:52:35+00:00 app[web.1]: app/controllers/cars_controller.rb:81:in `block in update'
2011-12-05T13:52:35+00:00 app[web.1]: app/controllers/cars_controller.rb:80:in `update'
这是我的车控制器更新动作 -
The update action on my cars controller is -
def update
@car = Car.find_by_url_identifier(params[:id])
respond_to do |format| #**line 80**
if @car.update_attributes(params[:car]) #**line 81**
CarMailer.gift_confirmation(@car).deliver
format.html { redirect_to(thanks_path(@car.url_identifier)) }
else
format.html { render action: "edit" }
end
end
end
被张贴的参数 -
The parameters being posted are -
{"utf8"=>"✓",
"_method"=>"put",
"authenticity_token"=>"RTXCVvdsKQHc8CxHLeYS9WuztcrI1b4H8SHsdfsKWu+Iz4=",
"car"=>{"name"=>"dgdfsdfsd",
"email"=>"test@test.com",
"recipient_attributes"=>{"name"=>"fdsfsd",
"address1"=>"sdfsdfdsf",
"address2"=>"dsfdsfsdf",
"city"=>"sdfdsf",
"postcode"=>"sdfds"},
"gift_id"=>"2",
"message"=>"fsdfsdfdsf",
"terms"=>"1"},
"commit"=>"submit",
"id"=>"test5"}
我的汽车模型是这样的 -
My car model looks like this -
class Car < ActiveRecord::Base
validates :name, :presence =>true, :on => :update
validates :url_identifier, :presence =>true, :on => :create
has_one :recipient
belongs_to :gift
accepts_nested_attributes_for :recipient
accepts_nested_attributes_for :gift
def to_param
self.url_identifier
end
end
任何想法如何,我可以解决这一问题?除了看herokus日志,怎么回事,我可以调试呢?
Any idea how I can fix this? Apart from looking at herokus logs, how else can I debug this?
奇怪了,而应用程序的工作,如果我做了Heroku的重启
Oddly the app work for a while if I do a 'heroku restart'
推荐答案
我用Google搜索的错误消息。你有没有一起来看看这个线程: http://ruby-forum.com/topic/81719他们也有类似的问题,并且已经发布了他们的解决方案/黑客。也许值得一试。
I googled the error message. Have you had a look at this thread: http://ruby-forum.com/topic/81719 They had a similar problem and have posted their solution/hack. Might be worth a try.
这篇关于Heroku的错误 - NoMethodError(未定义的方法'更新'?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!