rubyonrailsin

A Ruby and Rails talk

Tuesday, March 23, 2010


Re: [Rails] redirection in format.json ...

by rubyonrailsin 0 comments

Tag


Share this post:
Design Float
StumbleUpon
Reddit

Here is an example:

  format.json { render :json => { :redirect => requests_url } }

and then on your client redirect like this:

  if (json.redirect) {
    window.location = json.redirect;
  }

Also try http://www.google.com/search?q=json+redirect

Does this solve your problem?

/Lasse

2010/3/23 Erwin <yves_dufour@mac.com>
I  have presently a render :json which modify the current page

     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 rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.


--
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@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

No comments:

Post a Comment

Subscribe feeds via e-mail

Blog Archive