0

I have a Table called Blog which has 20 entries. Now i want to create 20 routes fetching title from the Blog table with minimal code or method in routes file.

And i dont want to create it manually. like whenever i add new entry to table, new route need to be created.

2
  • You probably want one route that uses slugs. Start by googling "rails slug" and go from there. Commented Mar 23, 2022 at 16:47
  • get '/:blog_url', to: 'blogs#show' . blog_url act as slug. but this will take any string and requirest is going to show method of blogs controller. there for i want to generate path for only those url which are already present in the Blog table..and i dont want get '/blogs/:blog_url', to: 'blogs#show' /blogs/ prefix in url. Commented Mar 24, 2022 at 11:38

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.