I use Active Admin, and I have a one-to-many relationship between the two models:
class WeeklyMenu < ActiveRecord::Base has_many :menu_items attr_accessible :menu_items accepts_nested_attributes_for :menu_items end
On the admin page for WeeklyMenu, I want to display five menu_items. This is what my admin page looks like:
ActiveAdmin.register WeeklyMenu do form do |f| f.inputs "Details" do f.input :title f.input :week end f.has_many :menu_items do |menu_item| menu_item.input :title end f.buttons end end
This gives me a very nice interface for adding additional menu_items, but I want the user to have five of them - no more and no less. How can I do it?
source share