Search code examples
ruby-on-railslink-to

Link_to for static pages


I have made a forum-based website, I want to add a few links to my footer like "more about badges" or "how to ask questions". Well, they are static pages so I really don't want to go through controller to go to those pages. For example, I'd like to view views/static_pages/badges.html.erb using link_to or other possible tag.

How can I go directly to some page in my views?


Solution

  • For static pages you should check out high_voltage gem. Once it's installed, it'll make a folder pages inside your view directory and it'll generate a named route method of page_path. For example, if you create a static page pages/static then you can refer it to by page_path('static') in your views.

    EDIT:

    If you don't want to use any gem then I'll suggest checking out this question