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
# Just a few different methods to strip white-space from all attributes on a model. | |
# method 1 - code from scott moonen | |
# http://scottmoonen.com/2009/05/08/rails-pattern-trim-spaces-on-input/ | |
module Trimmer | |
def self.included base | |
base.extend(ClassMethods) | |
end | |
module ClassMethods |
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
@charset "UTF-8" | |
// This is a manifest file that'll automatically include all the stylesheets available in this directory | |
// and any sub-directories. You're free to add application-wide styles to this file and they'll appear at | |
// the top of the compiled file, but it's generally better to create a new file per style scope. | |
// | |
//= require_self | |
// Then we'll import the compass and html5-boilerplate extensions | |
@import compass/utilities | |
@import html5/boilerplate |
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
source 'http://rubygems.org' | |
gem 'rails', '3.1.1' | |
# Bundle edge Rails instead: | |
# gem 'rails', :git => 'git://github.com/rails/rails.git' | |
gem 'haml' | |
gem 'devise' | |
gem 'json' |
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
stv@home:~/Desktop/refinery$ refinerycms test_123_456 --heroku | |
create | |
create README.rdoc | |
create Rakefile | |
create config.ru | |
create .gitignore | |
create Gemfile | |
create app | |
create app/assets/images/rails.png | |
create app/assets/javascripts/application.js |
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
class SelfMaker | |
def yet_what_is_self? | |
self.class.class_eval do | |
mirror(self, "Inside class_eval of SelfMaker#yet_what_is_self?") | |
end | |
instance_eval do | |
mirror(self, "Inside instance_eval of SelfMaker#yet_what_is_self?") | |
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
protected | |
def stored_location_for(resource) | |
nil | |
end | |
def after_sign_in_path_for(resource) | |
if condition_foo | |
redirect_to foo_url | |
elsif condition bar |
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 we have confirmable module turned on | |
def after_inactive_sign_up_path_for(resource) | |
"http://google.com" | |
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 after_sign_in_path_for(resource_or_scope) | |
if first_login | |
getting_started_path | |
else | |
super | |
end | |
end | |
def first_login | |
current_user.sign_in_count == 0 |
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
Devise by default has a configuration named: | |
config.allow_unconfirmed_access_for | |
You can set it in your devise initializer and it will allow the user to access any page, any time, while still unconfirmed. | |
Then, for the pages you require confirmation, you can simply add a before filter: | |
before_filter :only_confirmed |
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
expect { thing.destroy }.to change(Thing, :count).from(1).to(0) | |
expect { thing.tax = 5 }.to change { thing.total_price }.by(5) | |
expect { thing.save! }.to raise_error | |
expect { thing.symbolize_name }.to change { thing.name }.from(String).to(Symbol) |
OlderNewer