Link_to parameter used in controller

okay, so ive got a view page of ‘columns’, each comprised of a name and
code.
ive got a button to ‘add columns’ and i want it to pass it an integer
parameter so i can set up the default number of boxes for adding

so in my view ive got

= link_to “Add columns”, new_column_path, :number => 5

and in my controller:

def new
@columns = []
params[:number].to_i.times { @columns << Column.new }
end

so basically i just want to read number passed from the link. there will
be links from other places that have different values passed (not 5)
what am i doing wrong? or is there a better way of approaching it?

On 6 January 2012 01:39, miek test [email protected] wrote:

okay, so ive got a view page of ‘columns’, each comprised of a name and
code.
ive got a button to ‘add columns’ and i want it to pass it an integer
parameter so i can set up the default number of boxes for adding

so in my view ive got

= link_to “Add columns”, new_column_path, :number => 5

Try
link_to “Add columns”, new_column_path( :number => 5 )

Colin

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs