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
# http://www.tsheffler.com/blog/?p=428 | |
before_filter :cors_preflight_check | |
after_filter :cors_set_access_control_headers | |
# For all responses in this controller, return the CORS access control headers. | |
def cors_set_access_control_headers | |
headers['Access-Control-Allow-Origin'] = '*' | |
headers['Access-Control-Allow-Methods'] = 'POST, GET, OPTIONS' |
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
%meta{:content => "yes", :name => "apple-mobile-web-app-capable"}/ | |
%meta{:content => "black", :name => "apple-mobile-web-app-status-bar-style"}/ | |
%meta{:content => "minimum-scale = 1.0, maximum-scale = 1.0, initial-scale = 1.0, user-scalable = no", :name => "viewport"}/ | |
%meta{:name => "format-detection", :content => "telephone=no"} | |
%link{:rel => "apple-touch-icon-precomposed", :href => "/assets/apple-touch-icon-precomposed.png"}/ | |
%link{:rel => "apple-touch-icon-precomposed", :href => "/assets/apple-touch-icon-precomposed-57x57.png", :sizes => "57x57"}/ | |
%link{:rel => "apple-touch-icon-precomposed", :href => "/assets/apple-touch-icon-precomposed-72x72.png", :sizes => "72x72"}/ | |
%link{:rel => "apple-touch-icon-precomposed", :href => "/assets/apple-touch-icon-precomposed-114x114.png", :sizes => "114x114"}/ | |
%link{:rel => "apple-touch-icon-precomposed", :href => "/assets/apple-touch-icon-precomposed-144x144.png", :sizes => "144x144"}/ |
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
switch (window.orientation) | |
{ | |
case 0: // Portrait | |
break; | |
case 90: ; // Landscape | |
break; | |
case -90: ; // Landscape counterclockwise | |
break; | |
} |
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
# enable with: | |
# | |
# - content_for :head do | |
# :javascript | |
# window.enable_home_bookmark = true | |
$ -> | |
if window.enable_home_bookmark && (("undefined" != typeof window.navigator.standalone) && !window.navigator.standalone) && navigator.userAgent.match(/iPad/i) != null | |
$('<div id="home_bookmark" style="position:fixed; top: 60px; left: 155px;" ></div>').appendTo('body').popover( | |
placement: 'bottom' |
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
# http://stackoverflow.com/a/9460051/148270 | |
describe SomeController do | |
render_views | |
describe "GET 'index'" do | |
before(:each) do | |
@@response ||= begin | |
get 'index' | |
response | |
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
# app/controller/articles_controller.rb | |
around_filter { |controller, action| controller.send(:add_published_scope, Article){ action.call } } | |
# app/controller/application_controller.rb | |
def add_published_scope(klass = nil, &block) | |
unless klass | |
klass = controller_name.classify.constantize | |
end | |
klass.with_scope(:find => klass.where("published_at <= ?", Time.zone.now)) do | |
yield |
NewerOlder