In Rails, I'm receiving an error "Model(#-12345) expected, got String(#-12345)" -


i realize there's existing question this, none of answers provided worked me. what's particularly bothersome can tell i'm passing in correct parameters through create method (or update, i'm trying use create now). debugging/error page presented rails 4 built-in server:

"url"=>"", "country"=>"1", "charge"=>"0", 

my models configured model belongs_to country , country has_many models. don't why, if i'm passing in formatted data, , i'm accessing country model (my drop-down populated appropriate names via code below), doesn't work. appreciated. i'm stumped , google has been of minimal help.

<%= f.select :country, country.all.collect { |c| [c.id, c.id.to_i] }, class: 'form-control' %> 

also note i've tried many variations including not limited to:

<%= f.select :country, country.all.collect { |c| [c.country_long_name, c.id] }, class: 'form-control' %> <%= f.select :country, country.all.collect { |c| [c.id, c.id] }, class: 'form-control' %> <%= f.collection_select :country, country.all.collect, c.country_long_name, c.id %> 

your aproaches wrong. :

<%= f.collection_select :country_id, country.all, c.id, c.country_long_name, :prompt => true %> 

also, permit country_id inside controller params.permit(:country_id)

read collection_select know more it.


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - Bypass Geo Redirect for specific directories -

php - .htaccess mod_rewrite for dynamic url which has domain names -