I've added a new column to my Supplier model of 'source' and 'source_other'. The form I've set up for new suppliers, however, isn't correctly taking this attribute and adding it to the model
The migration looks like:
class AddNewColumnToOwner < ActiveRecord::Migration
def change
add_column :owners, :source, :string
add_column :owners, :source_other, :string
end
end
And I know the migration has worked because I can see in my rails console that owners do have source and source_other listed as attributes.
Then, I've added it to the new owner form views/owners/new.html.haml:
.field{style: 'padding-bottom:0px;' }
= f.input :source, as: :select, collection: HOW_HEAR, label: 'How did you hear about us?', allow_blank: false
.field#other_source_field
= f.input :source_other, input_html: { class: 'text_field' }, label: 'If other please let us know where you heard about us'
However, when I fill out the form to add a new owner and select one of the source options, it's not storing this in the table. I know this because when I check Owner.last in my rails console, I can see that source is 'nil', even though I selected an option for source in the form dropdown options.
I must be missing something but I'm not sure where I'm going wrong...?
您必须忘了允许在控制器中使用这些其他字段的参数。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.