On Monday, May 26, 2014 9:42:19 AM UTC-4, Ruby-Forum.com User wrote:
>
> mike2r wrote in post #1146701: 
> > On Wednesday, May 21, 2014 7:42:39 AM UTC-4, Ruby-Forum.com User wrote: 
> >>         format.json { head :no_content } 
> >>         respond_to do |format| 
> >> 
> >> -- 
> >> Posted via http://www.ruby-forum.com/. 
> >> 
> > 
> > The problem is the redirect.  When you do a redirect, Rails actually 
> > responds with a code 301 to the browser and redirects the browser to the 
> > new url.  When Rails receives the redirected request, it's treated as a 
> > completely new request, so no instance variables will persist. 
> > 
> > The only way to do what you want is to use a render instead of a 
> > redirect. 
>
> There is an issue with your solution too because the view is updated but 
> in the url of the page we can see the name of the function and then we 
> can't call other other function by clicking on other buttons of the 
> view. 
>
> Did I forgot something in my code? 
>
> -- 
> Posted via http://www.ruby-forum.com/. 
>

Probably, but I can't really tell without having more knowledge of the 
underlying controller and views.  If you have a button that links to the 
change action, it's going to create a response from that action and 
whatever routing is associated with that action will be in the url of that 
action unless you have told the system to do otherwise.  The one thing that 
is commonly misunderstood with rendering is that execution remains within 
the action that called the render, in this case, the action change.  Any 
instance variables that are referenced in the view must be defined within 
that action.  Even the following:

render action: "operation_en_cours"

doesn't really execute the action.  It renders a view using the template 
associated with the action operation_en_cours.  Any information required by 
the template from the action (such as instance variables) will need to be 
defined in the action that is calling it (in this case, change).  

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/5654ca26-2224-4193-9b89-a9c03e77bd10%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to