내 이미지 모델과 HABTM 관계가있는 갤러리 모델에 대한 ActiveAdmin 양식을 쓰려고합니다.ActiveAdmin 양식 오류 : "정의되지 않은 메소드`new_record? '"
내 갤러리 모델에서 이미 "accepts_nested_attributes_for"를 사용하고 있으므로이 사진은 this question과 중복되지 않습니다. 여기
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
입니다 : 여기
class Gallery < ActiveRecord::Base
belongs_to :admin_user
has_and_belongs_to_many :images
accepts_nested_attributes_for :images
end
내 이미지 모델 : 여기 <% @gallery.images.build %>
<%= 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 %>
<%= 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 %>
내 갤러리 모델 : 여기
는 오류가 발생하는 내 갤러리 양식입니다 오류 로그 :
NoMethodError in Admin/galleries#edit
Showing /home/***/www/***/app/views/admin/galleries/_form.html.erb where line #8 raised:
undefined method `new_record?' for #<Formtastic::SemanticFormBuilder:0x164b2088>
Extracted source (around line #8):
5: <%= g.input :images, :as => :check_boxes, :label_method => Proc.new { |image| image_tag(image.thumb_path, :alt => "") + content_tag("h3", image.title) } %>
6: <% end %>
7: <%= g.inputs :for => :images, :name => "New Image" do |image| %>
8: <% if image.new_record? %>
9: <%= image.input :title %>
10: <%= image.input :asset, :as => :file %>
11: <% end %>
Trace of template inclusion: /home/bdastous/.rvm/gems/[email protected]/gems/activeadmin-0.3.1/app/views/active_admin/resource/edit.html.arb
Rails.root: /home/bdastous/www/hotel_app_cms
Application Trace | Framework Trace | Full Trace
app/views/admin/galleries/_form.html.erb:8:in `block (2 levels) in _app_views_admin_galleries__form_html_erb__372176781_187575760'
app/views/admin/galleries/_form.html.erb:7:in `block in _app_views_admin_galleries__form_html_erb__372176781_187575760'
app/views/admin/galleries/_form.html.erb:2:in `_app_views_admin_galleries__form_html_erb__372176781_187575760'
감사합니다. –