Letter | Output | Example |
---|---|---|
%A | full day of week | |
%a | abbrev day of week | |
%B | full month name | |
%b | abbrev month name | |
%C | century (first two digits of year) | |
%c | Day, month, time. year | Thu Mar 17 11:20:10 2011 |
%D | western format with slashes | mm/dd/yy |
%d | day of month (zero-padded) | 02 |
%e | day of month (space-padded) | _2 |
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
# A goofy bit of code that takes your shoulda-style macro validations and generates a model class from it | |
require 'rspec' | |
require 'active_model' | |
module ActiveRecordTranslator | |
def it_should_validate_presence_of(field) | |
klass = Class.new do | |
include ActiveModel::Validations |
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
require 'spec_helper' | |
describe "HistoryItems" do | |
before(:each) {login_as :user} | |
describe "GET /history_items" do | |
it "works!" do | |
visit history_items_path | |
response.should be_success | |
end | |
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
# A sample Gemfile | |
source "http://rubygems.org" | |
gem "redis" | |
gem 'eventmachine', :git => 'git://github.com/eventmachine/eventmachine.git' | |
gem "em-hiredis" | |
# gem "em-synchrony" | |
gem "em-websocket" |
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
#here is app.rb: | |
get '/admin' do | |
protected! | |
@posters = Poster.all | |
@category_1_posters = @posters.all :category => 1 | |
@category_2_posters = @posters.all :category => 2 | |
@category_3_posters = @posters.all :category => 3 | |
haml :'admin/index' | |
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
Warden::Manager.serialize_into_session{|user| user.id } | |
Warden::Manager.serialize_from_session{|id| User.get(id) } | |
Warden::Manager.before_failure do |env,opts| | |
# Sinatra is very sensitive to the request method | |
# since authentication could fail on any type of method, we need | |
# to set it for the failure app so it is routed to the correct block | |
env['REQUEST_METHOD'] = "POST" | |
end | |