0

I worked off of a tutorial and it seems the syntax for my new.html.erb is outdated. I am not certain for sure but here is my code:

    <h1>Add new skill</h1>
<%= form_tag :action => 'create' %>
<p><label for="skill_title">Title</label>:
<%= text_field 'skill', 'title' %></p>
<%= collection_select(:skill,:id, :title) %></p>
<%= submit_tag "Create" %>
<%= end_form_tag %>
<%= link_to 'Back', {:action => 'list'} %>

my error is this:

    ArgumentError in Skills#new
Showing app/views/skills/new.html.erb where line #5 raised:

wrong number of arguments (3 for 5..7)

and it is pointing to this line specifically as the problem:

 <%= collection_select(:skill,:id, :title) %></p>

I will keep researching and hopefully will find my answer. Thank you anyone who takes a look, cheers! and good luck!

ZachyBear
  • 297
  • 3
  • 15
  • possible duplicate of [What does "wrong number of arguments (1 for 0)" mean in Ruby?](http://stackoverflow.com/questions/7537450/what-does-wrong-number-of-arguments-1-for-0-mean-in-ruby) – Michael Petrotta Jun 20 '14 at 04:40
  • Also possible duplicate of [Can someone explain collection_select to me in clear, simple terms?](http://stackoverflow.com/q/8907867/2413778) – John C Jun 20 '14 at 04:44
  • It is not a duplicate, I am not the same person if that's what you mean. – ZachyBear Jun 20 '14 at 04:54

1 Answers1

1

collection_select requires an identifier as the first argument and in the provided example the variable form is not set. Therefore the code should read:

<%= collection_select :skill, :id, Skill.all, :id, :name %>

Try this i don't know your model attributes so map your code to look like this.

And also see:

Collection_select

Abdul Baig
  • 3,683
  • 3
  • 21
  • 48