ruby - Create administration area in Rails app -
i'm creating blog rails , first thing i've done administration area (by thing have in application). i've used bootstrap design pages , devise authentication.
for models, views , controllers used scaffolding
, generated both admin
, post
models.
the problem have create real blog , access administration panel using /admin
route. example, create new post should access http:/mysite/admin/posts/new
.
another problem have totally different design in public blog page (not bootstrap) , of course i'll have different controllers, views , routes.
so, can done?
i suggest removing admin
model in case seems more namespace model. instead create :admin
namespace in routes.rb
file like:
namespace :admin resources :posts end
this cause routes inside of block prefixed w/ admin
. url editing post on admin side admin/posts/:id/edit
.
next suggest making admincontroller
of admin controllers inherit from. way can specify new layout. can create admin::postscontroller
@ app/controllers/admin/posts_controller.rb
app/controllers/admin_controller.rb
class admincontroller < applicationcontroller layout 'admin' end
app/controllers/admin/posts_controller.rb
class admin::postscontroller < admincontroller def index # admin/posts end end
app/views/admin/posts/index.html.erb
hello admin/posts view!
Comments
Post a Comment