2

i just start playing with active_admin, I have 2 resources:

class Category < ActiveRecord::Base
  validates :name, :presence => true
  has_many :auctions  
end

and

class Auction < ActiveRecord::Base
  belongs_to :category
end

under app/admin I have auctions.rb and categories.rb

ActiveAdmin.register Auction do
end
ActiveAdmin.register Category do
end

my questions are:

  • in order to show all the auctions for a given category what should i do to generate the nested resource for it? (/admin/categories/1/auctions)
  • in my frontend i have to show all the auctions without the admin/ prefix, basically I need this http://local/auctions available, I tried to add in the routes.rb the directive resources :auctions but I need to generare a new auctions controller outside the admin/ scope. Is this a good way to take?

Thank you

Mattia Lipreri
  • 953
  • 1
  • 16
  • 30

1 Answers1

1

First, what you could do, is to place this activeadmin directive in the 'register' block

ActiveAdmin.register Auction do
  belongs_to :auction
end

You may want to check out this page: https://github.com/gregbell/active_admin/issues/search?utf8=%E2%9C%93&q=belongs_to

And second; that is indeed the right way. Create a separate auctions controller outside the admin scope. Good luck.

Sjors Branderhorst
  • 2,138
  • 17
  • 25