Question

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??

Was it helpful?

Solution

Your text_field should be tool_version and not version

OTHER TIPS

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
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top