- Beginning Ruby
- Practical Object-Oriented Design in Ruby
- Programming Ruby (aka the pickaxe book)
- The RSpec Book
- Everyday Scripting with Ruby
- Refactoring Ruby
- Design Patterns in Ruby
- Exceptional Ruby
This file contains hidden or 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
| def create | |
| parent_resource = params[:parent_type].constantize | |
| parent_id = params[:parent_id] | |
| # both of the above values are empty because both params are not passed as parameters. | |
| @comment = parent_resource.find(parent_id).comments.create(comment_params.merge(account: current_account)) | |
| respond_with :dashboard, @comment | |
| end | |
This file contains hidden or 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
| UPDATE pg_database SET datallowconn = TRUE where datname = 'template0'; | |
| \c template0 | |
| UPDATE pg_database SET datistemplate = FALSE where datname = 'template1'; | |
| drop database template1; | |
| create database template1 with template = template0 encoding = 'UNICODE' LC_CTYPE = 'en_US.UTF-8' LC_COLLATE = 'C'; | |
| UPDATE pg_database SET datistemplate = TRUE where datname = 'template1'; | |
| \c template1 | |
| UPDATE pg_database SET datallowconn = FALSE where datname = 'template0'; |
This file contains hidden or 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 Api::TradesController < ApplicationController | |
| respond_to :json | |
| def index | |
| render json: DataTable.new(Trade, params) | |
| end | |
| def create | |
| trade = Trade.new(safe_params) | |
| trade.save |
This file contains hidden or 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 HospitalBooking | |
| def self.send_overtime_mail(user, bookings) | |
| OvertimeMailer.overtime_pdf(user, hospital_booking).deliver | |
| end | |
| end |
This file contains hidden or 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 ApplicationController... | |
| def clear_cart | |
| @cart.destroy | |
| session[:cart_id] = nil | |
| end | |
| end |
This file contains hidden or 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' | |
| require 'open-uri' | |
| it 'sends get request to web.memc to invoke the php script create_user_with_hashed_password - then validates the password in rails' do | |
| password = 'testphp' | |
| open_uri_result = '' | |
| expect do | |
| open("http://web.memc/create_user_with_hashed_password.php?password=#{password}").each do |f| | |
| open_uri_result << f | |
| end |
This file contains hidden or 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 AccountsController < ApplicationController | |
| load_and_authorize_resource | |
| # do not need to be logged in for :new or :create | |
| skip_before_filter :authorize_user, only: [:new, :create] | |
| def new | |
| @account.users.build | |
| @account.offices.build | |
| @account.phone_numbers.build |