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
# MODEL | |
class Theater | |
named_scope :with_recent_comments, | |
:select => "*, recent_comments.created_at AS last_comment_at", | |
:joins => "INNER JOIN (SELECT id, entity_id, created_at FROM comments WHERE entity_type = 'Theater' LIMIT 100) | |
AS recent_comments ON recent_comments.entity_id = theaters.id", | |
:order => "recent_comments.created_at DESC" | |
end |
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
def screenshot | |
require 'capybara/util/save_and_open_page' | |
now = Time.now | |
p = "/#{now.strftime('%Y-%m-%d-%H-%M-%S')}-#{rand}" | |
Capybara.save_page body, "#{p}.html" | |
path = Rails.root.join("#{Capybara.save_and_open_page_path}" "#{p}.png").to_s | |
page.driver.render path | |
Launchy.open path | |
end |
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
require "sinatra/base" | |
require "sinatra/namespace" | |
require "multi_json" | |
require "api/authentication" | |
require "api/error_handling" | |
require "api/pagination" | |
module Api | |
class Base < ::Sinatra::Base |