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

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.

Hi –

On Fri, 5 Feb 2010, Noppanit wrote:

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