Skip to content

Instantly share code, notes, and snippets.

@bsodmike
Created November 23, 2011 10:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save bsodmike/f347dabb4d37f365328b to your computer and use it in GitHub Desktop.
Save bsodmike/f347dabb4d37f365328b to your computer and use it in GitHub Desktop.
module Admin::VideosHelper
def check_attributes(r, blank_check, exists_check)
trigger = false
blank_check.each do |i|
trigger = true if r.send(i.to_sym).blank?
end
exists_check.each do |j|
trigger = true if !r.send(j.to_sym).exists?
end
trigger
end
end
# r.en_title.blank? || r.ar_title.blank? || r.fr_title.blank? || !r.cover_en.exists? || !r.cover_ar.exists? || !r.cover_fr.exists? || !r.insert_en.exists? || !r.insert_ar.exists? || !r.insert_fr.exists?
@bsodmike
Copy link
Author

Consider incorporating

[:en, :ar, :fr].any? {|lang| r.send("#{lang}_title").blank? || !r.send("cover_#{lang}").exists? }

or define an instance method to call #title(:en)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment