Use table elements

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

On 26 May 2014 16:09, Fab F. [email protected] wrote:

Scott R. wrote in post #1147132:

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 %>

And then how can use the id in my methode?

A long time ago I seem to remember suggesting that you work right
through
railstutorial.org and that then you would understand the
basics of rails and would not have to ask for answers to simple
questions. I believe your replied that you had looked through the
tutorials. Once again I request that you please take a few days out
and work right through it, including doing all the exercises. In the
long run you will save yourself and us a lot of time.

Colin