Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

country_select gem wrong number of arguments error

I put this in my gemfile

gem 'country_select'

I run bundle install

I put this in my form

= f.country_select(:country, priority_countries: ["US"])

Then when I restart the server and load the page I get the following error:

ActionView::Template::Error (wrong number of arguments (given 1, expected 0)):

Rails 5.2

here is the entire form:

= form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put }) do |f|

    .row
      .col.s12      
        = devise_error_messages!

    .row
      .input-field.col.s12
        = f.text_field :city
        = f.label :city

    .row
      .input-field.col.s12
        = f.label :country  
        %br
        = f.country_select(:country, priority_countries: ["US"])

This is the error:

ActionView::Template::Error (wrong number of arguments (given 1, expected 0)):
    20:           .input-field.col.s12
    21:             = f.label :country
    22:             %br
    23:             = f.country_select(:country, priority_countries: ["US"])
like image 895
don_Bigote Avatar asked Oct 16 '22 14:10

don_Bigote


2 Answers

Hi As per the user docs

Because you are using with devise I am assuming you are using this on your user model, there for you must call country_select("user", "country", priority_countries: ["US"])

If your devise model is called something else, replace user with the model name

like image 167
Joe Bloggos Avatar answered Oct 21 '22 09:10

Joe Bloggos


In reference to the issue that I opened on GitHub.

Running bundle update and restarting the rails server solves the problem.

like image 42
dcangulo Avatar answered Oct 21 '22 08:10

dcangulo