ruby on rails - Before filter syntax difference -


what difference between these 2 clips of code? first clip labeled "this one:" , second clip labeled "and this:". (.rb)

class reseller < activerecord::base attr_accessible :blah, :blah, :contact_email 

this one:

before_save { |reseller| reseller.contact_email = contact_email.downcase } 

and this:

before_save { contact_email.downcase } 

thank you

the first sets value back persisted property (or @ least should; i'd double check).

the second downcases , nothing result.

if second read contact_email.downcase! should modify actual property.

the "bang" method follows ruby convention of naming destructive methods, e.g., methods alter underlying data, trailing !.

note: tadman points out, you'd need vet against ar tests make sure app still functions expected, since may bypass of ar's magic.


Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -