Algorithmic Programmer
Algorithmic Programmer

Reputation: 766

(Ruby on Rails) Just created a new url in routes.rb but it's rendering the view from a different page?

So, I'm painfully new to Rails, but I'm trying to build a web application with it.

I just created a new url in config/routes.rb at localhost:3000/products/toyota.

          get 'products/toyota', to: 'static#products#toyota'

The homepage (localhost:3000 on my local machine) and products page (localhost:3000/products) already exist. So, I want my new toyota page to have a view that's independent from the products page but the localhost:3000/products/toyota page keeps rendering the haml/javascript files from the products page.

Any ideas on how to fix that?

Upvotes: 0

Views: 40

Answers (1)

puneet18
puneet18

Reputation: 4427

your routes in file is incorrect. Correct way is:

get 'products/toyota', to: 'static#toyota' # "controller_name#action"

and keep this route above resources :products

Upvotes: 1

Related Questions