França,

There is a reason for that? They sound useful in a lot of scenarios.

On Wednesday, October 30, 2013 2:02:54 PM UTC-2, Rafael Mendonça França 
wrote:
>
> The bang methods are private and should not be used in applications (see 
> the :nodoc: in the method definition)
>
> Rafael Mendonça França
> http://twitter.com/rafaelfranca
> https://github.com/rafaelfranca
>
>
> On Wed, Oct 30, 2013 at 1:51 PM, Gary Weaver <garys...@gmail.com<javascript:>
> > wrote:
>
>> I understand that bang methods in the classic Ruby sense are supposed to 
>> alter the current instance, but getting errors like:
>>
>> NoMethodError: undefined method `where!' for #<Class:0x007ff1522d3110>
>>
>> and
>>
>> NoMethodError: undefined method `includes!' for #<Class:0x007ff1522d3110>
>>
>> when calling the bang methods from QueryMethods on a model class are 
>> really not helpful.
>>
>> It's understandable that you don't want to pass a model class into a 
>> method that expects a relation that it can act upon and change with a bang 
>> query method and have it successfully create a new relation and call some 
>> method on it that is never again seen, hence the error. I also understand 
>> wanting to avoid any more checking/raising code than necessary in 
>> ActiveRecord both for maintainability, clarity, and maybe efficiency- but 
>> just look at this:
>>
>> 2.0.0p247 :001 > MyModel.to_s
>>  => "MyModel" 
>> 2.0.0p247 :002 > MyModel.new.to_s
>>  => "#< MyModel:0x007fc92aa017e8>" 
>> 2.0.0p247 :003 > MyModel.where({})
>>  => ...
>> 2.0.0p247 :003 > MyModel.where!({})
>> NoMethodError: undefined method `where!' for #<Class:0x007fc92a95a240>
>>
>> Thanks!
>>
>>  -- 
>> 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-co...@googlegroups.com <javascript:>.
>> To post to this group, send email to 
>> rubyonra...@googlegroups.com<javascript:>
>> .
>> 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 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/groups/opt_out.

Reply via email to