Reputation: 13
I'm building a frontend part in my rails app. The controllers like posts, comments, etc., will be in a folder I named it public. Therefore, the folders of posts in view is inside public folder as well, but I would like routes come after the root like:
localhost:3000/posts
NOT: localhost:3000/public/posts
It means I would like to skip public folder in routes.
Upvotes: 1
Views: 287
Reputation: 17802
In your routes file, you can write the following:
scope module: 'public' do
resources :posts
end
Now, it will generate routes without the word public
.
Not, for it to work, PostsController
must be inside a folder name: public
, and its name should be something like following:
class Public::PostsController < ApplicationController
end
Upvotes: 1