I am having trouble using link_to to go to my posts/index page. I have the following link_to:
<%= link_to('NEWS', posts_path(subdomain:"news"),:class=>'navtext',:style=>"color:#bfbebc!important;") %>
My routes:
resources :posts , constraints: { subdomain: 'news' }
When I am at http://news.lvh.me:3000/posts (the actual page the link_to refers to) the link works, however when I place in on any other page (for example, the root_path) it does not work. I get the No route matches [GET] "/posts"
error which I think means that the subdomain is not passed in my link_to. Any ideas on how I can do this? Thanks.
Try posts_url
, instead of posts_path
.
It works fine on my project even without (subdomain:"news")
. Just use posts_url
directly.