text stringlengths 10 2.61M |
|---|
require 'plane'
describe Plane do
context 'when created' do
it { is_expected.not_to be_flying }
it 'can land' do
expect(subject).to respond_to :land_to
end
it 'can take off' do
expect(subject).to respond_to :take_off_from
end
end
context 'after take off' do
it 'is expected t... |
namespace :qameha do
desc 'recreate instances for review forms and review questions for the given campaign'
task :hologram_step_1, [:campaign_id] => [:environment] do |t, campaign|
campaign = Campaign.find(campaign.campaign_id)
account = campaign.account
STDERR.puts "campaign id : " + campa... |
class Post < ActiveRecord::Base
mount_uploader :image, ImageUploader
validates :name, presence: true, length: { maximum: 50 }
validates :comment , presence: true, length: { maximum: 150 }
validates :image, presence: true
end
|
require 'minihelper'
class Dummy
extend Minihelper
end
RSpec.describe Minihelper do
it 'has a version number' do
expect(Minihelper::VERSION).not_to be nil
end
describe '.parse_money_to_float' do
# nil string
context 'invalid values' do
it 'should return -1 if nil' do
result = Dummy.... |
class CreateJoinTableCollateralsAttributeOptions < ActiveRecord::Migration[5.2]
def change
create_join_table :collaterals, :attribute_options do |t|
t.index [:collateral_id, :attribute_option_id], unique: true, name: 'idx_collateral_id_on_attribute_option_id'
t.index [:attribute_option_id, :collateral... |
module Hipmost
module Cmds
class Users
def initialize(path:, verbose: false)
$path = Pathname.new(path).expand_path
@verbose = verbose
end
def run(args)
@outpath = $path.join("..", "Users.jsonl").expand_path
save
true
end
def save
... |
class Response < ActiveRecord::Base
belongs_to :question
has_many :user_responses
has_many :users, through: :user_responses
end
|
# coding: utf-8
class ApplicationController < ActionController::Base
require 'yaml'
include VipUser::VipClient
include VipToken::VipClientToken
include Mpki::MpkiClient
protect_from_forgery
def redirect_back_or_default(default)
redirect_to(session[:return_to] || default)
session[:return_to] = nil
... |
class AddLanguageTimzoneToOrganization < ActiveRecord::Migration
def change
add_column :organizations,:language,:string,:default=>"en"
add_column :organizations,:time_zone,:string,:default=>""
end
end
|
module Admins
module Campaigns
class RemoveUsers < Operation
def process
if params[:user_ids].present?
campaign.users.delete(*params[:user_ids])
end
result.new(campaign, campaign.users)
end
private
def campaign
@campaign ||= Campaign.find(params[:... |
# frozen_string_literal: true
require 'spec_helper'
describe Darlingtonia do
describe '#config' do
it 'can set a default error stream' do
expect { described_class.config { |c| c.default_error_stream = STDOUT } }
.to change { described_class.config.default_error_stream }
.to(STDOUT)
end... |
class RemovePosterImageFromMovies < ActiveRecord::Migration
def change
remove_column :movies, :poster_image
end
end
|
class Comment < ApplicationRecord
belongs_to :post
belongs_to :user
validates_presence_of :comment
validates_presence_of :user_id
validates_presence_of :post_id
end
|
=begin
#Scubawhere API Documentation
#This is the documentation for scubawhere's RMS API. This API is only to be used by authorized parties with valid auth tokens. [Learn about scubawhere](http://www.scubawhere.com) to become an authorized consumer of our API
OpenAPI spec version: 1.0.0
Contact: bryan@scubawhere.co... |
module NotificationSystem
module UserExtension
def self.included(base)
base.class_eval do
has_many :notification_type_subscriptions,
:class_name => 'NotificationSystem::NotificationTypeSubscription',
:foreign_key => 'subscriber_id'
after_update... |
class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
def current_user
@current_user ||= User.find(session[:user_id]) if session[:user_id]
rescue ActiveRecord::Recor... |
require 'pp'
include Math
require_relative('json_parser.rb')
class SplitTestCalc
attr_accessor :path, :cohort_a_total, :cohort_b_total, :cohort_a_converts, :cohort_b_converts, :total_sample_size
def initialize(path)
@path = path
@total_sample_size = 0
@chi_cutoff = 3.84
@cohort_a_total = 0.0
... |
class PagesController < ApplicationController
# As the pages are all loaded for the navigation already, we don't have to load it on index again
load_and_authorize_resource except: :index
provide_optimistic_locking_for :page
provide_image_pasting_for :page
before_action :add_breadcrumbs
before_action :provid... |
class Api::V1::ApiController < ApplicationController
before_action :authenticate_user!, except: [:me]
before_action :doorkeeper_authorize!
respond_to :json
# GET /me.json
def me
@user = current_resource_owner
end
private
# Find the user that owns the access token
def current_resource_owner
... |
class BookingsController < ApplicationController
#new/create for adding a DJ to a time slot
#it should create a DJ in the system
#destroy for removing a DJ from a time slot
#eventually will populate bookings via the time slot model
#need to find club night from the time slot and 404 if the user doesn't belong... |
task :default => :'app:run'
# These tasks control the Sinatra application
namespace :app do
desc "Run the client Sinatra app. Assumes rackup is in your path"
task :run => :migrations do
sh "rackup client.ru"
end
desc "Run the applications migrations file"
task :migrations do
sh "maglev-ruby -Ilib mi... |
class Restaurant < ApplicationRecord
has_many :reservations
belongs_to :b_user
end
|
class AddAdminToUsers < ActiveRecord::Migration
def self.up
add_column :users, :admin, :boolean, :default => false
end
def change
add_column :users, :admin, :boolean, :default => false
end
def self.down
remove_column :users, :admin
end
end
# if current_user.admin?
# if no curr user , then do... |
class UserSerializer < ActiveModel::Serializer
attributes :id, :first_name, :last_name, :email, :dob, :contact_no, :role, :gender, :confirmation_code, :email_verified, :avatar, :user_quizes, :number_verified, :all_quizes, :is_activated, :doctor_type, :created_at
def email_verified
object.confirmed_at.present? ... |
# frozen_string_literal: true
# Represent a PMD violation.
class PmdViolation
PRIORITY_ERROR_THRESHOLD = 4
attr_accessor :violation
def initialize(violation)
@violation = violation
end
def priority
@priority ||= violation.attribute('priority').value.to_i
end
def type
@type ||= priority < P... |
require 'nokogiri'
require 'digest/sha1'
require 'tipr'
DIPFile = Struct.new(:sha_1, :path, :oid, :format)
class Representation
attr_reader :type, :ieid, :create_date, :package_id, :files, :events, :agents,
:global_files, :global_events
alias_method :to_xml, :to_s
# Requires a type ('ORIG' or 'ACTIV... |
class Customer < ActiveRecord::Base
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
has_many :orders, dependent: :destroy
has_many :ratings, dependent: :destroy
has_many :books, through: :orders
belongs_to :billing_address, class_name: "Address",... |
module TagLib::Ogg::Vorbis
# The file class for `.ogg` and other `.oga` files.
#
# @example Reading Vorbis comments
# TagLib::Ogg::Vorbis::File.open("file.oga") do |file|
# tag = file.tag
# puts tag.title
# fields = tag.field_list_map
# puts fields['DATE']
# end
#
class File < ... |
class Lesson < ActiveRecord::Base
belongs_to :lessonable, :polymorphic => true
acts_as_list :column => :position, :scope => :lessonable
acts_as_authorization_object
belongs_to :author, :class_name => "User", :foreign_key => "author_id"
has_many :lessons, :as => :lessonable
has_many :pages, :order => :positi... |
# Filters added to this controller apply to all controllers in the application.
# Likewise, all the methods added will be available for all controllers.
class ApplicationController < ActionController::Base
helper :all # include all helpers, all the time
# See ActionController::RequestForgeryProtection for d... |
class Playlist < ApplicationRecord
has_many :songs
validates_presence_of :title
end
|
class DevelopersController < MobileController
def index
@developers = Registration.developers
end
end
|
class Produto < ApplicationRecord
has_one_attached :image
def self.buscar_prod(nome)
where("lower(nome_prod) LIKE ?", '%' + nome.downcase + '%')
end
def self.buscar_prod_dono(email)
where("lower(dono_produto) LIKE ?", '%' + email.downcase + '%')
end
def logo_url
Rails.application.routes.url_helpers.... |
require 'spec_helper'
module RequirejsOptimizer
module Step
describe Finalize do
before do
# disconnect file system modifications
FileUtils.stub(:rm_r)
FileUtils.stub(:cp_r)
end
describe '#perform' do
it "removes the current public/assets directory" do
... |
# take_a_number(katz_deli, "Kent") #=> Welcome, Kent. You are number 3 in line.
def take_a_number(list, name)
list.push(name)
puts "Welcome, #{name}. You are number #{list.length} in line."
return list
end
# line(katz_deli) #=> "The line is currently: 1. Ada 2. Grace 3. Kent"
#If there is nobody in line, it shou... |
Rails.application.routes.draw do
devise_for :teachers
devise_for :students
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
# Root needs to be where we want to redirect the viewer when they
# log in for devise
root to: "courses#index"
# We can have th... |
class Board < ActiveRecord::Base
attr_accessible :title, :user_id
validates :title, presence: true
belongs_to :user
has_many :lists, dependent: :destroy
has_many :memberships
has_many :members, through: :memberships
default_scope order('id ASC')
end
|
class Album < ActiveRecord::Base
has_many :discs
belongs_to :genre
def Album.find_generously(search_term)
disc_join = 'INNER JOIN discs ON discs.album_id = albums.id'
album_conditions =<<-GENIUS
albums.name ILIKE :criterion
OR albums.artist_name ILIKE :criterion
OR genre_id I... |
class Usuario < ActiveRecord::Base
validates :nombre, :email, presence: true
has_many :mensajes
has_secure_password
end
|
class CreateSettings < ActiveRecord::Migration
def change
create_table :settings do |t|
t.string :language, default: 'japanese'
t.boolean :email_follow, default: true
t.boolean :email_like, default: true
t.boolean :email_bookmark, d... |
class CourseSection < ActiveRecord::Base
belongs_to :course_teacher_assignment
delegate :course, to: :course_teacher_assignment
delegate :teacher, to: :course_teacher_assignment
has_many :student_course_sections
has_many :students, through: :student_course_sections
has_many :courses, :through => :course_sec... |
require 'test_helper'
class BreweryTest < ActiveSupport::TestCase
test "truth" do
assert_kind_of Module, Brewery
end
test "Brewery::ApplicationController derives from ApplicationController" do
assert_operator Brewery::ApplicationController, :<, ::ApplicationController
end
test "Br... |
class CreateRecordsSingles < ActiveRecord::Migration
def change
create_table :records_singles, :id => false do |t|
t.integer :record_id, :null => false
t.integer :single_id, :null => false
end
end
end
|
require 'forwardable'
require 'net/http'
require 'net/http/post/multipart'
require 'uri'
require 'yajl'
module Songkick
module Transport
DEFAULT_TIMEOUT = 5
DEFAULT_FORMAT = :json
DEFAULT_USER_ERROR_CODES = [409]
HTTP_VERBS = %w[options head get patch post put delete]
USE_BODY = %w[post... |
class Api::HistoriesController < ApplicationController
before_action :set_api_history, only: [:update, :destroy]
# GET /api/histories.json
def index
@api_histories = History.all
end
# POST /api/histories.json
def create
@api_history = History.new(api_history_params)
respond_to do |format|
... |
require 'pry'
class CashRegister
attr_accessor :total, :discount, :items, :last_transaction
def initialize(discount = 0)
@items = []
@total = 0
@discount = discount
end
def add_item(title, amount, number = 1)
self.total += amount * number
number.times do
@items << title
... |
class Tool < ActiveRecord::Base
mount_uploader :image, ImageUploader
attr_accessible :description, :image, :name
has_many :tool_ages
has_many :tool_factors
validates :name, :presence => true
def self.search(search)
if search
where('name LIKE ?', "%#{search}%")
else
scoped
end
end
d... |
class CreateVendors < ActiveRecord::Migration
def change
create_table :vendors do |t|
t.string :name
t.string :email
t.string :line_1
t.string :line_2
t.string :city
t.string :state
t.string :zipcode
t.string :photo_url
t.boolean :is_... |
class Bookmark
attr_accessor :url, :name
def initialize(name, url)
@name = name
@url = url
end
def to_s(indent=0)
#puts "In Bookmark::to_s"
spaces = " " * indent
"#{spaces}#{@name} | #{url}"
end
end
|
require 'open-uri'
require 'net/http'
class User < ApplicationRecord
belongs_to :cohort
has_many :projects
validates :first_name, :last_name, :username, presence: true
validates :username, uniqueness: true
# validate :image_checker
attr_reader :full_name, :password
def full_name
"#{self.first_n... |
require 'rspec'
require_relative '../lib/ruby_js_html_wrapper/html_document'
require_relative '../lib/ruby_js_html_wrapper/stacked_bar_chart'
require_relative '../lib/ruby_js_html_wrapper/columnchart'
describe 'Html Document' do
let(:file) do
File.join('htmldoctest.html')
end
let(:stackedchart) do
ar... |
NUMBERS = {
'zero' => 0,
'one' => 1,
'two' => 2,
'three' => 3,
'four' => 4,
'five' => 5,
'six' => 6,
'seven' => 7,
'eight' => 8,
'nine' => 9
}
def computer(string)
arr = string.split(' ')
converted = arr.each_index.map { |idx| idx.even? ? NUMBERS[arr[idx]] : arr[idx]}
loo... |
module InvoiceTopDays
def average_invoices_per_day
invoice_count = @engine.invoice_list.count
(invoice_count/7.0).round(2)
end
def invoice_creation_days
invoices = @engine.invoice_list
invoices.map do |invoice|
date = invoice.created_at
date.strftime("%A")
end
end
def invoic... |
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe 'Api::Users::Quizzes::Questions', type: :request do
include_context 'login as current_user'
let(:current_user) { create(:user) }
describe 'POST /api/users/quizzes/:id/questions' do
let(:quiz) { create(:quiz, user: current_user) }
it 'cr... |
# Write a program that takes a user-entered list of states and prints them to the screen
# Hint: Use an array
visited = []
puts "Where Have You Been?"
puts "Enter all the states you've been to! Type 'done' when you're finished:"
keep_going = true
while keep_going
state = gets.chomp
if state == "done"
... |
require 'rails_helper'
RSpec.describe Neighbourhood, type: :model do
subject{ FactoryGirl.create(:neighbourhood) }
it "has a valid factory" do
expect(subject).to be_valid
end
it { should belong_to(:city) }
it { should have_many(:worksites) }
it { is_expected.to validate_presence_of(:name) }
it {... |
json.community_service do
json.partial! "api/v1/community_services/community_service", community_service: @community_service
end
|
require 'spec_helper'
describe "31292275 has_sage_flow_transitions optionally takes a block" do
before(:each) do
class Foo < Sample
has_sage_flow_states :new, :open, :saved, :locked
has_sage_flow_transitions edit: {:new => :open}, save: {open: :saved}
has_sage_flow_transitions lock: {saved: :lo... |
class Job < ActiveRecord::Base
belongs_to :job_category
has_many :job_applies
validates_presence_of :title, :description, :profile#, :location
validates_uniqueness_of :reference
named_scope :not_deleted, :conditions=> ["deleted_at IS NULL"]
named_scope :active, :conditions=> ["start_published_at >= ? and... |
class CreateProducts < ActiveRecord::Migration
def change
create_table :products do |t|
t.string :title
t.string :image
t.string :location
t.column :price, 'decimal(10,2)'
t.string :status
t.string :action
t.string :platform
t.string :url
t.string :seller
... |
class User < ActiveRecord::Base
has_many :likes, dependent: :destroy
has_many :dislikes, dependent: :destroy
has_many :liked_shows, through: :likes, class_name: 'Show', source: :show
has_many :disliked_shows, through: :dislikes, class_name: 'Show', source: :show
def like!(show)
dislikes.where(show_id: sh... |
class FontSarpanch < Formula
head "https://github.com/google/fonts.git", verified: "github.com/google/fonts", branch: "main", only_path: "ofl/sarpanch"
desc "Sarpanch"
homepage "https://fonts.google.com/specimen/Sarpanch"
def install
(share/"fonts").install "Sarpanch-Black.ttf"
(share/"fonts").install "... |
module Yoti
# Encapsulates Yoti user profile
class Profile
def initialize(profile_data)
if !profile_data.is_a? Object
profile_data = Hash.new
end
@profile_data = profile_data
end
def selfie
return get_attribute(Yoti::Attribute::SELFIE)
end
def famil... |
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup).
#
# Examples:
#
# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
# Ch... |
class RestaurantsManager < ActiveRecord::Base
belongs_to :restaurant
belongs_to :manager
end
|
STDIN.each_line do |line|
puts line.split.map(&:to_i).inject(:+)
end
|
module RBot
module Commands
class Monitor < RBot::Commands::Base
match(/.*/)
def self.call(client, data, match)
user = client.users[data.user]
channel_name = client.channels[data.channel].try(:name)
Celluloid::Actor[:user_activity].async.track(user_name: user.name)
... |
class Empresa < ActiveRecord::Base
has_many :usuarios
has_many :departamentos
has_many :unidades
has_many :requisicoes
validates_presence_of :nome
validates_uniqueness_of :nome
def codigo
sprintf("%0.3d", id)
end
end
|
class Source < ApplicationRecord
belongs_to :medium, optional: true
enum kind: %i[primary secondary tertiary]
validate :at_least_one_field_present
private
def at_least_one_field_present
[author, title, url].map(&:present?).any?
end
end
|
require 'telegram/errors/common_error'
module Telegram
module Errors
module Routing
class BadRouteError < Telegram::Errors::CommonError
def initialize route
super "Bad route \"#{route}\""
end
end
end
end
end
|
# Die Class 2: Arbitrary Symbols
# I worked on this challenge [by myself ].
# I spent [1.25] hours on this challenge.
# Pseudocode
# Input: An array of strings
# Output: Random String, number of sides
# Steps: When creating a new die, if the number of sides is less than one, return an error
# Create the number of ... |
require "spec_helper"
RSpec.describe "Day 4: Camp Cleanup" do
let(:runner) { Runner.new("2022/04") }
let(:input) do
<<~TXT
2-4,6-8
2-3,4-5
5-7,7-9
2-8,3-7
6-6,4-6
2-6,4-8
TXT
end
describe "Part One" do
let(:solution) { runner.execute!(input, part: 1) }
it "... |
require 'spec_helper'
feature 'user reviews a market', %Q{
As an authenticated user
I want to review a market
So that I an give my opinion about the market
} do
scenario 'user provides text for Review field' do
user = FactoryGirl.create(:user)
market = FactoryGirl.create(:market)
total_count = ... |
module Framework
class Renderer
class << self
def types
{
plain: PlainRenderer,
html: HtmlRenderer,
js: JsRenderer,
json: JsonRenderer,
xml: XmlRenderer
}
end
def create(type)
types[type].new
end
end
def re... |
class ItemImage < ApplicationRecord
belongs_to :section
# has_attached_file :image, #styles: { large: '1000x1000>', medium: "300x300>", thumb: "100x100#" }, default_url: "/images/:style/missing.png"
# validates_attachment_content_type :image, content_type: /\Aimage\/.*\z/
has_attached_file :image, styles: { lar... |
json.array!(@maintenance_records) do |maintenance_record|
json.extract! maintenance_record, :id
json.url maintenance_record_url(maintenance_record, format: :json)
end
|
class CreateBlogUrls < ActiveRecord::Migration
def self.up
create_table :blog_urls, :force => true do |t|
t.string :url,:limit=>250
t.integer :user_id
end
add_index :blog_urls, :user_id
end
def self.down
drop_table :blog_urls
end
end
|
module CorePrint
class Dam
def initialize(account)
@account = account
end
def save(fh)
response = @account.request(:stream, dam_save_service, { }, fh)
if response.has_key?(:action) && response[:action] == "ok"
return response
else
return false
end
end
... |
require 'calabash-android/calabash_steps'
require 'pry'
When(/^I tap <view> for (\d+) times$/) do |times, table|
times.to_i.times do
table.hashes.each do |row|
id = row['view']
tap_when_element_exists("* id:'#{id}'")
end
end
end
When(/^I long tap <view> for (\d+) times$/) do |times, table|
t... |
require 'chemistry/element'
Chemistry::Element.define "Potassium" do
symbol "K"
atomic_number 19
atomic_weight 39.0983
melting_point '336.5K'
end
|
class CreatePartnerPhotos < ActiveRecord::Migration[5.0]
def change
create_table :partner_photos do |t|
t.string :title
t.string :link
t.integer :status
t.integer :album_id, index: true
t.timestamps
end
add_reference :partner_photos, :partner, foreign_key: true
end
end
|
# ============================================================================
# e-archia: stories controller
# author: nunojobpinto[at]gmail[dot]com
# ============================================================================
class StoriesController < ApplicationController
# =======================================... |
require 'test_helper'
class EntryTest < ActiveSupport::TestCase
fixtures :users
self.use_instantiated_fixtures = true
test "a user's all_tags gets set when an entry is saved" do
e = Entry.new :user => @bob, :tags => 'xyz abc jkl'
assert e.save
assert @bob.reload
assert_equal 'abc jkl xyz', @bob.... |
class Attendee
attr_reader :reg_date,
:first_name,
:last_name,
:email_address,
:home_phone,
:street,
:city,
:state,
:zipcode
def initialize(data)
@normal = Normalize.new
@reg_date =... |
require 'spec_helper'
if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0
describe 'Dehydrated::WildcardDN' do
describe 'accepts wildcarddn' do
[
'*.example.com',
'*.bzed.at',
].each do |value|
describe value.inspect do
it { is_expected.to allow_value(v... |
class CreateSteps < ActiveRecord::Migration
def change
create_table :steps do |t|
t.references :guider
t.integer :step_order
t.text :link
t.text :question
t.string :answer1
t.string :answer2
t.string :answer3
t.integer :correct_answer
t.timestamps
end
e... |
module TinyCI
module OutputParser
class CapistranoCommandParser < Base
def parse!
@result = TinyCI::Report::DeployCommandReport.new
last_server = nil
last_channel = nil
while !empty?
line = consume!.line
if line =~ /^\s*\*\* \[... |
# encoding: utf-8
# Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
module MobileCenterApi
module Models
#
# Audience definition.
#
class AudienceSummary
# @return [String] Audience name.
... |
module ApplicationHelper
def admins_link(&block)
block.call if current_user.try(:admin)
end
def owner_link(object, &block)
block.call if current_user == object.try(:user)
end
def is_active?(link_path)
current_page?(link_path) ? "active" : ""
end
end
|
class QueueElement
def initialize(obj, read_loop, str_priority = 'low')
@obj = obj
@str_priority = str_priority
@num_priority = 1
@read_loop = read_loop
end
def num_priority
return @num_priority
end
def str_priority
return @str_priority
end
def execute
@obj.execute
#only... |
class TravisParser
def self.parse(params, project)
new(params, project).parse
end
def initialize(params, project)
parsed = JSON.parse params[:payload]
@params = ActiveSupport::HashWithIndifferentAccess.new parsed
@project = project
end
def parse
Hook.create hook_params
end
private
... |
Rails.application.configure do
# http://guides.rubyonrails.org/active_job_basics.html#backends
config.active_job.queue_adapter =
if Rails.env.test?
# Our "after_commit" model callbacks are not being executed correctly in test environment
# (despite adding the "test_after_commit" gem). Therefore havi... |
require 'rails_helper'
require 'swagger_helper'
RSpec.describe MovieCatalog, type: :model do
describe 'relation' do
it { should belong_to(:movie) }
end
end
|
module BaristaMatic
module StorageCommands
class Restock
attr_reader :shipment
# hash of item_name => quantity
def initialize(shipment)
@shipment = shipment
end
# execute with storage details
# returns the remaining shipment units, without changing the argument... |
class Tag < ApplicationRecord
has_many :gossip_tag_joins
has_many :gossips, through: :gossip_tag_joins
end
|
class Organization < ActiveRecord::Base
has_many :user, dependent: :destroy
has_many :contract
#validates_associated
validates :name, presence: true
#validates :name_eng
validates :email, format: { with: /\A[-\w.]+@([A-z0-9][-A-z0-9]+\.)+[A-z]{2,4}\z/}
validates :tpolis_num, :ptc_num, numericality: {only... |
#the strategy class contants formatting methods for the report
#each different format required would be dealt with using a new class
class HTMLFormatter
def output_report(report)
#this method is called from the context (report), which passes itself as an argument
puts '<html>'
puts ' <head>'
puts " <title>#{... |
# Trivial base class to DRY up the GDI Window / Printer code
#
# Author: Ben Nagy
# Copyright: Copyright (c) Ben Nagy, 2006-2013.
# License: The MIT License
# (See http://www.opensource.org/licenses/mit-license.php for details.)
require_relative 'ffi_binding'
require_relative 'font'
require_relative 'text'
require_rel... |
# frozen_string_literal: true
# this is the model
# that takes care of all actions related to players table
class Player < ApplicationRecord
belongs_to :team
validates :name, presence: :true
validates :skill_level, presence: true
end
|
# encoding: utf-8
module ActiveRecord
class Base
### note:
## alias_method will NOT work for activerecord attributes
## - attribute reader/writer will NOT exist on startup
# thus, lets add a new alias_attr that will
# send message / forward method call on demand
#
# e.g. use like:
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.