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
client_max_body_size 30M; | |
proxy_send_timeout 600; | |
proxy_read_timeout 1h; | |
send_timeout 600; | |
upstream backend { | |
server unix:///var/run/puma/my_app.sock ; | |
} | |
server { |
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
# Controller /app/controllers/posts_controller.rb | |
def index | |
@posts = Post.all | |
end | |
# Spec /spec/controllers/posts_controller_spec.rb | |
describe "GET #index" do | |
it "responds successfully with a HTTP 200 status code" do | |
get :index | |
expect(response).to be_success |
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
class MyLittleProgram | |
def execute | |
h = { h1: 'value1', h2: 'value2', h3: 'value3', h4: 'value4' } | |
a = [ '1', '2', '3', '4' ] | |
h.each_with_index do |(k, v), i| | |
break if a.size > h.keys.size | |
a.each_with_index { |val, index| | |
if i == index |
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
class ActsController < ActionController::Base | |
before_filter :get_user | |
def new | |
@act = @user.acts.new | |
end | |
def create | |
@act = @user.acts.new params[:act] |
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
require 'spec_helper' | |
class User | |
def initialize(args = {}); end | |
def email | |
'[email protected]' | |
end | |
def mobile |
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
require 'rubygems' | |
require 'viewpoint' # Library for MS Outlook | |
require 'viewpoint/logging/config' # For Debugging | |
include Viewpoint::EWS | |
endpoint = 'YOUR MS EXACHANGE URL COMES HERE' # E.g. https://OUTLOOKSERVER_URL/ews/exchange.asmx | |
user = 'USERNAME' | |
pass = 'PASSWORD' | |
cli = Viewpoint::EWSClient.new endpoint, user, pass |
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
# app/models | |
class User < ActiveRecord::Base | |
has_many :responses, dependent: :destroy | |
end | |
class Response < ActiveRecord::Base | |
has_one :report | |
has_many :points | |
belongs_to :user | |
end |
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
class Product < ActiveRecord::Base | |
has_many :suppliers, conditions: ["suppliers.status = ?", true] | |
end | |
# In Rails4, if you wish to use the same, you can use the below syntax: | |
class Product < ActiveRecord::Base | |
has_many :suppliers, -> { where("suppliers.status = ?", true) } | |
end |
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
#{PATH_TO_APP}$ rails g model Person name:string email:string | |
#{PATH_TO_APP}$ rails g model Community name:string description:text | |
class Person < ActiveRecord::Base | |
has_and_belongs_to_many :communities | |
end | |
class Community < ActiveRecord::Base | |
has_and_belongs_to_many :persons | |
end |
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
begin | |
# Code to be executed here | |
# This part will be 'protected' | |
raise # Use this to raise any message | |
rescue | |
# Exception Handling, like argument error, 404 | |
retry # use this if you want the begin block to be executed again, if execption occurs. | |
ensure | |
# This part will always get executed. | |
end |
NewerOlder