ruby on rails - Why does @user.update_attributes(nil) return true? -



ruby on rails - Why does @user.update_attributes(nil) return true? -

i'm writing rails app , i'm trying figure out why passing invalid params update_attributes returns true.

valid params homecoming true.

for example:

@user.update_attributes(params[:user]) => true

and

@user.update_attributes(params[:whatever]) => true

also

@user.update_attributes(false) => true @user.update_attributes(nil) => true

everything returns true. why? , how check if valid params in update_attributes?

update_attributes update attributes passed, , if no attributes passed there's nil update , record may saved.

update_attributes homecoming false if record not saved due validation. however, doesn't mean attributes in hash in error... may field set elsewhere made record invalid.

# record has validation email address must valid format @user.email = "invalid address" @user.update_attributes(name: "fred") => false # due email error # record has validation email address must valid format @user.email = "fred@sample.com" @user.update_attributes(name: "fred") => true

update_attributes raise exception if seek update unknown attribute

@user.update_attributes(vegetable: "carrot") #> activerecord::unknownattributeerror: unknown attribute: vegetable

ruby-on-rails update-attributes

Comments

Popular posts from this blog

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

mediawiki - How do I insert tables inside infoboxes on Wikia pages? -

Local Service User Logged into Windows -