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


Re-routing form-submits? Advice please?

Hey everyone.

I would like users to be shown the homepage of my app after clicking the submit button on a form. With rails scaffolds the standard is to show the "listing" page after this action.

The idea is for me to be able to view the list (details for mailing list) and the new user is now back on the homepage. I am also unable to find a way to change the default "names" for these buttons.

I am using rails 4 simple_form3 and bootstrap3.

I wasn't 100% sure I had done this the right way, as this is different to the 'user-signup' through devise and it is just a temporary way to collect data until I am finished some other features. is there a gem or a plugin that could handle this task better? In principle this way works but it doesn't seem very efficient.

Any help/advice would be greatly appreciated.

2 Answers

Jason Seifer
Jason Seifer
Treehouse Guest Teacher

Hey pat saunders! You can handle that in the create or update action of your controller. By default Rails will redirect back to the index but you could always change it to root_path for a particular action.

Thanks Jason Seifer, my confusion turned out to be with the names 'index' and 'root_path'. By default rails roots to the index of the particular scaffold not the index of the whole site. I have changed it to root_path and everything is working perfectly.

Great instruction thanks so much!