Last active
February 22, 2017 17:22
-
-
Save Fernan2/a6fc86c51b629c61903b8e7323be25d9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
user.phone_1 = '963112233' | |
user.phone_4 = '666111000' | |
user.phone_2 = '678111000' | |
phones = (1..4).map do |i| | |
user.send("phone_#{i}") | |
end | |
=> ['963112233', '678111000', nil, '666111000'] | |
VALID_SECTIONS = %w(banca bolsa fondos) | |
def filter_by_section(param_section) | |
return unless param_section.in?(VALID_SECTIONS) | |
Message.send("in_#{param_section}") | |
end | |
tagging.tag_id = 1234 | |
tagging.taggable_type = 'Post' | |
tagging.taggable_id = 56 | |
Class Tagging | |
def taggable | |
taggable_type.constantize.find(taggable_id) | |
end | |
end | |
tagging.taggable | |
=> Post.find(56) | |
def pictures(format, order = 'created_at desc', limit = nil) | |
"Look for *.#{format} files in order #{order} maximum #{limit || 'all'}" | |
end | |
item.pictures('jpg') | |
item.pictures('jpg', 'likes_count desc') | |
item.pictures('jpg', 'created_at desc', 20) | |
def pictures(format:, order: 'created_at desc', limit: nil) | |
"Look for *.#{format} files in order #{order} maximum #{limit || 'all'}" | |
end | |
item.pictures(format: 'jpg') | |
item.pictures(format: 'jpg', order: 'likes_count desc') | |
item.pictures(format: 'jpg', limit: 20) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment