text stringlengths 10 2.61M |
|---|
class Admin::BaseController < ActionController::Base
protect_from_forgery with: :exception
before_filter :authenticate_admin!
before_filter :ensure_en_locale
layout 'admin'
private
def ensure_en_locale
I18n.locale = :en
end
end |
require 'rspec'
require 'dessert'
=begin
Instructions: implement all of the pending specs (the `it` statements without blocks)! Be sure to look over the solutions when you're done.
=end
describe Dessert do
let(:chef) { double("chef", name: "Alexandra") }
describe "#initialize" do
subject(:cupcakes) { Dessert... |
class Ship
attr_reader :abbv,
:coordinates,
:name,
:size
attr_accessor :coordinates
def initialize(name, size, coordinates=nil)
@abbv = name[0]
@coordinates = coordinates
@hits = 0
@name = name
@size = size
... |
module CDI
module V1
module PageStructure
class LearningCyclePageSerializer < BaseSerializer
has_one :learning_cycle, serializer: ModelSerializer::LearningCycleSerializer
has_many :categories, serializer: ModelSerializer::CategorySerializer
end
end
end
end
|
module Riopro
module KillBill
module Bank
class Itau < Riopro::KillBill::Bank::Base
attr_accessor :cpf_or_cnpj
# Expects an Array describing services included in this billing
attr_accessor :descriptions
# bank default options
def initialize(options = {})
s... |
module GraphQLServer::BatchLoaders
class JoinsThroughLoader < BaseLoader
RECORD_KEY = '__record_key__'
def initialize(model, association_name, column)
@model = model
@column = column
@association = model.reflect_on_association(association_name)
if !@association.is_one_of?([ActiveRec... |
# Print to stdout, each element in a hash based linked list.
# If you don't know what that is, go check out the previous problem.
#
# EXAMPLES:
# head = {:data => 1, :next => nil}
# print_list head # >> "1\n"
# head = {:data => 2, :next => head}
# print_list head # >> "2\n1\n"
# he... |
class User < ApplicationRecord
validates :email, :uniqueness => true, :on => :create
end
|
require File.join(File.dirname(__FILE__), '..', 'test_helper')
# create
# ------
class IQ::Crud::Actions::Create::CreateTest < Test::Unit::TestCase
def setup
ActionView::Base.any_instance.stubs(:error_messages_for).returns('<p id="errors">Errors</p>')
['', 'admin_'].each do |prefix|
send(prefix + 'crud... |
class RouteAdditionalDetailsController < ApplicationController
before_filter :login_required
before_filter :set_additional_field, :only => [:edit, :update, :delete_details]
filter_access_to :all
require 'lib/override_errors'
helper OverrideErrors
check_request_fingerprint :create, :update
def ind... |
class MockBoard
attr_reader :board_displayed, :spaces
def print_board
@board_displayed = true
end
def spaces
@spaces = true
end
end
|
class Integer
def to_roman
=begin
As a reminder, here's the full list of roman numerals:
SYMBOL VALUE
I 1
IV 4
V 5
IX 9
X 10
XL 40
L 50
XC 90
C 100
CD 400
D 500
CM 900
M ... |
class User < ActiveRecord::Base
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
ROLES = %w[Unapproved Basic Creative Admin Retired]
after_create :notify_user_created
before_destroy :unlink_orders
has_many :assignments, dependent: :destroy
has_many :orga... |
require 'rails_helper'
RSpec.describe User, :type => :model do
context "roles" do
it "returns two roles by default" do
expect(User.roles).to eq({"visitor" => 0, "admin" => 1})
end
end
context "role" do
it "equals :visitor by default" do
user = create(:user)
expect(user.role).to eq... |
class Videos < ActiveRecord::Migration
def change
create_table :videos do |t|
t.integer :user_id
t.integer :videonumber, default: 1
t.string :filename
t.string :thumbnail
t.string :title
t.string :caption
t.integer :views
t.string :responseto
t.timestamps
end
end
end
|
# NAME: MESA_Reader
# AUTHOR: William Wolf
# LAST UPDATED: August 21, 2013
# PURPOSE: Provides access to the MESAData class, which, through the methods
# header and data, can return a value (header) or DVector (data) the
# corresponds to the key provided to it. New in this version: access
# t... |
class AddRoomNameToReceptions < ActiveRecord::Migration
def change
add_column :receptions, :room_name, :string
end
end
|
class Event
include Mongoid::Document
include Mongoid::Slug
# after_create :send_mail_to_users_about_events
#attr_accessible :name,:description,:images_attributes
field :name, type: String
field :description, type: String
field :start_time, type: DateTime
field :end_time, type: DateTime
field :venue... |
# Description: A basic GNU/linux filesystem
# URL: http://www.buildgear.org
name=fs
version=1.0
release=1
options=(nostrip)
source=(modules-load.d.rpi3.conf)
depends=(core
linux
wiringpi
lighttpd
php
i2c-tools
avahi)
build() {
# Copy fully populated sysroot
... |
class MomentumCms::Admin::PagesController < MomentumCms::Admin::BaseController
before_action :load_momentum_cms_page, only: [:edit, :update, :destroy]
before_action :build_momentum_cms_page, only: [:new, :create]
before_action :load_parent_pages, only: [:edit, :new, :update, :create]
def index
@momentum_cm... |
# -*- coding: utf-8 -*-
require 'helper'
require File.join 'adapters', 'dictionary', 'dictionary'
# http://www.dictionaryapi.com/content/products/documentation/collegiate-tag-description.txt
describe "Obtaining definitions from Merriam-Webster" do
let(:dictionary) do
Dictionary.new(:key => Options.dictionary_... |
#! /usr/bin/env ruby
require 'rubygems'
require 'user-choices'
require 'lib/snail.rb'
class Snail < UserChoices::Command
include UserChoices
def add_sources(builder)
builder.add_source(CommandLineSource, :usage,
"Usage ruby #{$0} [options] host port",
"Connect to IRC.")
builder.add_source(Envi... |
require_relative "test_helper"
require_relative "../lib/merchant"
class MerchantTest < Minitest::Test
def test_it_exists
parent = mock("parent")
merchant = Merchant.new({id: 1, name: "monkey", created_at: "2009-05-30"}, parent)
assert_instance_of Merchant, merchant
end
def test_it_has_id
paren... |
class AddQuoteBoxSizeToWorkingArticle < ActiveRecord::Migration[5.1]
def change
add_column :working_articles, :quote_box_size, :integer
end
end
|
class SessionsController < ApplicationController
def create
@user = User.find_by(username: params[:username])
if @user.nil?
redirect_to login_path
flash[:warning] = 'That user does not exist.'
else
session[:user_id] = @user.id
redirect_to root_path
flash[:notice] = "Welcome b... |
require 'dm-core'
require 'dm-migrations'
require 'dm-postgres-adapter'
require 'dm-postgis/operators'
require 'dm-custom-index'
module DataMapper
class Property
autoload :PostGISGeometry, 'dm-postgis/pg_geometry'
autoload :PostGISGeography, 'dm-postgis/pg_geometry'
end
module Post... |
class Api::SurveyQuestionsController < ApplicationController
def index
questions = SurveyQuestion.where(survey_id: params[:survey_id])
render json: questions
end
def show
question = SurveyQuestion.find_by!(id: params[:id])
render json: question
end
end
|
class Rating < ActiveRecord::Base
belongs_to :customer
belongs_to :book
validates_inclusion_of :rating_number, :in => 1..10
end
|
# encoding: utf-8
# copyright: 2016, you
# license: All rights reserved
# date: 2015-08-28
# description: All directives specified in this STIG must be specifically set (i.e. the server is not allowed to revert to programmed defaults for these directives). Included files should be reviewed if they are used. Procedure... |
class CardsController < ApplicationController
def new
@card = Card.new
end
def create
@card = Card.new(card_params)
if @card.save
redirect_to root_path
else
render 'new'
end
end
def edit
@card_edit = Card.find(params[:id])
end
def update
@card = Card.find(para... |
class AddMissingIndexes < ActiveRecord::Migration
def change
add_index :tracks, :conference_id
add_index :activities, :room_id
add_index :activities, [:detail_id, :detail_type]
add_index :review_decisions, :session_id
add_index :review_decisions, :organizer_id
add_index :review_decisions, :out... |
class Cuboid
attr_reader :x, :y, :z
def initialize(x:, y:, z:)
@x = x
@y = y
@z = z
end
def size
@x.size * @y.size * @z.size
end
def &(other)
xint = intersection(x, other.x)
yint = intersection(y, other.y)
zint = intersection(z, other.z)
return nil unless xint && yint && ... |
module Paperclip
class Attachment
# PATCH check thumbnailable, ie. is an image or PDF content type
def self.thumbnailable?(content_type)
[ 'image/jpeg', 'image/pjpeg',
'image/gif', 'image/png',
'image/x-png', 'image/jpg',
'application/pdf' ].include?(content_type)
end
pr... |
# coding: utf-8
module API
class AuthCodesAPI < Grape::API
resource :auth_codes do
# 获取验证码
params do
requires :mobile, type: String, desc: "手机号,必须"
end
post :fetch do
# 手机号验证
unless check_mobile(params[:mobile])
return { code: 1001, message: "... |
# -*- coding: utf-8 -*-
CATEGORIZED_ASIN_LIST = <<END
- category: ''
asin:
- '1234567890'
- '0987654321'
- category: 'poem'
asin:
- '1111111111'
- '2222222222'
- '3333333333'
END
AMAZON_ASSOCIATE_ID = 'your-affiliate-id'
AMAZON_AFFILIATE_TEMPLATE_URL = '<iframe src="http://rcm-fe.amazon-adsys... |
class Vote < ActiveRecord::Base
attr_accessible :voted_for_user_id, :voting_user_id
belongs_to :voting_user, class_name: 'User', foreign_key: 'voting_user_id'
belongs_to :voted_for_user, class_name: 'User', foreign_key: 'voted_for_user_id'
# belongs_to :user
validate :user_cannot_vote_more_than_three_times... |
class RecursiveLinkedList
attr_accessor :head
def initialize
@head = nil
end
def append(node, list_node = head)
if head.nil?
self.head = node
elsif list_node.link.nil?
list_node.link = node
else
append(node, list_node.link)
end
end
def prepend(node)
node.link = h... |
require 'spec_helper'
RSpec.describe PJBank::Recebimento::Boleto do
let(:credencial) { "15524442a57788c4f3109c939056d821302155a9" }
let(:chave) { "027e30fbc768931e0682479e0f0404a0fcc8886b" }
let(:http) { PJBank::Http.new(credencial: credencial, chave: chave) }
subject { described_class.new(http) }
de... |
#######################################
# Kafka BCPC specific attributes #
#######################################
#
# Attribute to indidate whether an existing Hadoop Zookeeper
# can be used. If not Kafka Zookeeper quorum need to be created.
#
# This should always be false in a standalone Kafka cluster.
#
defaul... |
class Person
attr_reader :first_name, :last_name, :gender
attr_writer :first_name
def initialize(first_name, last_name, gender)
@first_name = first_name
@last_name = last_name
@gender = gender
end
def fullname
return "#{first_name} #{last_name}"
end
def doctor
... |
json.current_user do |json|
json.id @current_user.id
json.name @current_user.name
end
|
module Pjax
extend ActiveSupport::Concern
included do
before_filter lambda {
if pjax_request?
self.instance_eval do
@old_layout = self.send("_layout")
end
self.class.send(:layout, false)
end
}
after_filter lambda {self.class.send(:... |
require 'rails_helper'
RSpec.describe "Groups Pages" do
subject { page }
let(:user) { FactoryGirl.create(:user) }
before { valid_signin user }
describe "With group_editor permission" do
before do
Permission.create(name: "group_editor", user: user)
visit root_path
end
describe "Group... |
class ApplicationMailer < ActionMailer::Base
default from: 'noreply@aem.org.ua'
layout 'mailer'
end |
# frozen_string_literal: true
module BPS
module PDF
class Roster
class Detailed
module Benefits
def benefits
formatted_page do
benefits_intro
benefits_list
store_info
benefits_disclaimer
end
end
... |
module Polycon
module Commands
module Professionals
require 'fileutils'
HOME = Dir.home
FileUtils.mkdir_p(HOME+"/.polycon") unless File.exists?(HOME+"/.polycon")
class Create < Dry::CLI::Command
desc 'Create a professional'
argument :name, required: tru... |
#Copyright 2010 Foradian Technologies Private Limited
#This product includes software developed at
#Project Fedena - http://www.projectfedena.org/
#
#Licensed under the Apache License, Version 2.0 (the "License");
#you may not use this file except in compliance with the License.
#You may obtain a copy of the License at... |
class CodeVersionsController < ApplicationController
# GET /code_versions
# GET /code_versions.json
def index
@code_versions = CodeVersion.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @code_versions }
end
end
# GET /code_versions/1
# GET /code_... |
class AddBaseRatioToShift < ActiveRecord::Migration[6.0]
def change
add_column :shifts, :base_ratio, :integer, null: true
reversible do |change|
change.up do
ActiveRecord::Base.transaction do
Shift.update_all('base_ratio=shifts.limit')
end
end
end
end
end
|
Rails.application.routes.draw do
# get 'welcome/index', as: :main
devise_scope :user do
authenticated :user do
root 'welcome#index', as: :authenticated_root
end
unauthenticated do
root 'devise/sessions#new', as: :unauthenticated_root
end
end
devise_for :users
root "welcome#in... |
class AddFieldsToUsers < ActiveRecord::Migration[6.0]
def change
add_column :users, :first_name, :string, null: false
add_column :users, :last_name, :string, null: false
add_column :users, :date_of_birth, :datetime, null: false
add_column :users, :nationality, :string, null: false
add_column :user... |
require 'rails_helper'
RSpec.describe Cultivation::SaveSimpleBatch, type: :command do
let(:valid_user) { User.create!(email: 'email@email.com', password: 'password', password_confirmation: 'password') }
let(:facility) { Facility.create!(name: Faker::Lorem.word, code: Faker::Lorem.word) }
let(:existing_fs) { crea... |
class UserRepository
def self.find_or_create(user_entity:)
user = User.where(
provider: user_entity.provider,
uid: user_entity.uid
).first_or_create do |user|
user.password = user_entity.password
user.email = user_entity.email
user.name = user_entity.name
end
user_en... |
class Admins::StaticPagesController < Admins::BaseController
before_action :set_static_page, only: [:edit, :update, :destroy]
add_breadcrumb I18n.t('breadcrumbs.static_pages.name'), :admins_static_pages_path
add_breadcrumb I18n.t('breadcrumbs.static_pages.new'), :new_admins_static_page_path, only: [:new, :create... |
class TicTacToe
def initialize()
@board = Array.new(9, " ")
end
WIN_COMBINATIONS = [
[0,1,2], # top row
[3,4,5], # Middle row
[6,7,8], # Bottom row
[0,3,6], # Left column
[1,4,7], # Middle column
[2,5,8], # Right column
[0,4,8], # Left to right diagonal
[6,4,2], # Right to lef... |
# encoding: utf-8
module TTY
class Terminal
# A class responsible for paging text inside terminal
class Pager
attr_accessor :enabled
attr_reader :text
@command = nil
# Initialize a Pager
#
# @param [String] text
# the text to page
#
# @api public
... |
#!/usr/bin/env ruby
#
# to support different dims for test input
WIDTH = (ARGV[1] || 25).to_i
HEIGHT = (ARGV[2] || 6).to_i
# an array of layers
# for now each layer is just another array:
# don't need a grid for p1
def read_layers(digits)
digits.each_slice(WIDTH * HEIGHT).to_a
end
def p1(layers)
l = layers.min_by... |
class ClientesController < ApplicationController
before_action :set_cliente, only: [:show, :edit, :update, :destroy]
before_action :set_cidade, only: [:show, :edit, :update, :destroy, :new]
before_action :set_administradora, only: [:show, :edit, :update, :destroy, :new]
before_action :set_contrato, only: [:show... |
require 'spec_helper'
RSpec.describe GridGenerator do
describe "#generate" do
let(:primes) { [2,3,5] }
subject { described_class.new(primes: primes) }
it "generates an array of arrays" do
expect(subject.generate).to be_an_instance_of(Array)
expect(subject.generate[0]).to be_an_instance_of(Ar... |
class Manager < ActiveRecord::Base
has_many :restaurants_managers
has_many :restaurants, through: :restaurants_managers
end
|
require 'deckchair/view_helpers'
module Deckchair
class Railtie < Rails::Railtie
initializer "deckchair.view_helpers" do |app|
ActionView::Base.send :include, ViewHelpers
end
end
end
|
class DataMailer < ActionMailer::Base
default from: "no-reply@idrivealot.com"
def monthly_data(user_id, report_string, data)
@user = User.find(user_id)
@download_data = data
xlsx = render_to_string template: "mileage_records/aldi_log.xlsx.axlsx", locals: {current_user: @user}
attachments["#{report... |
require "minitest/autorun"
require "d17"
SAMPLE = <<~STR
x=495, y=2..7
y=7, x=495..501
x=501, y=3..7
x=498, y=2..4
x=506, y=1..2
x=498, y=10..13
x=504, y=10..13
y=13, x=498..504
STR
describe Scan do
it "parses" do
s = Scan.parse(<<~STR)
x=501, y=2..3
y=7, x=10..11
STR
s[Point.new(501, 2)].must... |
require "pdd/version"
module Pdd
class Error < StandardError; end
def self.put(&block)
puts "#" * 60
puts "#" * 60
puts yield
puts "#" * 60
puts "#" * 60
end
end
|
class CreateDispositions < ActiveRecord::Migration
def change
create_table :dispositions do |t|
t.integer :animal_id
t.integer :personality_type_id
t.timestamps
end
end
end
|
require 'test_helper'
# bundle exec ruby -Itest test/controllers/users_controller_test.rb
class UsersControllerTest < ActionDispatch::IntegrationTest
describe "#show" do
describe "when user is not logged in" do
test "redirect to login page" do
get user_url(users(:one))
assert_redirected_to ... |
# Copyright 2011 Dell, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, s... |
# == Schema Information
#
# Table name: episodes
#
# id :bigint not null, primary key
# anime_id :integer not null
# title :string not null
# genre :string not null
# episode_num :integer
#
class Episode < ApplicationRecord
validates :title, :genre... |
module Slug
module InstanceMethods
def slug
self.name.downcase.gsub(/\ /, "-")
end
end
module ClassMethods
def unslug(slug)
no_cap = ["and","or","the","to","a", "with"]
slug.gsub(/\-/," ").split(' ').map {|word|
if no_cap.include?(word)
word
else
word.capitalize
end
}.join... |
class AddChrClassRefToAdventurers < ActiveRecord::Migration
def change
add_reference :adventurers, :chr_class, index: true, foreign_key: true
end
end
|
class Sparc::SubServiceRequest < ActiveRecord::Base
include SparcShard
belongs_to :owner, :class_name => 'Identity', :foreign_key => "owner_id"
belongs_to :service_request
belongs_to :organization
has_many :line_items
has_many :one_time_fee_line_items, -> { one_time_fee }, :class_name => 'LineItem'
h... |
# frozen_string_literal: true
require 'rails_helper'
require 'generators/provider_state/provider_state_generator'
describe ProviderStateGenerator do
describe 'create_provider_state_file' do
context 'once generated' do
before(:all) { ProviderStateGenerator.new(['test']).create_provider_state_file }
... |
require 'sinatra'
require 'sinatra/activerecord'
require './environments'
require 'json'
get '/' do
@poems = Poem.all
erb :"poems/index"
end
post '/poem/:id' do
poem = Poem.find(params[:id])
content_type :json
{ id: poem.id, title: poem.title, body: poem.scrambled}.to_json
end
post '/poem/:poem_id/line/:li... |
require "rails_helper"
RSpec.describe AuthenticationsController, :type => :routing do
describe "routing" do
it "routes to #index" do
expect(:get => "/authentications").to route_to("authentications#index")
end
it "routes to #new" do
expect(:get => "/authentications/new").to route_to("authent... |
#super class / parent class
class Product
attr_accessor :name, :price, :description
def initialize(data={})
@name = data[:name]
@price = data[:price]
@description = [:description]
end
def display
"#{self.name} - INR - #{self.price} - #{self.description}"
end
end
#sub ... |
require 'test_helper.rb'
module JRL::Concurrent
class Latch
def fail_after_sec
raise Exception.new("timed out waiting one second for latch countdown - remaining count: #{count}") unless await 1
end
end
end
class MailboxTest < Test::Unit::TestCase
JThread = java.lang.Thread
def jrl_latch count ... |
require 'docking_station'
describe DockingStation do
it " creates an instance of DockingStation" do
expect(DockingStation.new).to be_an_instance_of(DockingStation)
end
it {is_expected.to respond_to(:release_bike)}
it 'expects bike to be working' do
subject.dock(double(:bike, working?: true))
expect(s... |
class CardsController < ApplicationController
before_action :set_card, only: [:show, :edit, :update, :destroy]
# GET /cards
# GET /cards.json
def index
@cards = Card.all
end
# GET /cards/1
# GET /cards/1.json
def show
end
# GET /cards/new
def new
@card = Card.new
end
def dancer_vis... |
require 'test-unit'
require "rbooks"
require "uri"
class TestBook < Test::Unit::TestCase
def test_concat_each_item_by_space
params = Rbooks::Book.concat_each_item_by_space({title: ["なれるSE", "こころ"], author: ["夏目漱石", "与謝野晶子"]})
assert_equal Hash, params.class
assert_equal params[:title], "なれるSE こ... |
class CreateBillAddresses < ActiveRecord::Migration
def change
create_table :bill_addresses do |t|
t.references :customers
t.string :address, null: false
t.string :postal_code, null: false
t.string :state_province, null: false
t.references :customer, null: false
t.timestamps
... |
class Expense < ActiveRecord::Base
belongs_to :property
has_many :expense_items, dependent: :destroy
accepts_nested_attributes_for :expense_items, allow_destroy: true
def total
expense_items.sum(:amount)
end
end
|
require 'rubygems'
require 'MeCab'
include Math
class CorrelationAnalyzer
def self.analyze(wine)
line = wine.comments
info = create_analyze_result_info_by_line(wine.wine_id,line)
return info
end
def self.create_analyze_result_info(wine_id)
info = AnalyzeResultInfo.new
rows = Analy... |
class Airport < ApplicationRecord
before_save :upcase_state
validates :city, presence: true
validates :state, presence: true, length: {maximum: 2}
validates :code, presence: true, length: {maximum: 3}
has_many :departing_flights, class_name: "Flight", foreign_key: "dept_airport_id"
has_many :arriving_flights, cla... |
class Propietario < ActiveRecord::Base
has_many :propiedades
belongs_to :agente
store_accessor :informacion
def nombre_completo
"#{informacion['nombre']} #{informacion['apellido']}"
end
class Informacion
include Virtus.model
include ActiveModel::Model
attribute :nombre, String
attribute :apel... |
class AlbumsController < ApplicationController
before_filter :get_artists, :only => [:edit, :new, :create]
# GET /albums
# GET /albums.json
def index
@albums = Album.where(:user_id => current_user.id)
@albums.each do |a|
get_artist a
end
respond_to do |format|
format.html # index... |
#!/usr/bin/env ruby
class Solution2
def initialize
@fibo_map = { 1 => 2, 2 => 8 }
end
def even_fibonacci(n)
return @fibo_map[n] if @fibo_map.has_key? n
@fibo_map[n] = 4 * even_fibonacci(n-1) + even_fibonacci(n-2)
end
end
s = Solution2.new
puts (1..12).map { |i| s.even_fibonacci(i) }.select { |f| ... |
require 'pry'
require_relative 'node'
class LinkedList
def initialize
@head = nil
end
def [](index)
node = @head
index.times do
if !node.next
return nil
else
node = node.next
end
end
node
end
def each
node = @head
while !node.nil?
yield(n... |
require 'cfndsl'
require 'erb'
require 'fileutils'
require 'cfndsl/globals'
require 'cfndsl/version'
require 'json'
require 'yaml'
require 'open-uri'
require 'net/http'
require 'net/https'
require 'highline/import'
require 'zip'
require_relative './util/zip.util'
require_relative './util/cloudformation.util'
module Cf... |
require_dependency "discovery/application_controller"
module Discovery
class CategoriesController < ApplicationController
before_filter :set_category, only: [:show, :edit, :update, :destroy]
before_filter :authorize
def index
@categories = Discovery::Category.all
@personalities = Discovery::Personality.a... |
# Develop your work so far to handle sentences
# e.g. "The quick fox jumped over the lazy dog" ->
# "Ethay ickquay oxfay umpedjay overway ethay azylay ogday"
def pig_latin(word)
capital = false
if word.capitalize == word
capital = true
end
if "aeiou".include? word.chr
word += "way"
else
i... |
shared_examples_for "Flavors" do
describe "#get" do
it "should return a matching flavor if one exists" do
get = @flavors.get(subject.id)
subject.attributes.should == get.attributes
end
it "should return nil if no matching server exists" do
@flavors.get('0').should be_nil
end
en... |
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
require File.expand_path('../config/application', __FILE__)
Rails.application.load_tasks
desc "Scrub reports and set checkin time to allow demo of checkin feat... |
class CreateOpTables < ActiveRecord::Migration[6.0]
def change
create_table :op_tables do |t|
t.string :code
t.string :name
t.string :profile
t.string :level
t.string :form
t.string :year
t.string :opop
t.string :edu_plan
t.string :annotation
t.string :r... |
class AddAvailableColumnToSlots < ActiveRecord::Migration[5.2]
def change
add_column :slots, :available, :boolean, default: true
end
end
|
class RenameColorsInProducts < ActiveRecord::Migration[5.2]
def change
rename_column :products, :color, :year
end
end
|
class User < ActiveRecord::Base
attr_accessible :email, :password, :token, :social_network_ids
validates :email, uniqueness: true
before_create :encrypt_password
before_create :generate_access_token
has_many :social_networks
has_many :nodes, through: :social_networks
has_many :families, through: :socia... |
class Admin::DocumentsController < ApplicationController
before_action :authenticate_user!
authorize_resource
before_action :load_model, only: [:edit, :show, :update, :destroy]
def index
@documents = Document.order("title")
end
def new
@document = Document.new
end
def show
end
def cre... |
require 'spec_helper'
require 'hannya'
require 'nokogiri'
include Hannya
xmlstring = <<-EOT
<Root>
<Policy>
<PolicyNumber>123456</PolicyNumber>
<InsuredName>Joe Smith</InsuredName>
<Address>
<AddressId>1</AddressId>
<Street>123 Mockingbird Ln.</Street>
<City>Sacramento</City>
<St... |
Rails.application.routes.draw do
resources :game_genres
resources :reviews
resources :likes
resources :orders
resources :items
resources :categories
resources :purchases
post '/users/register', to: 'users#create'
post '/users/login', to: 'users#login'
# For details on the DSL available within this... |
class Article < ActiveRecord::Base
has_one :page, :as => :content
has_many :audits, :as => :record, :class_name => 'Admin::User'
belongs_to :updated_by, :class_name => 'Admin::User'
belongs_to :created_by, :class_name => 'Admin::User'
named_scope :active, :conditions => {:active => true}
named_scope :ord... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.