This file contains hidden or 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
last_post = Post.limit(1).offset(2999).order("created_at desc") |
This file contains hidden or 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
module FindRecentExtension | |
def find_recent | |
where("created_at > ?", 5.days.ago) | |
end | |
end | |
class Customer < ActiveRecord::Base | |
has_many :orders, :extend => FindRecentExtension | |
end | |
This file contains hidden or 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
class Customer < ActiveRecord::Base | |
has_many :orders do | |
def find_by_order_prefix(order_number) | |
find_by_region_id(order_number[0..2]) | |
end | |
end | |
end |
This file contains hidden or 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
def get_facebook_friends(access_token) | |
@graph = Koala::Facebook::API.new(access_token) | |
friends = @graph.get_connections("me", "friends?fields=id,name,picture.type(large)") | |
return friends | |
end |
NewerOlder