0
내 프로젝트에 ActiveAdmin gem을 사용하고 있습니다.액티브 관리자의 도서에 태그 추가
has_many 연관을 사용하는 2 개의 모델이 있습니다. 본질적으로 Book_Mapping Table을 통해 has_many 태그를 가진 Book 모델을 가지고 있습니다.
Active Admin의 책 양식에서 책에 태그를 편집/추가하고 싶습니다.
하지만 내 양식에 이것을 표시하는 데 문제가 있습니다. 누구나 적절한 Active Admin 양식 구조를 만들 수 있습니까?
모형
class Book < ActiveRecord::Base
has_many :book_mappings
has_many :tags, through: :book_mappings
##Not sure if I should use this...
accepts_nested_attributes_for :book_mappings
accepts_nested_attributes_for :tags
end
class BookMapping < ActiveRecord::Base
belongs_to :book
belongs_to :tag
end
class Tag < ActiveRecord::Base
has_many :book_mappings
has_many :books, through: :book_mappings
end
ActiveAdmin을
ActiveAdmin.register Book do
###Should this permit any other params?
permit_params :title
form do |f|
f.inputs "Book Detail" do
f.input :title
end
f.has_many :book_mappings do |app_f|
app_f.inputs "Book Tags" do
###Other than a Create Tag button,
###The actual form fields don't appear at all...
app_f.input :book_tag_id
end
end
end
#Show Page (Is there a way to show the selected tags here?)
show do |pic|
attributes_table do
row :title
end
end
end
어떻게하면 내보기 페이지에서 선택된 태그를 표시 할 수 있습니까? 아니면 activeadmin을 통해 표시 할 수 있습니까? 위의 코드를 업데이트했습니다 ... –
정말 고맙습니다. :) –