0

I have created a simple has_many and belongs_to relationship between two activerecords and when i try to create uninitialized constant Tool::Version,

tool.rb:

class Tool < ActiveRecord::Base
  attr_accessible :name
  validates_presence_of :name
  has_many :versions
end

versions.rb

class Versions < ActiveRecord::Base
  belongs_to :tool
  attr_accessible :tool_version
end

abc.html.erb:

<%= form_for([@tool, @tool.versions.build]) do |f| %>
    <div class="field">
        <%= f.label :version %><br />
        <%= f.text_field :version %>
    </div>
    <div class="actions">
        <%= f.submit %>     
    </div>

<% end %>

on submit I get the error. what am i doing wrong here??

Arjun Ramesh
  • 189
  • 1
  • 12

2 Answers2

0

Your text_field should be tool_version and not version

rb512
  • 6,880
  • 3
  • 36
  • 55
0

You should change the class name

The class name should be Version, not Versions

class Versions < ActiveRecord::Base
  belongs_to :tool
  attr_accessible :tool_version
end
Danny Beckett
  • 20,529
  • 24
  • 107
  • 134
chegoon
  • 49
  • 1