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 CreateSearches < ActiveRecord::Migration | |
def self.up | |
ActiveRecord::Base.connection.execute <<-SQL | |
CREATE VIEW searches AS | |
SELECT authors.id AS searchable_id, authors.name AS term, | |
CAST ('Author' AS varchar) AS searchable_type | |
FROM authors | |
UNION | |
SELECT books.id AS searchable_id, books.title AS term, | |
CAST ('Book' AS varchar) AS searchable_type |
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 Search < ActiveRecord::Base | |
# We want to reference various models | |
belongs_to :searchable, :polymorphic => true | |
# Wish we could eliminate n + 1 query problems, | |
# but we can't include polymorphic models when | |
# using scopes to search in Rails 3 | |
# default_scope :include => :searchable | |
# Search.new('query') to search for 'query' |
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 'texticle/searchable' | |
class Book | |
# :title, String | |
# :author, String | |
extend Searchable(:title) | |
end | |
Book.create :title => "Poignant Guide to Ruby", :author => "_why" |
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 Address | |
# :street, String | |
# :city, String | |
# :state, String | |
# :country, String | |
scope :local, lambda { |query| search_by_street_or_city(query, query) } | |
scope :national, lambda {|query| search_by_state_or_country(query, query) } | |
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
class Person | |
attr_accessor :pocket | |
end | |
class Artist < Person | |
def draw_like_an_artist | |
"Look, I painted a landscape." | |
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
Magick::Image.read(Image.with_file.find_by_import_file("DSC00014.JPG").file_url(:small_thumb))[0].get_exif_by_entry('GPSLongitude')[0][1] | |
Magick::Image.read(Image.with_file.find_by_import_file("DSC00014.JPG").file_url(:small_thumb))[0].get_exif_by_entry('Model') | |
pp Magick::Image.read(Image.with_file.find_by_import_file("DSC00014.JPG").file_url(:small_thumb))[0].get_exif_by_entry | |
@total_file_images = Image.with_file | |
@total_file_images_count = @total_file_images.count | |
@loop_counter = 0 | |
puts @total_file_images.collect do |i| |
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
alias rf='rake features' | |
# For running specific features. | |
function rff { | |
rake features FEATURE=features/"$1".feature | |
} | |
# For running specific line numbers | |
function rffl { | |
cucumber features/"$1".feature:"$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
gem 'rails', '3.0.9' | |
# Bundle edge Rails instead: | |
# gem 'rails', :git => 'git://github.com/rails/rails.git' | |
gem 'devise' | |
gem 'omniauth' | |
gem 'jquery-rails' | |
gem "less" |
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
# Based on | |
# https://github.com/ng/paperclip-watermarking-app/blob/master/lib/paperclip_processors/watermark.rb | |
# Modified by Laurynas Butkus | |
module Paperclip | |
class Watermark < Processor | |
# Handles watermarking of images that are uploaded. | |
attr_accessor :format, :whiny, :watermark_path, :position | |
def initialize file, options = {}, attachment = nil |
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
# usage (in app dir): | |
# rake rails:template LOCATION=http://gist.github.com/406257.txt | |
gem "database_cleaner" | |
group :test do | |
gem "launchy" # So you can do Then show me the page | |
# gem "capybara" # alternative to webrat | |
gem "spork" | |
gem "cucumber-rails" | |
gem "cucumber", "0.7.2" |