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 Image < ActiveRecord::Base | |
before_create, :set_width_and_height | |
has_attached_file :img, | |
:url => "/system/images/:attachment/:id/:basename.:extension", | |
:path => "#{Rails.root}/public/system/images/:attachment/:id/:basename.:extension" | |
def set_width_and_height | |
# this next line is the magic line | |
geo = Paperclip::Geometry.from_file(img.to_file(:original)) |
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
#!/bin/sh -e | |
# | |
# Usage: browser | |
# pipe html to a browser | |
# e.g. | |
# $ echo '<h1>hi mom!</h1>' | browser | |
# $ ron -5 man/rip.5.ron | browser | |
if [ -t 0 ]; then | |
if [ -n "$1" ]; then |
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
# Filename: RAILS_ROOT/lib/paperclip_processors/thumbnail_with_dimensions.rb | |
# Required Configuration in the model | |
# has_attached_file :image, | |
# :styles => { | |
# :thumbnail => { | |
# :geometry => "100x100>", | |
# :format => :png, | |
# :processors => [:thumbnail_with_dimensions], | |
# :mystyle => :thumbnail | |
# }, |
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
gem 'cramp' | |
gem 'erubis', '2.6.5' | |
gem 'usher', "0.6.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
Rails.configuration.middleware.use Rack::OpenID | |
Rails.configuration.middleware.use RailsWarden::Manager do |manager| | |
manager.default_strategies :remember_me_token, :password_form, :api_token, :openid | |
manager.failure_app = ExceptionsController | |
end | |
# Setup Session Serialization | |
class Warden::SessionSerializer | |
def serialize(record) |
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
=Navigating= | |
visit('/projects') | |
visit(post_comments_path(post)) | |
=Clicking links and buttons= | |
click_link('id-of-link') | |
click_link('Link Text') | |
click_button('Save') | |
click('Link Text') # Click either a link or a button | |
click('Button Value') |
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
Package: require('node-asset').Package | |
# Coffee files | |
coffee_package: new Package 'where/you/want/output.js', [ | |
'where/is/coffee/dir' | |
'or/file.coffee' | |
'coffee/type/also/support/file.js' | |
], { | |
type: 'coffee' | |
# Watch for changes |
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 'action_dispatch' | |
require 'capybara/rails' | |
require 'capybara/dsl' | |
module RSpec::Rails | |
module IntegrationExampleGroup | |
extend ActiveSupport::Concern | |
include ActionDispatch::Integration::Runner | |
include RSpec::Rails::TestUnitAssertionAdapter |
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
# Cleaning up and extending the Gemfile | |
remove_file 'Gemfile' | |
create_file 'Gemfile', <<-GEMFILE | |
source 'http://rubygems.org' | |
gem 'rails', '3.2.8' | |
# Bundle edge Rails instead: | |
# gem 'rails', :git => 'git://github.com/rails/rails.git' |
OlderNewer