On May 26, 2014, at 8:00 AM, Fab F. [email protected] 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 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 R.
[email protected]
http://www.elevated-dev.com/
(303) 722-0567 voice