Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Lee Hughes
8,380 PointsCreating controllers - Problems with URLs dashes and underscores
I needed different styles and a different layout for certain pages on my app so I created a new controller using
rails g controller subject-text index
While it produced the files I wanted, my server shows a 404 error.
In Sublime the file has been created and shows find me in
Find me in app/views/subject_test/index.html.erb
If I go to this file the message displays the correct content.
But why does rails convert my dash between subject-test to an underscore: subject_test ?
Is there a way I can make rails use a dash?
1 Answer
Nima Shariatian
1,760 Pointsif i understand you correctly, you can use the routes file to have dashes in the url :
match '/about-us' => 'pages#about'
for a resource you can something like :
resources :user_bundles, :path => '/user-bundles'
hope this helps
Lee Hughes
8,380 PointsLee Hughes
8,380 PointsThanks, I'll give it a try :)