$ rails g model User
belongs_to
has_one
| # app/models/ability.rb | |
| # All front end users are authorized using this class | |
| class Ability | |
| include CanCan::Ability | |
| def initialize(user) | |
| user ||= User.new | |
| can :read, :all |
| ############################################################# | |
| ################### OFFICIAL DEBIAN REPOS ################### | |
| ############################################################# | |
| ###### Debian Main Repos | |
| deb http://ftp.us.debian.org/debian/ squeeze main contrib non-free | |
| deb-src http://ftp.us.debian.org/debian/ squeeze main contrib non-free | |
| ###### Debian Update Repos | |
| deb http://security.debian.org/ squeeze/updates main contrib non-free |
| FooBar::Application.config.mine = OpenStruct.new({}) | |
| FooBar::Application.config.mine.omniauth_config = {:facebook => { :app_id => 123 } } | |
| # how do i access the config in my controller | |
| # i can do FooBar::Application.config.mine but that is too verbose |
| # db/migrate/20111218135715_globalize_models.rb | |
| class GlobalizeModels < ActiveRecord::Migration | |
| def up | |
| NewsItem.create_translation_table!( | |
| {:title => :string, :body => :text}, | |
| {:migrate_data => true} | |
| ) | |
| end |
| # Last Change: 2012 Jan 05 10:48:29 | |
| # ~/.bashrc: executed by bash(1) for non-login shells. | |
| # see /usr/share/doc/bash/examples/startup-files (in the package bash-doc) | |
| # for examples | |
| # http://www.caliban.org/bash/ | |
| # Author: Sérgio Luiz Araújo Silva | |
| # Site: http://vivaotux.blogspot.com | |
| # twitter: http://www.twitter.com/voyeg3r | |
| # | |
| # ( O O ) |
| function nestCollection(model, attributeName, nestedCollection) { | |
| //setup nested references | |
| for (var i = 0; i < nestedCollection.length; i++) { | |
| model.attributes[attributeName][i] = nestedCollection.at(i).attributes; | |
| } | |
| //create empty arrays if none | |
| nestedCollection.bind('add', function (initiative) { | |
| if (!model.get(attributeName)) { | |
| model.attributes[attributeName] = []; |
This installs a patched ruby 1.9.3-p327 with various performance improvements and a backported COW-friendly GC, all courtesy of funny-falcon.
You will also need a C Compiler. If you're on Linux, you probably already have one or know how to install one. On OS X, you should install XCode, and brew install autoconf using homebrew.
I've been using this technique in most of my Ruby projects lately where Ruby versions are required:
.rbenv-version containing the target Ruby using a definition name defined in ruby-build (example below). These strings are a proper subset of RVM Ruby string names so far....rvmrc (with rvm --create --rvmrc "1.9.3@myapp") and edit the environment_id= line to fetch the Ruby version from .rbenv-version (example below).Today I learned about another Ruby manager, rbfu, where the author is using a similar technique with .rbfu-version.
REAL WORLD SCENARIO (blinking lights)
Mr. Tom Dev wants to remote pair program with Mr. Todd Programmer. Tom is in New York, Todd is in San Francisco. They’re working on yet another blog written in Ruby. Tom fires up Rubymine, Todd fires up TextMate.
Todd’s editor quickly alerts him that he is connected with Tom and that their projects are out of sync. The plugin gives them each the option of using Tom’s file versions, Todd’s files, or performing a git pull request. They both do a git pull and are back in sync.
Todd quickly opens the User model in Rubymine with cmd-shift-N and Todd quickly sees that same file opened in Textmate. Todd then highlights a method that has been failing a test and Tom sees that highlight. Todd makes the change to the file, clicks cmd-s, and that file change is synced over to Tom.
Tom thought there was a secondary change needed in the Profile model, so he hits cmd-T, opens the Profile model and Todd sees that file opened in Rubymine. Todd tells Tom that he’s smoking catn