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
ruby-1.8.7-p248 > module Foo | |
ruby-1.8.7-p248 ?> def self.included(base) | |
ruby-1.8.7-p248 ?> def base.do_foo | |
ruby-1.8.7-p248 ?> define_method :write do | |
ruby-1.8.7-p248 > puts "1" | |
ruby-1.8.7-p248 ?> end | |
ruby-1.8.7-p248 ?> end | |
ruby-1.8.7-p248 ?> end | |
ruby-1.8.7-p248 ?> end | |
=> 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
ruby-1.8.7-p248 > module Foo | |
ruby-1.8.7-p248 ?> def self.included(base) | |
ruby-1.8.7-p248 ?> def base.do_foo | |
ruby-1.8.7-p248 ?> Foo.send :define_method, :write do | |
ruby-1.8.7-p248 > puts "1" | |
ruby-1.8.7-p248 ?> end | |
ruby-1.8.7-p248 ?> end | |
ruby-1.8.7-p248 ?> end | |
ruby-1.8.7-p248 ?> end | |
=> 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
class SubmissionsController < ActionController::Base | |
scaffold :submission | |
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
Finally, if the customization at the views level is not enough, you can customize each controller by following these steps: | |
1) Create your custom controller, for example a Admins::SessionsController: | |
class Admins::SessionsController < Devise::SessionsController | |
end | |
2) Tell the router to use this controller: | |
devise_for :admins, :controllers => { :sessions = "admin/sessions" } |
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 A | |
class << self | |
private :new | |
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
class String | |
def xml_to_yaml | |
Hash.from_xml(self).to_yaml | |
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 = {:one => {:two => {:three => {:four => "Hello world"}}}} | |
b = [:one, :two, :three, :four] | |
b.inject(a) {|h, i| h[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
Foo.stub(:new).and_return(@foo = mock(Foo)) | |
@foo.stub!(:bar).and_return("omg!") |
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 Status < ActiveRecord::Base | |
ALARM = Status.find_by_name('alarm') | |
NO_ALARM = Status.find_by_name('no_alarm') | |
... | |
end | |
Status::ALARM | |
=> <Status:... name="alarm"> |
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
map.namespace :aegis do |aegis| | |
aegis.resources :user_sessions | |
end |