I have a rails app where I have a userpage. Each userpage is a dashboard for a user showing his listings and his activities. I am also using a User model which is coming from devise so I can't use user/:id
to refer to a user as that is used for registrations and editing passwords etc.
I added a custom route as follows:
match '/userpage', to: 'listings#userpage', via: :get
The URL looks like: http://localhost:3000/userpage?id=2
My questions are:
- I want the url to look like
http://localhost:3000/userpage/2
without creating a seperate userpage resource. How should I proceed with this? If I addmatch '/userpage/:id', to: 'listings#userpage', via: :get
its not giving me a name for the path. I mean there is no userpage_path to access in routes.I need that userpage_path to refer it at links to the userpage. - I want to show the users name instead of user_id. Right now I am showing it as:
http://localhost:3000/userpage?id=2&name=CoolShop
but I would want it to behttp://localhost:3000/userpage/CoolShop
. I know that friendly_id gem can help me out but that will need a userpage model.
Keep in mind that userpage is just a users page with his details other than his registration details provided by devise so I don't want to create a seperate model for this.