Created
November 29, 2011 21:29
-
-
Save suciuvlad/1406594 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 Article < ActiveRecord::Base | |
| has_one :publication, :as => :publicationable | |
| accepts_nested_attributes_for :publication | |
| end |
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
| def new | |
| @article = Article.new | |
| @article.build_publication | |
| end |
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
| <%= form_for [:admin, @article], :html => { :class => "lalign" } do |f| %> | |
| <%= f.fields_for :publication do |builder| %> | |
| <div class="clearfix"> | |
| <%= builder.label :name %> | |
| <div class="input"> | |
| <%= builder.text_field :name, :class => "span9" %> | |
| </div> | |
| </div> | |
| <% end %> | |
| <% end %> |
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 Publication < ActiveRecord::Base | |
| belongs_to :publicationable, :polymorphic => true | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment