Reputation: 9184
I have such form:
= form_for @order do |f|
.field
= f.label :city , "Использовать данные вашего профиля*: "
= f.radio_button :usercase, true, :required => true
= f.radio_button :usercase, false, :required => true
.field
= f.label :city , "Город*: "
= f.text_field :city, :placeholder => "Minsk", :required => true
But field :usercase is not presented in @order. How could i send radio_button as params to my controller method? Now i get: undefined method `usercase' How to send usercase?
Upvotes: 4
Views: 1462
Reputation: 8954
In your Order
model you can add the usercase=
method to deal witrh the data. Like this.
def usercase=(data)
# DO SOMETHING WITH data
end
the variable data will contain the value from the usercase
field.
// The attr_accessor will define usercase
and usercase=
but you whould have to redefine the usercase=
anyway because you need to do something with the data.
Upvotes: 3