Skip to content

Instantly share code, notes, and snippets.

View denysonique's full-sized avatar

Dennis Prochniak denysonique

View GitHub Profile
@denysonique
denysonique / my_model.rb
Created July 1, 2011 17:08
Is there a cleaner/simpler way of doing this?
class MyModel < ActiveRecord::Base
attr_accessor :foo_bar
def foo_bar
@foo_bar || []
end
end
@denysonique
denysonique / my_model.rb
Created July 1, 2011 17:14 — forked from mnaser/my_model.rb
Is there a cleaner/simpler way of doing this?
class MyModel < ActiveRecord::Base
after_initialize :setup_defaults
attr_accessor :foo_bar
def setup_defaults
@foo_bar ||= "my default value"
end
end
root :to => 'user#home', :constraints => lambda {|r|
r.env['warden'].user.class.name == 'User'
}
root :to => 'organizer#home', :constraints => lambda {|r|
r.env['warden'].user.class.name == 'Organizer'
}
Class Book < ActiveRecord::Base
def self.by_authors(author_ids)
where(:author_id => author_ids).map{ |book|
issuer = book.issuer
issuer.foo = boo.foo
}
end
end
#instead of
def foo
end
def foo.bar
'foobar'
end
/*
* This is a manifest file that'll automatically include all the stylesheets available in this directory
* and any sub-directories. You're free to add application-wide styles to this file and they'll appear at
* the top of the compiled file, but it's generally better to create a new file per style scope.
*= require_self
*= require_tree .
*= require layout
*/
@denysonique
denysonique / gist:1099325
Created July 22, 2011 12:10 — forked from nickws/gist:1099324
database.yml
development:
adapter: postgresql
database: emotio-dev
pool: 5
timeout: 5000
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
require 'spec_helper'
describe ProfileController do
include Devise::TestHelpers
before(:each) do
@user = Factory.create(:user)
sign_in @user
end
filename=$(basename $0)
APP=${filename#thin-}
CONFIG="/etc/thin/$APP.yml"
ARGS="--daemonize --config=/etc/thin/$APP.yml"
RVM_ENV="ruby-1.8.7-p352@redmine"
source "/usr/local/rvm/environments/$RVM_ENV"
COMMAND="sudo -Eu $APP $(which thin)"
case "$1" in
start)
require 'spec_helper'
describe 'Signed in' do
before(:each) do
user = Factory(:user)
visit new_user_session_path
fill_in 'Email', with: user.email
fill_in 'Password', with: user.password
click_button 'Sign in'