Newbie question, I have seen create! what does it mean

N

Noppanit

Hi All,

I have some newbie question, and I have been searching all over google
for a long time. Could some of you please explain me why do we have to
use ! instead of normal method

like
@stock = Stock.create! params[:stock]

what does the "!" actually mean?

Thank you very much.
 
D

David A. Black

Hi --

Hi All,

I have some newbie question, and I have been searching all over google
for a long time. Could some of you please explain me why do we have to
use ! instead of normal method

like
@stock = Stock.create! params[:stock]

what does the "!" actually mean?

It's just a character in the method name, but it has a special
conventional significance:

http://dablog.rubypal.com/2007/8/15/bang-methods-or-danger-will-rubyist

(The Rails source code, on the whole, does not follow the convention,
which I've always thought was too bad.)


David
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,900
Latest member
Nell636132

Latest Threads

Top