4
votes

Currently running through a ruby on rails guide and I seem to have hit a slight snag. I duplicated a view in one of my view folders:

hello.html.erb and index.html.erb

When trying to access it via browser (localhost:3000/demo/"...") Only the original demo/index works but demo/hello has "No Route Matches"

2
Could you please paste your config/routes.rb?? - zapico
The rails guides are excellent and answers this question guides.rubyonrails.org/routing.html - Alexander Christiansson
Thanks for the concern Zapico the problem has been solved. Alexander thanks for the link I'm sure it will come in handy really soon. - Geno Diaz
Mark the answer as correct to close it ;) - zapico

2 Answers

16
votes

Add

 get "demo/hello" => "your-controller#your/action"

to your routes.rb

For example:

app/controllers/demos_controller.rb:

class DemosController < ApplicationController

  def hello
  end

end

app/views/demos/hello.html.erb:

<p>Hello World</p>

config/routes.rb:

get "demo/hello" => "demos#hello"

UPDATE: From the comments: check out the rails guide for more details: http://guides.rubyonrails.org/routing.html

0
votes

get 'your url path', to: 'yourcontroller#youraction' eg.

get '/demos/hello', to: 'demos#hello'