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?

--
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 post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Search Discussions

  • Colin Law at Jan 6, 2012 at 8:14 am

    On 6 January 2012 01:39, miek test 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

    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouprubyonrails-talk @
categoriesrubyonrails
postedJan 6, '12 at 1:40a
activeJan 6, '12 at 8:14a
posts2
users2
websiterubyonrails.org
irc#RubyOnRails

2 users in discussion

Miek test: 1 post Colin Law: 1 post

People

Translate

site design / logo © 2021 Grokbase