Reputation: 3501
I am using https://github.com/plataformatec/simple_form and am trying to send a extra parameter. I have a Task, List and ListTask models, in the new page of the of the list I want to be able to insert the number of tasks that will be added. When you submit it will send you to the new list_task page with the correct number of forms populated.
=simple_form_for @list do |s|
=s.input :title
=s.input :task_count
=s.button :submit
This produces a error undefined method task_count
, which makes sense because it is not a method in list.
Upvotes: 2
Views: 3449
Reputation: 4499
if you don't want the value persisting to the db, add a virtual attribute:
class List < ActiveRecord::Base
attr_accessor :task_count
end
this will allow you to use that attribute in the form, but that will only persist for the life of that object but it will make it into your POST params.
...otherwise, if you want it to persist to the db (which is sounds like you may). You'd add task_count as a column in your lists table (via a migration).
Upvotes: 9