gregbell/active_admin — Issue #621: undefined method `new_record?' for #<Formtastic::SemanticFormBuilder:0x16031e78>
Author: bdastous
Created: 2011-10-14 18:32:06+00:00
State: open

Here is my Gallery form that throws the error:

<%= semantic_form_for [:admin, @gallery] do |g| %>
<%= g.inputs "Details" do %>
<%= g.input :title %>
<%= g.input :images, :as => :check_boxes, :label_method => Proc.new { |image| image_tag(image.thumb_path, :alt => "") + content_tag("h3", image.title) } %>
<% end %>
<% @gallery.images.build %>
<%= g.inputs :for => :images, :name => "New Image" do |image| %>
<% if image.new_record? %>
<%= image.input :title %>
<%= image.input :asset, :as => :file %>
<% end %>
<% end %>
<%= g.buttons %>
<% end %>

Here is my Gallery model:

class Gallery < ActiveRecord::Base
belongs_to :admin_user
has_and_belongs_to_many :images
accepts_nested_attributes_for :images
end

Here is my Image model:

class Image < ActiveRecord::Base
belongs_to :admin_user
has_and_belongs_to_many :galleries

has_attached_file :asset, :styles => {
:thumb => "96x96#"
}

validates_attachment_presence :asset
end