0
votes

I was wondering how to display an action when specifying a controller url. For example; say I have DemoController.rb, and views/demo/index.html.erb file. Also I've specified the route in routes.rb get 'demo/index'

How can I setup the project so that when I type "localhost:3000/demo" it renders the same layout as "localhost:3000/demo/index"?

Currently when I type in "localhost:3000/demo" I get a "no route matches" error.

1

1 Answers

1
votes

You need a get 'demo' => 'demo#index' instead for that URL to work.

That said, you might want to use Rails conventions and maybe pluralize the controller and use RESTful routes instead:

resources :demos, only: :index