I would like to simplify this complicated logic for creating unique Track object.
def self.create_unique(p) f = Track.find :first, :conditions => ['user_id = ? AND target_id = ? AND target_type = ?', p[:user_id], p[:target_id], p[:target_type]] x = ((p[:target_type] == 'User') and (p[:user_id] == p[:target_id])) Track.create(p) if (!f and !x) end -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/0f9XTmZfNt0J. For more options, visit https://groups.google.com/groups/opt_out.

