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
ActionController::Routing::Routes.draw do |map| | |
# twitter app stuff | |
map.connect '/accounts/callback', :controller => 'accounts', :action => 'callback' | |
map.resources :accounts, :collection => { :callback => :get}, :members => {:do_update => :post} | |
map.resources :feeds | |
map.resources :feed_entries | |
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
This example shows how to setup an environment running Rails 3 beta under 1.9.1 with a 'rails3' gem set. | |
∴ rvm update --head | |
# ((Open a new shell)) | |
# If you do not already have the ruby interpreter installed, install it: | |
∴ rvm install 1.9.1 | |
# Use the ruby + gem set | |
∴ rvm 1.9.1%rails3 |
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 Admin < Person | |
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
it "should call the callback :before_add" do | |
@callback = lambda {true} | |
@record.class.has_and_belongs_to_many_active_resource :resourcen, :before_add => @callback | |
@record.resource_ids = [1] | |
@callback.should_receive(:call) | |
@record.add_resource(5) | |
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
require 'spec_helper' | |
describe Post do | |
context "A post (in general)" do | |
subject {Post.new} | |
it {should validate_presence_of :title} | |
it {should validate_presence_of :body} | |
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
Event.should_receive(:only).with(:street, :location, :postal_code, :place_name).and_return(criteria_mock = mock("Criteria")) | |
criteria_mock.should_receive(:limit).with(100).and_return(criteria_mock) |
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 'uri' | |
... | |
def image? | |
['.jpg', '.jpeg'].include?(file_type) | |
end | |
def file_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
# dir is an array of dir entries, eg: ['ar', 'fe', '4a', 'c9'] | |
def delete_empty_dirs(dir) | |
begin | |
Dir.rmdir File.join(self.base_storage_path, dir.join('/')) | |
dir.pop | |
delete_empty_dirs(dir) unless dir.empty? | |
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
#controller | |
def add_new_chapter | |
@chapter=Chapter.new | |
@user=current_user | |
@subjects=[] | |
@subject_final=[[]] | |
count=0 | |
if @user.admin? | |
@subjects=Subject.all(:select=>'id,name,batch_id') | |
puts "#{@subjects}" |
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 'spec_helper' | |
describe RegistrationsController do | |
include Devise::TestHelpers | |
let :user do | |
mock_model(User) | |
end | |
before (:each) do |
OlderNewer