@davidifranco This is not what the question is about
How to keep track of selected user resource and show content accordingly?
I have came across such projects a lot where a user has many resources, and user is shown a dashboard according to the resource he has selected. For example, I worked for a company that has multiple hotels in India. They wanted a CMS system in which they can add a hotel and then manage that particular hotel by adding different details defined in different section of the dashboard. My question is how to keep track of selected hotel.
1
Pass hotel id as GET parameter
domain.com/dashboard/hotel-images?id=1342
2
Pass hotel id/slug as route parameter
e.g. domain.com/hotel-1/dashboard/hotel-images
3
Store selected hotel id/details in session
4
Whenever user selects a hotel, make a controller to add fresh timestamp to hotel table's last_accessed_at field and then whenever a user tries to access a page, just look for a hotel with most recent value in that column. This way, when user loges in again in the future, he will get the last accessed hotel dashboard opened by default, which wont be possible with sessions.
Which approach is a good practice? Or is there any better way to deal with this?
I would go with option 2. I have a legacy project that does a mix of 2 and 3. Those places where it uses option 2 are very good. Lets say one of our users has an issue, the person can just send me the url. (same with user to use)
In this project I often see people send around urls like http://example.com/admin/report/edit with a text like "Please set up new reports in the same way as the report listed here".. But as it is session based the recipients have no clue what report is being talked about
For companies (customers) we use the url approch http://example.com/admin/company/22/edit meaning people can share this link and we will always see the same page.
Please or to participate in this conversation.