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
<% cache(["categories", "index", "project", @project.id], :expires_in=>1.hour) do %> | |
<ul id="category_list" class="challenges columned clearfix"> | |
<% @categories.each do |c| %> | |
<li class="grid_4"><a href="<%= category_path(c) %>"> | |
<% if p = c.lead_photo_for(@project) %> | |
<div class="image" style="background: url(<%= p.square_src(220) %>) center center no-repeat;"><!-- <%= p.byline %> --></div> | |
<% end %> | |
<div class="info"><h3><%= c.name %></h3></div> | |
</a></li> | |
<% 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
## Example inspect result, stored as 'line' | |
"max = 60\n" | |
## Test | |
line.match(/.*(max|count|active|inactive|global queue).*[=:]\s+(\d+).*/) | |
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
Tempfile.open(filename) do |t| | |
begin | |
t.binmode | |
t.write Net::HTTP.start(host){|http| http.get(url)}.body | |
FileUtils.cp(t.path, filepath) | |
ensure | |
t.close! | |
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
SELECT groups.id, groups.created_at AS group_created, MAX(gu.created_at) AS newest_user, MAX(gp.created_at) AS newest_photo, GREATEST(groups.created_at, IFNULL(MAX(gu.created_at), 0), IFNULL(MAX(gp.created_at), 0)) AS latest_activity FROM groups | |
LEFT OUTER JOIN groups_users gu ON groups.id = gu.group_id | |
LEFT OUTER JOIN group_photos gp ON groups.id = gp.group_id | |
GROUP BY groups.id |
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 Comment < ActiveRecord::Base | |
has_one :photo_invite | |
has_one :critique | |
def attachment | |
if photo_invite and photo_invite.invited_to | |
photo_invite | |
elsif critique then critique | |
else nil | |
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
Sass.compile(render :template=>'../assets/stylesheets/theme.css.scss').html_safe |
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
resources :photos | |
## Results in standard restful routes, including | |
## photo GET /photos/:id(.:format) photos#show | |
match '/photos/:id(/in/:collection)' => 'photos#show', :via=>:get, :as=>'photo' | |
## Overrides old photo_path with | |
## photo GET /photos/:id(/in/:collection)(.:format) photos#show |
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
/photos/:id/in/:collection_with_delim | |
## /photos/123/in/category-landscapes | |
/photos/:id/in/:collection/:collection_id | |
## /photos/123/in/category/landscapes |
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 MobileApi | |
def self.included(base) | |
base.extend ClassMethods | |
end | |
class ClassMethods | |
def mobile_api(*args) | |
opts = args.extract_options! | |
self.class_eval do |
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
collection @photos | |
extends 'photos/show' | |
node(:src){|photo| photo.src(:thumb) } |