Created
January 31, 2011 19:28
-
-
Save reu/804631 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class NewYachtModel < ActiveRecord::Base | |
belongs_to :new_yacht | |
has_many :contents, :class_name => 'NewYachtTopicContent' | |
has_many :topics, :class_name => 'NewYachtTopic', :through => :contents | |
accepts_nested_attributes_for :contents | |
end | |
class NewYachtTopic < ActiveRecord::Base | |
belongs_to :new_yacht | |
has_many :contents, :class_name => 'NewYachtTopicContent' | |
has_many :models, :class_name => 'NewYachtModels', :through => :contents | |
accepts_nested_attributes_for :contents | |
accepts_nested_attributes_for :models | |
end | |
class NewYachtTopicContent < ActiveRecord::Base | |
belongs_to :new_yacht_model | |
belongs_to :new_yacht_topic | |
end | |
class Admin::NewYachtModelsController < Admin::AdminController | |
inherit_resources | |
def new | |
@new_yacht = NewYacht.find(params[:new_yacht_id]) | |
@new_yacht_model = NewYachtModel.new | |
end | |
end | |
= link_to '<< Voltar', edit_admin_new_yacht_path(params[:new_yacht_id]), :id => "top_link", :class => "link" | |
#form | |
%dl | |
- form_for [:admin, @new_yacht_model], :url => admin_new_yacht_models_path do |form| | |
%dt< | |
%p= form.error_messages | |
%dt= form.hidden_field :new_yacht_id, :value => params[:new_yacht_id] | |
- @new_yacht.topics.each do |topic| | |
%dt= form.label :topics, topic.name | |
- form.fields_for :contents, NewYachtTopicContent.new(:new_yacht_topic => topic) do |content_form| | |
%dd= content_form.hidden_field :new_yacht_topic_id | |
%dd= content_form.text_field :content | |
= form.submit 'Inserir', :class => 'button' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment