if @request.save
format.html { redirect_to(@request) }
format.json { render :json => { :result => 'success', :request
=> request_path(@request) } }
....
but I would like rather to redirect to an index page
I wrote this but it doesn't redirect ...
format.json { redirect_to requests_url }
what should I write to redirect correctly to an html page ?
thanks for your help
erwin
--
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 rubyonra...@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-ta...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
thanks for your help
it seems that json.redirect is bypassed...
I put an alert, and it's not fired up
if (json.redirect) {
alert('redirect');
}
--
Posted via http://www.ruby-forum.com/.
respond_to do |format|
if @request.save
flash[:notice] = 'Request was successfully created.'
format.html { redirect_to requests_url }
format.xml { render :xml => @request, :status => :created,
:location => @request }
format.json { render :json => {:result => 'success', :redirect
=> requests_url } }
format.js
else
.....
once the request is saved, ... I get in the log
Completed in 563ms (View: 1, DB: 5) | 200 OK [http://localhost/requests]
I should have
200 OK [http://localhost:3000/requests]
yes... after some tests, I rewrote the original format.json line (from
the plugin uploadify_rails) as :
format.json { render :json => { :result => 'success', :request
=> member_request_url(@request[:id]) } }
this redirects to :show (don't misunderstand it , 'request' is my
model instance...)
and I just modified the :show action as following :
respond_to do |format|
..
format.js {
render :update do |page|
page.redirect_to member_requests_url
end
}
end
this time, the redirection is fine.... which is enough for my test,
I'll try to investigate a little bit more to understand why:
format.json { render :json => { :result => 'success', :request
=> member_request_url(@request[:id]) } }
redirects to :show with a format .js
I thought I could write a :callback => 'index', no change... it's always
redirected to :show...
OR is it an issue in using :request =>
maybe this is a parameter used by the render.json ...
thanks a lot for your help