Hi, Maybe, can you use the method #tap?
model = Model.new(attrs).tap(&:readonly!) Best regards. ----- Geoffrey Roguelon > Le 3 juil. 2014 à 02:10, David Rueck <dru...@gmail.com> a écrit : > > I was wondering if it would make sense to return self from the readonly! > method of an ActiveRecord model? I found myself wanting to create a list of > read only instances and it seemed unnecessarily verbose to do > > model = Model.new(attrs) > model.readonly! > model > > for each of them instead of just > > Model.new(attrs).readonly! > > I've got the super small patch prepared, but I wanted to run it by some folks > before adding it to the rather large list of pull requests! > > Thanks, > > -David > -- > 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 rubyonrails-core+unsubscr...@googlegroups.com. > To post to this group, send email to rubyonrails-core@googlegroups.com. > Visit this group at http://groups.google.com/group/rubyonrails-core. > For more options, visit https://groups.google.com/d/optout. -- 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 rubyonrails-core+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-core@googlegroups.com. Visit this group at http://groups.google.com/group/rubyonrails-core. For more options, visit https://groups.google.com/d/optout.