Documentation for include? method for active record ruby on rails
Where is the documenta开发者_如何学Pythontion for the include? method?
include? is actually a method in the Ruby array class. It isn't a Rails method.
http://www.ruby-doc.org/core/classes/Array.html#M000265
Hope that helps.
For records (I know it's 5+ years old), there is an include?
method for ActiveRecord in Rails (at least now), which works for collections (e.g. has_many reference):
https://github.com/rails/rails/blob/master/activerecord/lib/active_record/associations/collection_association.rb#L274
def include?(record)
if record.is_a?(reflection.klass)
if record.new_record?
include_in_memory?(record)
else
loaded? ? target.include?(record) : scope.exists?(record.id)
end
else
false
end
end
It's from Ruby API, not Rails API:
http://www.ruby-doc.org/core/classes/String.html#M001178
精彩评论