Search code examples
htmlruby-on-railsfrontendsimple-form-for

Having troubles getting my rails form to work


I've been trying for hours to get my rails form to work but I can't. The error that it keeps throwing says:

ArgumentError at / wrong number of arguments (3 for 1..2)

and the line of code where it says this error occurs is at the f.input line. Any ideas?

.select-width
 = f.label :country 
 = f.input :country, :select, :as => :fancy_select, collection: ['South Africa', 'Nigeria', 'Zimbabwe', 'Mali', 'Namibia'], hint: 'Lorem ipsum hint'

Solution

  • In simple_form, input requires only two parameters.

    1. for field name
    2. hash of options (This parameter is optional)

    So, you can use following code. It will work fine.

    .select-width
      = f.label :country
      = f.input :country, as: :fancy_select, collection: ['South Africa', 'Nigeria', 'Zimbabwe', 'Mali', 'Namibia'], hint: 'Lorem ipsum hint'