This file contains hidden or 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 Ticket::GrouperValidator < ActiveModel::Validator | |
| def validate(record) | |
| record.errors.add :grouper, 'has already occurred!' if record.grouper.full? | |
| record.errors.add :grouper, 'has already occurred!' if record.grouper.past? | |
| end | |
| end |
This file contains hidden or 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 User < ActiveRecord::Base | |
| include Redis::Objects | |
| counter :reminders_to_send | |
| def purge | |
| @@redis_objects = {} | |
| end | |
| end |
This file contains hidden or 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 Foo | |
| has_many :tags | |
| has_many :states | |
| # q is hash: { "tags" => "ruby", "states" => "open" } | |
| def self.search(q) | |
| # wat do? | |
| end | |
| end |
This file contains hidden or 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 ApplicationController < ActionController::Base | |
| protect_from_forgery | |
| prepend_before_filter :authenticate! | |
| before_filter :restrict_routes! | |
| cattr_accessor :skipping_authentication | |
| rescue_from Exits::Unauthorized do |exception| | |
| flash.alert = t("restrictions.unauthorized") |
This file contains hidden or 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 negotiate(handshake) | |
| config = Rails.application.config | |
| key_generator = Rails.application.key_generator | |
| secret_token = config.secret_token | |
| secret_key_base = config.secret_key_base | |
| host = handshake.headers['Host'] | |
| cookies = Rack::Utils.parse_query(handshake.headers['Cookie'], ';,') { |s| Rack::Utils.unescape(s) rescue s } | |
| cookies.map { |k,v| Array === v ? v.first : v } | |
| options = { |
This file contains hidden or 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
| module Ouan | |
| def self.object | |
| @test = '1234' | |
| end | |
| end | |
| Ouan.object | |
| #-> 1234 | |
| Ouan.instance_variable_get('@test') |
This file contains hidden or 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 SomeController < ApplicationController | |
| def create | |
| @record = Record.new params[:record] | |
| respond_to do |format| | |
| format.js do | |
| if @record.save | |
| render "create" | |
| else |
This file contains hidden or 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
| Pathname.new(__FILE__) + "../what/ever/file.rb" | |
| # VS | |
| File.expand_path("../what/ever/file.rb", __FILE__) |
This file contains hidden or 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 SimpleDelegator | |
| attr_reader :object | |
| def initialize(obj) | |
| @object = obj | |
| end | |
| def method_missings(method, *args) | |
| if obj.responds_to? method | |
| obj.send(method, *args) |
This file contains hidden or 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
| "active_support/descendants_tracker" | |
| "active_support/file_update_checker" | |
| "active_support/log_subscriber" | |
| "active_support/notifications" | |
| "active_support/backtrace_cleaner" | |
| "active_support/base64" | |
| "active_support/basic_object" | |
| "active_support/benchmarkable" | |
| "active_support/buffered_logger" | |
| "active_support/cache" |