Re: nil.errors and error_messages_for

Phlip
Thu, 26 Mar 2009 05:11:48 -0000

> Here we go:
>
>     @discount = Discount.find(params[:id])
>     if @discount.update_attributes(params[:discount])
>       flash[:notice_good] = "Discounts have been updated"
>       redirect_to :action=> ''index''
>     else
>       index # I need to do this in order to get my instance variables
> populated for the index view

and ... index re-populates @discount?

put this inside the index:

   @discount ||= Discount.new

>       render :action => ''index''
>     end