working 2 models: films , categories, , trying setup form films uses association categories prepopulate can found in dropdown. if delete , :collection => category.all(order: 'prototype'), prompt: "choose category" films/_form, see 'prototype' field of categories not correctly rendered , instead see like:

checked out simpleform docs don't find can help. *edited include better link can seen have used suggested in simpleform.
film.rb
class film < activerecord::base has_many :categories end category.rb
class category < activerecord::base belongs_to :film end films/_form.htm.erb
<%= simple_form_for @film |f| %> <%= f.input :title, required: false %> <%= f.association :categories, :collection => category.all(order: 'prototype'), prompt: "choose category" %> <%= f.button :submit %> <% end %> categories/_form.htm.erb
<%= simple_form_for(@category) |f| %> <%= f.error_notification %> <div class="form-inputs"> <%= f.input :prototype %> </div> <div class="form-actions"> <%= f.button :submit %> </div> <% end %> trace in terminal
argumenterror - wrong number of arguments (1 0): app/views/films/_form.html.erb:3:in block in _app_views_films__form_html_erb___839547296437048808_70229269835880' actionview (4.2.1) lib/action_view/helpers/capture_helper.rb:38:inblock in capture' actionview (4.2.1) lib/action_view/helpers/capture_helper.rb:200:in `with_output_buffer'
the simple form docs didn't because problem isn't simple form how you're using active record. of rails 4, no longer pass options all:
company.all(order: 'prototype') should be
company.order('prototype')
Comments
Post a Comment