Re: [Rails] Use table elements
On May 26, 2014, at 4:28 AM, Fab Forestier wrote: Colin Law wrote in post #1146856: On 23 May 2014 07:41, Fab Forestier li...@ruby-forum.com wrote: id_op2 name_op2num_op2button 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. Yes but my question was how can I have the value equal to the number of the line of the table where the button is? If you are dynamically generating the table, then you know what index each row of that table is, don't you? And if you are generating the table using a collection of data, then you know the :id (for example, or the color or stock number or any of the parameters of the underlying object) of each item as you draw the table. Adding that value to the link_to generated code is a trivial exercise. for foo in @foos tr tdfoo.bar/td tdfoo.baz/td tdlink_to foo.boo, foo.blarg, :stock_number = foo.id/td /tr end Does that help? (Left off all the erb stuff 'cause it's early.) Walter -- Posted via http://www.ruby-forum.com/. -- 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/383c77eeae62a42d017cdc8c88fdd811%40ruby-forum.com. For more options, visit https://groups.google.com/d/optout. -- 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/2AA2405C-44A0-4D02-936B-F9BAD93E6E78%40wdstudio.com. For more options, visit https://groups.google.com/d/optout.
Re: [Rails] Use table elements
On May 26, 2014, at 8:00 AM, Fab Forestier li...@ruby-forum.com wrote: But the in the methode ajouter how can I have something like @myvariable=n or @myvariable=@defautrec[i] where I is the current line of the table? %= link_to controller: pages, action: ajouter, id: n % But your code is otherwise so messed up that I can't tell exactly what you're trying to do. What is the do at then end of the call to link_to? Is the %end% after /button intended to be associated with it? Or is it supposed to be for the @defautrec.each, but is just in the wrong place? I suspect you're trying to wrap a button in a link, but that's not how HTML works, regardless of whether you're using Rails or not. Do you just want a button that acts like a link??? It that's the case, you want button_to: http://stackoverflow.com/questions/12475299/ruby-on-rails-button-to-link-to http://stackoverflow.com/questions/6247491/rails-3-display-link-as-button Anyway, you cannot just stick do at the end of a function call in order to start a loop. Remember, %= % just executes the Ruby code inside and inserts the result into the HTML, and this is not legitimate Ruby: link_to controller: pages, action: ajouter do Or, for more clarity, since this is the way it would be parsed: link_to (controller: pages, action: ajouter do) -- Scott Ribe scott_r...@elevated-dev.com http://www.elevated-dev.com/ (303) 722-0567 voice -- 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/AB790A24-89A2-4114-97D0-1D6A18C13C7F%40elevated-dev.com. For more options, visit https://groups.google.com/d/optout.
Re: [Rails] Use table elements
On May 26, 2014, at 9:09 AM, Fab Forestier li...@ruby-forum.com wrote: And then how can use the id in my methode? Like any other parameter. -- Scott Ribe scott_r...@elevated-dev.com http://www.elevated-dev.com/ (303) 722-0567 voice -- 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/9E7AC522-7CEC-4CEA-A498-E54A7E6BBD13%40elevated-dev.com. For more options, visit https://groups.google.com/d/optout.
Re: [Rails] Use table elements
On May 23, 2014, at 12:41 AM, Fab Forestier li...@ruby-forum.com wrote: 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? %= @operation.id % You use @operations.each, just like any other variable. It doesn't matter whether it's a model or not. -- Scott Ribe scott_r...@elevated-dev.com http://www.elevated-dev.com/ (303) 722-0567 voice -- 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/66A30D7F-52F6-4F23-881D-312FFE27DE71%40elevated-dev.com. For more options, visit https://groups.google.com/d/optout.
[Rails] Use table elements
Sorry th etitle of the topic isn't very clear but it's difficult to summarize my problem! I made a view without model but I display in table the content of a variable named '@operations'. So each line corresponds to an operation. In my table I have also a column with a button for each line. When i click on the button I want to redirect to an existing page 'Operation' witch correspond to the operation of the line of the table like in the index view with the 'edit' or 'delete' button. But I can't do the same think because I'm not working with a special model in this view. Is someone did somethink like this yet? Fab -- Posted via http://www.ruby-forum.com/. -- 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/27bc401ad0fbe0b6865185301ff05ad5%40ruby-forum.com. For more options, visit https://groups.google.com/d/optout.
Re: [Rails] Use table elements
On 22 May 2014 13:32, Fab Forestier li...@ruby-forum.com wrote: Sorry th etitle of the topic isn't very clear but it's difficult to summarize my problem! I made a view without model but I display in table the content of a variable named '@operations'. So each line corresponds to an operation. In my table I have also a column with a button for each line. When i click on the button I want to redirect to an existing page 'Operation' witch correspond to the operation of the line of the table like in the index view with the 'edit' or 'delete' button. But I can't do the same think because I'm not working with a special model in this view. You can, but you may need to do it a different way. The first question is whether you need to use a form, do you need to post data, or is each button effectively just a link? 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%3D0gLu1EV%3D6ezMKavNRy0v0n%2BxKfmRTV9YPt6uf7%3D4XOKvasA%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
Re: [Rails] Use table elements
On 2014-May-22, at 15:39 , Colin Law clan...@gmail.com wrote: On 22 May 2014 18:17, Fab Forestier li...@ruby-forum.com wrote: Colin Law wrote in post #1146811: On 22 May 2014 16:00, Fab Forestier li...@ruby-forum.com wrote: You said that, for example, the link should take you to the edit page of an article. How does the user know what article that is? Colin No by exemple I understand the action of the button but it's a totally different think my button has to redirect to an Operation view but it is not an edit view it's a view created by me, and this operation has to be the operation in the same line in the table with the button. You don't redirect to a view using a link or button, you request an action in a controller, it is important to use the right words or we will all be confused. It must be particularly difficult when one is not working in one's native language, I understand that. So, when the button is clicked you need to request an action in a controller, and from that you can then show whatever view you like. So do you know what action you wish to invoke? Colin Fab, You seem to have put several concepts into one description of the problem. Perhaps if you break it into its parts like: * The link/button initiates a request back to the server ( link_to(Text, my_view_path(article), remote: true) ) * The config/routes.rb specifies how a request is directed to a particular controller/action * The action can use the params from the request to determine what to render or where to redirect. Does that help you either understand the problem or at least indicate which part you really have a question about? -Rob -- 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/0F374511-AA05-4577-B74B-6A17F93A975C%40agileconsultingllc.com. For more options, visit https://groups.google.com/d/optout.