Skip to content

Instantly share code, notes, and snippets.

@onlymejosh
Created November 24, 2010 17:21
Show Gist options
  • Save onlymejosh/714026 to your computer and use it in GitHub Desktop.
Save onlymejosh/714026 to your computer and use it in GitHub Desktop.
#Plan
class Plan < ActiveRecord::Base
attr_accessible :title, :price, :show_id
has_one :show
has_many :paths
has_many :topics, :through => :paths
accepts_nested_attributes_for :topics
end
#Topic
class Topic < ActiveRecord::Base
establish_connection "arcticfox_#{RAILS_ENV}"
has_many :shows
has_many :paths
has_many :plans, :through => :paths
end
#Path
class Path < ActiveRecord::Base
belongs_to :plan
belongs_to :topic
end
_form
<% f.fields_for :paths do |builder| %>
<%= builder.collection_select :topic_id, Topic.all, :id, :name, :include_blank => true%>
<% end %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment