rest - How to be RESTful in Ruby on Rails? -
i have decent amount of experience rails, i've been bit ad hoc development methods. i'm curious how restful in rails. here's example of app i'm working on now:
i have few models, including user, pack, , product model. models each have controller associated them. if want create new page called 'dashboard', on user can create new records on pack model, see account information, how do in restful way? create new controller called dashboard? or add controller defines 'static pages'? what's best practice regarding pages aren't exclusive actions on 1 model?
thank in advance!
yes, want 1 controller per resource. in case resource combination of things since you've identified singular meta-resource (a "dashboard") makes sense. so, i'd create dashboardscontroller
, have route like:
resource :dashboard, only: :show
then can use dashboard_url
links dashboard.
notes: singular resource
in routes file important because indicates don't have list of resources, single one. means there won't index
action , show
action default -- dashboard_url
doesn't require resource show passed it. and, regardless, controllers named in plural -- dashboardscontroller
.
Comments
Post a Comment