Skip to content

Instantly share code, notes, and snippets.

@suciuvlad
Created November 29, 2011 21:29
Show Gist options
  • Select an option

  • Save suciuvlad/1406594 to your computer and use it in GitHub Desktop.

Select an option

Save suciuvlad/1406594 to your computer and use it in GitHub Desktop.
class Article < ActiveRecord::Base
has_one :publication, :as => :publicationable
accepts_nested_attributes_for :publication
end
def new
@article = Article.new
@article.build_publication
end
<%= 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 %>
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