Skip to content

Instantly share code, notes, and snippets.

View i-arindam's full-sized avatar

Arindam Chakraborty i-arindam

  • Bangalore, India
  • 17:53 (UTC +05:30)
View GitHub Profile
class User < ApplicationRecord
has_many :posts
has_many :comments
# id :integer not null, primary key
# name :string(50) default("")
end
@i-arindam
i-arindam / rspec_rails_cheetsheet.rb
Created May 29, 2017 05:51 — forked from them0nk/rspec_rails_cheetsheet.rb
Rspec Rails cheatsheet (include capybara matchers)
#Model
@user.should have(1).error_on(:username) # Checks whether there is an error in username
@user.errors[:username].should include("can't be blank") # check for the error message
#Rendering
response.should render_template(:index)
#Redirecting
response.should redirect_to(movies_path)
@i-arindam
i-arindam / Rails and ruby.md
Last active August 9, 2016 14:44 — forked from ryansobol/gist:5252653
Interview Questions
  1. to_param
  [ 1, 'String', true, String].to_param

"1/String/true/String"

  1. with_options
  class ModelName < AR::Base
    has_many :model1, dependent: :destroy