On 23 May 2014 07:41, Fab Forestier <li...@ruby-forum.com> wrote:
> Yes you're both right.
>
> My problem is not to redirect or to render and not to config routes.
> My problem is the assignment of the variable @operation, how can I
> assign the operation which correspond to the right button?
>
> Operations
> ------------------------------------------------------------------
> id_op1       name_op1        num_op1        button
> ------------------------------------------------------------------
> id_op2       name_op2        num_op2        button
> ------------------------------------------------------------------
> id_op3       name_op3        num_op3        button
> ------------------------------------------------------------------
>
> To display this table I use a loop to display each element of each
> operation contained in the variable '@operations'.
> The when I click on the first button I wish to assign the first
> operation in the variable '@operation' annd then call a method in the
> controller but it's not my problem.
>
> Be careful operation is not a model in this view but a variable. I don't
> know how to assign my variable in fonction of the button line?

That is not important.  You cannot assign a value to a variable and
then pass it to an action, you must do it using the url of the link
to.  The easiest way is to pass it as a parameter to the url, so the
url will look something like
htttp://localhost:3000/operations/some_action?value=73.  You can
easily do this with something like link_to("label",
:controller="operations", :action="some_action", :value=73).  Then in
the action in the operations controller the variable params[:value]
will have the value 73.

Note, however, that if in the operations controller all you want to do
is redirect to another action in order to edit an article, for
example, which is what I understood you wanted to do a few posts ago,
then don't go to the operations controller at all, just construct the
correct link so that the button takes you straight to the activities
controller edit action so the edit page is displayed when the button
is clicked.

Colin

-- 
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/CAL%3D0gLs49_cS0dzpmNiUmR%3DNDMg0ZqYCF4rEFPnzRUCGDc8Ogg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to