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
# How to give your devise controllers all the same layout (e.g. "authentication" below) | |
class ApplicationController < ActionController::Base | |
layout :setup_layout | |
def setup_layout | |
return "authentication" if | |
[ConfirmationsController, PasswordsController, SessionsController, | |
RegistrationsController, UnlocksController].include? self.class | |
"application" | |
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
# Send email to MockSMTP | |
config.action_mailer.delivery_method = :smtp | |
ActionMailer::Base.smtp_settings = { | |
:address => "localhost", | |
:port => 1025, | |
:domain => "localhost" | |
} |
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 active_link?(controller, action = nil) | |
action_match = case | |
when action.nil? | |
true | |
when action.respond_to?(:include?) | |
action.include? params[:action] | |
else | |
action == params[:action] | |
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
# link_to 'Foo', bar_path, :class => active_link?('some_controller', 'some_action') | |
# link_to 'Foo', bar_path, :class => active_link?('some_controller') # Active anywhere within the controller | |
def active_link?(controller, action = nil) | |
action_match = case | |
when action.nil? then true | |
when action.is_a?(Array) then action.include? params[:action] | |
else action == params[:action] | |
end | |
params[:controller] == controller && action_match ? 'active ' : '' |
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
- if Rails.env.development? | |
%link{:rel => 'shortcut icon', :href => "/favicon.ico?#{(100..200).to_a.shuffle[1]}"} |
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
@mixin ie6 { * html & { @content } } | |
#logo { | |
background-image: url("/images/logo.png"); | |
@include ie6 { background-image: url("/images/logo.gif"); } | |
} |
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
@mixin background-image-retina($file, $type, $width, $height) { | |
background-image: url($file + '.' + $type); | |
@media (-webkit-min-device-pixel-ratio: 2), (-moz-min-device-pixel-ratio: 2) { | |
& { | |
background-image: url($file + '@2x.' + $type); | |
-webkit-background-size: $width $height; | |
} | |
} | |
} |
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
@mixin size($width, $height: $width) { | |
width: $width; | |
height: $height; | |
} | |
// Examples | |
#foo { | |
@include size(10px); | |
} |
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
# Written in a taxi on the way to Railscamp X | |
require 'twitter' | |
Twitter.configure do |config| | |
config.consumer_key = | |
config.consumer_secret = | |
config.oauth_token = | |
config.oauth_token_secret = | |
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 search_chosen(selector, search) | |
page.execute_script "jQuery('#{selector}').click();" | |
find('div.chzn-search input').set search | |
end | |
def select_from_chosen(selector, name) | |
page.execute_script "jQuery('#{selector}').click();" | |
page.execute_script "jQuery(\".chzn-results .active-result:contains('#{name}')\").click();" | |
wait_for_ajax | |
end |
OlderNewer