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

Ruby

Rey Adronico Baguio
Rey Adronico Baguio
13,672 Points

New and Create method

What's the difference between the new and create methods in Rails controllers?

And why the need to create a private parameter on create methods, but not on new methods?

1 Answer

Seth Reece
Seth Reece
32,867 Points

Hi Rey

New uses a GET request, create uses a POST request. If we take a User, new will retrieve a form from .../users/new route and pull a form. Create will take the information inputted and POST to ..../users route. The private method passed into the create method tells create what parameters it has permission to write to the database. There are some good table references on routing here.

Rey Adronico Baguio
Rey Adronico Baguio
13,672 Points

Ohh that clears it up (GET vs POST).

Thanks so much Seth Reece