Not plussing or minusing this, just want to say if we did something like Josh's preferred syntax then it should be presence!, not present!, to match presence vs. present?.
Brian Morearty On Tuesday, September 24, 2013, Josh Susser wrote: > I dislike this. I'd rather see something along the lines of `present?` > that can be tacked on anywhere. Maybe something like this: > > company = current_user.company.present! > > -- > Josh Susser > http://blog.hasmanythrough.com > > > On Tue, Sep 24, 2013 at 2:58 PM, Roman > <[email protected]<javascript:_e({}, 'cvml', '[email protected]');> > > wrote: > >> Hi, >> just stumbled upon a need to raise a NotFound exception when the object >> doesn't have a necessary association. So instead of writing >> `Company.find(current_user.company_id)` or `current_user.company || raise >> AR::RecordNotFound`, maybe it would be nicer to just say >> `current_user.company!`. What do you think? >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Ruby on Rails: Core" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected]<javascript:_e({}, >> 'cvml', >> 'rubyonrails-core%[email protected]');>. >> To post to this group, send email to >> [email protected]<javascript:_e({}, 'cvml', >> '[email protected]');> >> . >> Visit this group at http://groups.google.com/group/rubyonrails-core. >> For more options, visit https://groups.google.com/groups/opt_out. >> > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Core" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected] <javascript:_e({}, > 'cvml', 'rubyonrails-core%[email protected]');>. > To post to this group, send email to > [email protected]<javascript:_e({}, 'cvml', > '[email protected]');> > . > Visit this group at http://groups.google.com/group/rubyonrails-core. > For more options, visit https://groups.google.com/groups/opt_out. > -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/rubyonrails-core. For more options, visit https://groups.google.com/groups/opt_out.
