0

I have a blog that use authentication and where users are able to create posts my post is generated via scaffold and want that users when want to edit a posts they will redirected to something like this localhost:3000/posts/jack-stone/the-first-post/edit instead of localhost:3000/posts/the-first-post/edit (jack-stone is the user full name and the-first-post is the post title (I'm using FriendlyId gem for this)) How can i achieve this? my actual routes for posts is resources :posts

Loenvpy
  • 899
  • 1
  • 10
  • 30

1 Answers1

0

You might want to configure using match statement with a pattern.

match '/posts/:user_full_name/:post_title/edit', :to => "posts#edit", :via => 'get'

Params available in posts#edit will then be params[:user_full_name] and params[:post_title].

Further reading: here

manu29.d
  • 1,538
  • 1
  • 11
  • 15