rstt/ArvoresBrasil — Issue #1: Has_many :trought
Author: rstt
Created: 2011-10-13 15:11:21+00:00
State: open

models/arvore.rb
...
has_many :nomes_populares, :dependent => :destroy
has_many :populares, :through => :nomes_populares
...

models/popular.rb
...
has_many :nomes_populares, :order => :ordem, :dependent => :destroy
has_many :arvores, :through => :nomes_populares
...

models/nome_popular.rb
...
belongs_to :arvore
belongs_to :popular
...

config/initializers/inflections.rb
inflect.irregular 'arvore', 'arvores'
inflect.irregular 'popular', 'populares'
inflect.irregular 'nome_popular', 'nomes_populares'

views/admin/arvores/_form.html.erb
<% Popular.all.each do |popular| -%>
<%= check_box_tag :popular_ids, popular.id, @arvore.populares.include?(popular), :name => 'arvore[popular_ids][]' %>
<%= label_tag :popular_ids, popular.nome -%>

<% end -%>

http://localhost:3000/admin/arvores/new
NameError in Admin/arvores#new
...
uninitialized constant Arvore::NomesPopular

What`s wrong ?