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
# app/controllers/pets_controller.rb | |
class PetsController < ApplicationController | |
before_action :set_pet, only: [:show, :edit, :update, :destroy] | |
def index | |
# old way | |
# @pet_presenters = Pet.all.map { |pet| PetPresenter.new(pet, view_context) } | |
# new way | |
@pet_presenters = PetsPresenter.prepare(Pet.all, view_context) |
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 'rspec' | |
class Menu | |
def item val, &block | |
p val | |
yield if block_given? | |
end | |
def test_it |
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 Company < ActiveRecord::Base | |
has_many :contacts | |
class Contact < ActiveRecord::Base | |
belongs_to :company |
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
new.html.haml | |
%h1 New vendor | |
= render 'form' | |
= link_to 'Cancel', vendors_path, id: :cancel_new_vendor_link | |
--------------------- | |
_form.html.haml |
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
<b>Priority:</b> | |
<%= @ticket.priority.name %> |
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
<b>Priority:</b> | |
<%= @ticket.priority.try(:name) %> |
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
create_table :priorities do |t| | |
t.string :name | |
t.boolean :default | |
t.boolean :archived | |
t.integer :position | |
t.timestamps | |
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
<select name="ticket[priority_id]"> | |
<option value="low">Low</option> | |
<option value="medium">Medium</option> | |
<option value="high">High</option> | |
</select> |
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 self.report | |
from_date = '20130401' | |
entities = Entity.unscoped.where('updated_at > ?', from_date).where('type in (?)', ['Contact', 'Deceased', 'Child']).where(culture_id: [Selection.culture_australian_aboriginal.id, Selection.culture_australian.id]).order(:site_id, :type) | |
p entities.length | |
media_items = MediaItem.unscoped.where('updated_at > ?', from_date) | |
p media_items.length | |
entities = Entity.unscoped.where('updated_at > ?', from_date).where('type in (?)', ['Contact', 'Deceased', 'Child']).where(referral_source_id: [Selection.referral_source_internet.id, Selection.referral_source_information_session.id]).order(:site_id, :type) | |
p entities.length | |
entities = Entity.unscoped.where('updated_at > ?', from_date).where('type in (?)', ['Contact', 'Deceased', 'Child']).where(relation_id: [Selection.relation_friend.id, Selection.relation_support_1.id]).order(:site_id, :type) |
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" | |
describe ApplicationController do | |
controller do | |
def index | |
render nothing: true | |
end | |
end | |
let(:user) { create(:user_agent) } |
NewerOlder