Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Membership < ActiveRecord::Base
- belongs_to :course
- belongs_to :person
- class Course < ActiveRecord::Base
- has_many :memberships
- has_many :people, :through => :memberships
- class Person < ActiveRecord::Base
- has_many :memberships
- has_many :courses, :through => :memberships
- form do |f|
- f.inputs
- f.has_many :associations do |association|
- association.inputs
- end
- f.buttons
- end
- class Ingredient < ActiveRecord::Base
- has_and_belongs_to_many :products, :join_table => :ingredients_products
- end
- class Product < ActiveRecord::Base
- has_and_belongs_to_many :ingredients, :join_table => :ingredients_products
- end
- class CreateProductsIngredients < ActiveRecord::Migration
- def self.up
- create_table :ingredients_products,:id => false do |t|
- t.integer :product_id
- t.integer :ingredient_id
- t.timestamps
- end
- end
- def self.down
- drop_table :products_ingredients
- end
- end
- ActiveAdmin.register Product do
- form do |f|
- f.inputs "Details" do
- f.input :product_name
- f.input :brand
- f.input :ingredients # don't forget this one!
- end
- end
- ActiveAdmin.register User do
- index do
- column :id
- column :name
- column :attendance
- column :person do |membership|
- membership.person.name
- end
- column :course do |membership|
- membership.course.name
- end
- default_actions
- end
- form do |f|
- f.inputs "Membership" do
- f.input :name
- f.input :created_at
- f.input :updated_at
- end
- f.inputs :name => "Person", :for => :person do |person|
- person.inputs
- end
- f.inputs :name => "Course", :for => :course do |course|
- course.input :name
- end
- f.buttons
- end
- end
Add Comment
Please, Sign In to add comment