Displaying 3 results from an estimated 3 matches for "find_or_initialize".
2010 Jul 12
0
[Patch][Issue #5097] attributeless find_or_create/find_or_initialize
This patch relaxes DynamicFinderMatch to recognize find_or_create /
find_or_initialize without a trailing _by_attribute_list. I''ve found
this useful when the relevant attributes have already been built up
through a chain of associations or named scopes.
Please review, thank you!
--
You received this message because you are subscribed to the Google Groups "Ruby on Ra...
2008 Aug 31
9
assigning collection values and exceptions
hi everyone,
I''ve this code in my Report model:
has_many :report_reasons, :validate => true
has_many :reasons, :through => :report_reasons #, :uniq => true
# :accessible => true
def reason_attributes=(reason_attributes)
reasons.clear
reason_attributes.uniq.each do |reason|
reasons << Reason.find_or_create_by_content(reason)
end
end
2010 Mar 13
6
Find first or create
Is there any ActiveRecord''s dynamic finder that can allow me to find
first association or create it if it doesn''t exist. Something like this
(not this code is conceptual - it does not work!):
Comment.posts.find_or_create(:first)
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: