Reputation: 11336
I have the following action to confirm a PIN code.
def create
@confirm = User.where(:email => params[:user][:email]).last
errors[:base] << "Subscription not found" if @confirm.nil?
respond_with(@confirm)
end
If the object doesn't exist I'm getting the following error
NameError in ConfirmsController#create
undefined local variable or method `errors' for #<ConfirmsController:0x007f921de173d0>
Why it doesn't recognize errors and how can I handle error for this case?
Upvotes: 1
Views: 94
Reputation: 2069
Errors as you are using them are typically on the ActiveRecord model. If you want to display an error message try using the flash method.
Upvotes: 1