Skip to content

Instantly share code, notes, and snippets.

View krishna-shilpakar's full-sized avatar

krishna shilpakar krishna-shilpakar

View GitHub Profile
@krishna-shilpakar
krishna-shilpakar / gist:724847
Created December 2, 2010 05:59
example_model
class Person
include Mongoid::Document
field :name, :type => String
field :age, :type => Integer
field :address, :type => Hash
end
/***** ADDING THROUGH CONSOLE ******/
@krishna-shilpakar
krishna-shilpakar / inherit_include.rb
Created May 24, 2011 08:05
Model inheritance or include
# Structure for inheritance
# app/models/parent/base.rb
class Parent::Base
include Mongoid::Document
end
# app/models/parent/first_child.rb
class FirstChild < Parent::Base
# fields needed for first child
@krishna-shilpakar
krishna-shilpakar / rails31init.md
Created February 8, 2012 06:10 — forked from jraines/rails31init.md
Rails 3.1 with Rspec, Cucumber, Factory Girl, Haml, and Simple Form

Install Rails 3.1 RC

gem install rails --pre

generate new app, skipping Test::Unit file generation

rails new my_app -T

Set up Gemfile

@krishna-shilpakar
krishna-shilpakar / .gitconfig
Created March 2, 2012 08:18 — forked from millisami/.gitconfig
Global settings for git at ~/.gitconfig
[user]
name = your_username
email = your_email@gmail.com
[github]
user = github_username
token = github_your_own_token
[core]
#Global .gitignore file
excludesfile = /Users/millisami/.gitignore
editor = mate -w
@krishna-shilpakar
krishna-shilpakar / index.md
Created March 21, 2012 05:49 — forked from rstacruz/index.md
Rails models cheatsheet

Rails Models

Generating models

$ rails g model User

Associations

belongs_to

has_one

@krishna-shilpakar
krishna-shilpakar / rails-rspec-capybara.md
Created August 15, 2012 08:36
Rails with rspec, capybara

#Rails with Rspec, Capybara (with selenium driver), FactoryGirl #

Generate new app, skipping Test::Unit file generation and skipping bundle

rails new my_app -T --skip-bundle

Setup Gemfile

@krishna-shilpakar
krishna-shilpakar / sublime-text-2-settings
Created September 25, 2012 10:28 — forked from olivierlacan/sublime-text-2-settings.json
Basic Sublime Text 2 settings for Rails development
{
"use_simple_full_screen": false,
// calculates indentation automatically when pressing enter
"auto_indent": true,
// sets the colors used within the text area (default)
// see https://github.com/olivierlacan/monokaim to download
// the customized Monokai I use.
"color_scheme": "Packages/Color Scheme - Default/Monokaim.tmTheme",
@krishna-shilpakar
krishna-shilpakar / .irbrc
Created November 23, 2012 05:02 — forked from adamcrown/.irbrc
My Bundler proof .irbrc file including wirble, awesome_print, hirb, console logging and route helpers
require 'rubygems' unless defined? Gem # rubygems is only needed in 1.8
def unbundled_require(gem)
loaded = false
if defined?(::Bundler)
Gem.path.each do |gems_path|
gem_path = Dir.glob("#{gems_path}/gems/#{gem}*").last
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