Tek,
You need to return or the processing keeps happening through the
method. I.e.:
redirect_to :action => "index" and return unless request.post?
:-)
-Danimal
On Mar 30, 10:40 pm, Teck
<tek.k...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> I have the following code:
>
> def create
> redirect_to :action => "index" unless request.post?
> @entry = Entry.new(params[:entry])
> if @entry.save
> flash[:notice] = "Successfully created..."
> redirect_to :action => "index"
> else
> render :action => "new"
> end
> end
>
> I get an error "Can only render or redirect once per action".
> I understand "redirect_to" or "render" doesn''t
end the script.
>
> I would like to allow only "post" request for "create"
action,
> so I need to do somehting about this.
>
> But how can I improve the script?
>
> Is there any way to write
> redirect_to :action => "index" unless request.post?
> in model?
>
> Tek
--~--~---------~--~----~------------~-------~--~----~
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
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---