New Discussion

Notifications

You’re not receiving notifications from this thread.

How do I have a root route without an action parameter in the URL?

0
Rails

My system is using a post model with friendly_id so the calls are /name_of_the_post and this works great.
The initial home page is also a post so in routes.rb I have

    root 'home#index'
        get ':slug', to: 'posts#show_post', as: 'show_post'

    ```
    My HomeController has the following index action
    ```
        def index
        redirect_to '/home'
    end
    ```
    The PostsController will pick up home slug and show the post, however my URL is now localhost:3000/home and I want it to be 
    localhost:3000/

    How can I achieve this stripping the home slug (only for home)
Join the discussion
Create an account Log in

Learning Ruby on Rails? Join our newsletter.

We won't send you spam. Unsubscribe at any time.