Hello, 

Consider this code, it gets a mention and an array of tags.
It finds the mentions and add the tags.
But in my methods I keep using return if foo.nil?
or execute a line of code if a line is not nil.
Is there a better way of doing this kind of thing?
Thks

def add_tags_to_mention mention_id, *tags
mention = Mention.find mention_id
return if mention.nil?
tags.each do |tag_id|
tag = Tag.find tag_id
mention.tags.push(tag.to_mongo) if tag
end
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 rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msg/rubyonrails-talk/-/Vre8k4twtb4J.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to