In my posts form the input to the model can only be Dog or Cat, I’ve constructed the following code and assumed it would work, however the information input into the select_tag box was never going into my database.
1 2 3 4 5 6 7 8 9 10 11 |
<% form_for(@post) do |f| %> <%= f.label :title %><br /> <%= f.text_field :title %> <%= f.label :source %><br /> <%= select_tag :source, options_for_select([ "Dog", "Cat") %> <%= f.submit 'Create' %> <% end %> |
I finally got this to work by using;
1 |
<%= f.select(:source, options_for_select({ : Dog =>'Dog',:Cat =>'Cat'} %> |
If you put the options in a hash then they will be output in a random order, to output the options in a chosen order they need to be put into an array, this left me with the following code.
View
1 2 |
<%= f.label :source %><br /> <%= f.select(:source, options_for_select(@source)) %> |
Controller
1 |
@source = [['Dog'],['Cat'],] |
Medicamentspot.com International Legal RX Medications. Special Internet Prices (up to 40% off average US price). NO PRIOR PRESCRIPTION REQUIRED!…
Combivir@buy.online” rel=”nofollow”>.…
Buy:Tramadol.Viagra Super Active+.Cialis Professional.Propecia.Super Active ED Pack.Zithromax.Viagra Professional.Maxaman.Cialis Soft Tabs.Viagra Super Force.Cialis.Viagra.Levitra.VPXL.Viagra Soft Tabs.Soma.Cialis Super Active+….
Buy:Nexium.Lumigan.100% Pure Okinawan Coral Calcium.Prevacid.Human Growth Hormone.Arimidex.Actos.Petcam (Metacam) Oral Suspension.Retin-A.Zyban.Zovirax.Synthroid.Accutane.Valtrex.Prednisolone.Mega Hoodia….