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 fetch(col) | |
t = self.class.arel_table | |
ar = t.project(t[col]).where(t[:id].eq(id)) | |
self.class.uncached do | |
self.class.connection.select_value(ar.to_sql) | |
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
render(:template=>'base/header', :formats=>[:mustache], :handlers=>[:erb]) | |
## ActionView::Template::Error (Missing template base/header with {:locale=>[:en], :formats=>[:html], :handlers=>[:erb, :builder, :rabl, :rjs]} |
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
{ | |
"status": <%= response.status %>, | |
<% if @error %>"error": <%= @error.to_json.html_safe %>,<% end %> | |
"version": "<%= version(yield) %>", | |
"template": "<%= controller.controller_name %>-<%= controller.action_name %>", | |
"result": <%= yield %> | |
} |
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
## Initial request / response, appcache is outdated so second request won't use cached page but will re-request it. | |
Processing by Mobile::PhotosController#show as HTML | |
Parameters: {"id"=>"1052"} | |
... | |
Rendered text template within layouts/mobile (0.0ms) | |
Completed 200 OK in 49ms (Views: 33.0ms | ActiveRecord: 3.1ms | Sphinx: 0.0ms) |
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
object(nil) | |
node(:total){ @comments.total_entries } | |
node(:page){ @comments.page } | |
node(:per_page){ @comments.per_page } | |
child(@comments => :items) do | |
extends 'comments/base' | |
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
TIMESTAMPDIFF(HOUR, '2012-08-30 22:13:31', "2012-12-19 19:04:37") -- Gives me 2660 | |
time_to_sec(timediff("2012-12-19 19:04:37", '2012-08-30 22:13:31'))/3600 -- Gives me 838.9997 |
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
root :to => 'application#index', :as => :home | |
root :to => 'application#index', :as => :new_user, :via=>:get, :defaults=>{:anchor=>"signup"} | |
root :to => 'application#index', :as => :login_users, :via=>:get |
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
validate :group_is_real | |
def group_is_real | |
errors.add(:group, "must be an already existing group") if group_id and !group | |
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 Challenge < ActiveRecord::Base | |
has_many :challenge_photos, :dependent=>:destroy | |
has_many :photos, :through=>:challenge_photo | |
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
SELECT photos.id FROM photos | |
LEFT OUTER JOIN votes ON votes.photo_id = photos.id | |
LEFT OUTER JOIN flags ON flags.photo_id = photos.id AND flags.type="Love" | |
LEFT OUTER JOIN comments ON comments.photo_id = photos.id | |
WHERE photos.user_id = 38218 | |
GROUP BY photos.id; |