如何验证模型中的方法参数?

时间:2013-06-06 20:31:51

标签: ruby-on-rails

这是我的尝试:

class Answer < ActiveRecord::Base
validate :upd
def upd
 unless question_id.nil? || status.nil?
    redirect_to :action => 'index'
 else return true
end

def update_status(question_id, status)
 if question.valid? && status.valid?
   @update = Question.find(question_id)
   @update.update_attributes(:question_status => status)
 end
end

end

我得到未定义的局部变量或方法`status'

0 个答案:

没有答案