uri = session[:original_uri]
session[:original_uri] = nil
render (uri || { :action => :index })
is it possible?
Thanks!
uri = session[:original_uri]
session[:original_uri] = nil
render (uri || { :action => :index })
is it possible?
Thanks!
Brian H. wrote:
no.
why can’t you use redirect_to?On Thu, Jul 31, 2008 at 4:13 PM, Justin To
<[email protected]
def save_requirement
@post = Post.new(params[:post])
if @post.save
redirect_to :action => :index, :id => @post.id
else
params[:not_saved] = true
render :action => :index
end
end
If I redirect_to then the error_messages_for ‘post’ won’t be shown
anymore. Any workarounds?
Thanks!
Not following you. Why would you need to change the rendering? It should
render just fine with the code you have below. No need to redirect on
failure, only on success, just as your code below specifies. What
exactly
are you trying to do?
A lot of your questions come without context,., consider adding some
background to the problem you’re trying to solve when you show code.
On Thu, Jul 31, 2008 at 4:20 PM, Justin To
<[email protected]
Brian H. wrote:
Not following you. Why would you need to change the rendering? It should
render just fine with the code you have below. No need to redirect on
failure, only on success, just as your code below specifies. What
exactly
are you trying to do?A lot of your questions come without context,., consider adding some
background to the problem you’re trying to solve when you show code.On Thu, Jul 31, 2008 at 4:20 PM, Justin To
<[email protected]
Mmm…well I have the index page. And when a user clicks “new” (:action
=> :new), a table slides_down with a form for the Post model in the
index page. There’s no ‘new.html.erb’. Then when a user submits (:action
=> :save_requirement), it is suppose to redirect_to :action => :index if
saved successfully. There is no ‘save_requirement.html.erb’ so I need to
render something otherwise I get the ‘Missing Template’ error if the
Post fails to save. Since my form was presented through ajax on my index
page, I need to display my error messages for the unsuccessful Post on
the table that slid_down in the index page that holds the Post form.
Therefore, I have to render :action => :index
At least, that’s the only way I’ve managed to do it. There is one bug I
found with this method: the url stays the same ‘/save_requirement’, when
I don’t want that there anymore if it was unsuccessful.
Hope that’s clearer,
thanks
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs