Question

So I have my main page, landingpage.html.erb, and I want to put a link on there that will lead to another simple page with a few more links to outside sources.

landingpage.html.erb

<%= link_to "press", '/press', :method => :get %>

press.html.erb

<h1>Test!</h1>

(I also made a partial, to test if that would get displayed. Its the same is press.html.erb but _press.html.erb)

Controller

def press
  end

Error I keep getting:

Routing Error
No route matches [GET] "/press"

Where am I going wrong? Thanks.

Was it helpful?

Solution

You need to add the route to your config/routes.rb too. It depends on how you defined your other routes but a basic definition look like this:

get '/press', to: 'controller_name#press'

Read more about Routing in the Rails Guides.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top