Admin Controllers in Merb

How to make controllers with names in Merb, for example, to create an admin section on a site? In Rails it is possible to use Admin :: CategoriesController, is this similar in Merb or is this another recommended way of doing this?

0


source to share


2 answers


The namespace method seems to do this.

This is put into the routes file (router.rb):

namespace :admin do
  resources :categories
end

      

This creates routes like:



edit_admin_category - /admin/categories/:id/edit(.:format)
delete_admin_category - /admin/categories/:id/delete(.:format)
admin_categories - /admin/categories(/index)(.:format)
new_admin_category - /admin/categories/new(.:format)
admin_category - /admin/categories/:id(.:format)

Then I install my controller into a module like this:

module Admin
  class Categories < Application
    def index
      ...
    end

    .
    .
    .
  end
end

      

I'm not sure if this is the recommended way, any suggestions on this would be great.

+2


source


The above answer is correct, but for what it cost me, I found it difficult to use the new route with link_to in my views.

I ended up working:



<%= link_to("Categories Admin", resource(:admin, :categories) %>

      

0


source







All Articles