On Tue, Feb 14, 2012 at 7:51 PM, Soichi Ishida <[email protected]> wrote:
>
> Then, I would like to set up the action upon the failure as follows
>
> def create
> @script = Script.new(params[:script])
>
> respond_to do |format|
> if @script.save
> format.json { render json: @script, status: :created, location:
> @script }
> else
> format.html { redirect_to @script } #HERE!!!!
> # format.json { render json: @script.errors, status:
> :unprocessable_entity }
> end
> end
> end
>
> hoping that it will redirect to 'script' page. But it doesnt.
>
>
but after @script.save you're redirecting nowhere... you have to specify
something like
redirect_to :controller=> "scripts", :action=>"index"
Javier Q
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.