Skip to content

Instantly share code, notes, and snippets.

View mrpunkin's full-sized avatar

Bryan Corey mrpunkin

View GitHub Profile
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
## 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)
{
"status": <%= response.status %>,
<% if @error %>"error": <%= @error.to_json.html_safe %>,<% end %>
"version": "<%= version(yield) %>",
"template": "<%= controller.controller_name %>-<%= controller.action_name %>",
"result": <%= yield %>
}
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]}
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
collection @photos
extends 'photos/show'
node(:src){|photo| photo.src(:thumb) }
module MobileApi
def self.included(base)
base.extend ClassMethods
end
class ClassMethods
def mobile_api(*args)
opts = args.extract_options!
self.class_eval do
/photos/:id/in/:collection_with_delim
## /photos/123/in/category-landscapes
/photos/:id/in/:collection/:collection_id
## /photos/123/in/category/landscapes
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
Sass.compile(render :template=>'../assets/stylesheets/theme.css.scss').html_safe