THpubs
THpubs

Reputation: 8172

Rails : How to display a post in a blog for normal users out side the post controller?

In my app, there's a seperate admin area to control everything including writing posts. The post routes point inside the admin panel :

resources :posts, path: '/admindashboard/posts'

Now in the normal view, Im trying to display the posts inside the pages controller under the blog action. I have managed to list the posts in the blog. But linking to them and showing individual posts is the problem.

Not : I use a post slug instead of the id.

If I link to the post like this :

<%= link_to post.title, post  %>

It will go to /admindashboard/posts/post-slug. But to access that url, we need to sign in. I need to put it like /blog/post-slug . How to do it? How to add the right action in the pages controller to display individual post pages?

Upvotes: 0

Views: 113

Answers (1)

Bashar Abdullah
Bashar Abdullah

Reputation: 1545

I think you need namespacing like this

namespace :admindashboard do
  resources :posts
end

Upvotes: 1

Related Questions