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
source :rubygems | |
# We are not loading Active Record, nor Active Resources etc. | |
# We can do this in any app by simply replacing the rails gem | |
# by the parts we want to use. | |
gem "actionpack", "~> 3.2" | |
gem "railties", "~> 3.2" | |
gem "tzinfo" | |
# Let's use thin |
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
namespace :discussions do | |
resources :posts, :only => [:show, :create, :update, :destroy] do | |
resources :replies, :only => :create | |
resources :flags, :only => [:create, :destroy] | |
resources :votes, :only => [:create, :destroy] | |
resources :favorites, :only => [:create, :destroy] | |
end | |
end | |
# same result on flags, votes, favorites, or replies |
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 install memcache | |
Building native extensions. This could take a while... | |
ERROR: Error installing memcache: | |
ERROR: Failed to build gem native extension. | |
/Users/bushymark/.rvm/rubies/ruby-1.9.2-p0/bin/ruby extconf.rb | |
Building libmemcached. | |
tar xzf libmemcached-0.38.tar.gz 2>&1 | |
env CFLAGS='-fPIC' ./configure --prefix=/Users/bushymark/.rvm/gems/ruby-1.9.2-p0@rails3/gems/memcache-1.2.13/ext --without-memcached --disable-shared --disable-utils --disable-dependency-tracking 2>&1 | |
checking build system type... x86_64-apple-darwin10.4.0 |
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
# Everything you need to do to get started with Rails 2.3.8 | |
# | |
# As of June 14th, 2010 @ 2:30 p.m. MST | |
# | |
# This gist now features instructions to get Rails 3 up and running with: | |
# - Ruby 1.8.7-p174 | |
# - Bundler 0.9.26 | |
# - Cucumber 0.8.0 | |
# - Rspec 1.3.0 + Rspec-Rails 1.3.2 | |
# - RVM |
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
##### I need to be able to eager load the notes element on the lesson element. Figured the best way to do it was through an | |
##### association. | |
############## | |
# doesn't work . . . conditions on associations don't take lambda's | |
class Note < ActiveRecord::Base | |
belongs_to :notable, :polymorphic => true | |
end | |
class Lesson < ActiveRecord::Base |
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
stupid ruby tricks | |
Posted by Nick Quaranto | |
# Over the past few months of slinging Ruby here at Thoughtbot, I’ve picked up quite a | |
# few stupid ruby tricks smart ruby techniques that really help out your code. | |
# If you’ve got your own, feel free to leave a comment. | |
# Destructuring yielded arrays | |
def touch_down |
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
# Original Post: http://pastie.textmate.org/143799 | |
# Author Karmen Blake | |
#RUBYISMS | |
a = b.foo | |
if a.empty? | |
a = b.bar | |
else | |
a.reverse! |