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 Mailing | |
singleton_class.class_eval do | |
attr_accessor :engine | |
delegate :add, :clear, :each, :deliver, :to => :engine | |
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
ruby-1.9.2-p290-fastrequire :017 > o.inspect | |
=> "#<Object:0x9b517fc>" | |
ruby-1.9.2-p290-fastrequire :018 > (o.object_id*2).to_s(16) | |
=> "9b517fc" |
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 SkipAutoloadingAllHelpersController < ActionController::Base | |
# Fuck you, rails! | |
def self.helper(*params) | |
if params.include?(:all) | |
Rails.logger.warn("Rejected :all") | |
params.reject!{|p| p == :all} | |
end | |
super | |
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 PapersController < ApplicationController | |
def create | |
@paper = Paper.new(params[:paper]) | |
if @paper.save | |
redirect_to @paper, notice: "Talk proposal submitted" # notice: I18n.t(:paper_created_flash_message) | |
else | |
flash[:alert] = "An error occurred while submitting a proposal" | |
render action: :new |
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 PapersController < ApplicationController | |
def create | |
@paper = Paper.new(params[:paper]) | |
if @paper.save | |
redirect_to @paper, notice: :created | |
else | |
flash[:alert] = :invalid | |
render action: :new |
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
<%= form_for(@user) do |f| %> | |
<fieldset> | |
<div class="clearfix <%= @user.errors[:login].present? ? :error : nil %>"> | |
<%= f.label :login %><br /> | |
<div class="input"> | |
<span class="help-block"> | |
Your login. You know... login. | |
</span> |
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
<% @user.errors[:login].each do |err| %> | |
<span class="help-block"> | |
<p><%= error_message(err) %></p> | |
</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 | |
validate :login_length | |
private | |
def login_length | |
return if login.size >= 2 && login.size <= 10 | |
errors.add(:login, { | |
code: :INVALID_LENGTH, |
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 InvalidLengthError | |
attr_accessor :min, :max, :current | |
private :min=, :max=, :current= | |
CODE = "INVALID_LENGTH" | |
DESCRIPTION = "Invalid length" | |
def initialize(min, max, current) | |
self.min = min | |
self.max = max |
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 InvalidLengthError | |
attr_accessor :min, :max, :current | |
private :min=, :max=, :current= | |
CODE = "INVALID_LENGTH" | |
DESCRIPTION = "Invalid length" | |
def initialize(min, max, current) | |
self.min = min | |
self.max = max |