text stringlengths 10 2.61M |
|---|
class PostSweeper < ActionController::Caching::Sweeper
include SweepingHelper
observe Post
def after_create(post)
expire_all(post, true) if !post.in_draft
end
def after_update(post)
if post.changed? && (post.in_draft_changed? || !post.in_draft)
expire_all(post)
end
end
def after_dest... |
class CreateRecruitments < ActiveRecord::Migration[5.2]
def change
create_table :recruitments do |t|
t.string :first_name
t.string :last_name
t.string :email
t.string :mobile_number
t.string :landline_number
t.string :position
t.text :feedback
t.integer :decision, d... |
module ZanoxPublisher
class Policy
class << self
def fetch(data = nil)
# To support API of picking categories of hash with [] notation
return nil if data.nil?
# Try to fetch policy else make data it an array
policies = data.fetch('policy', nil)
policies = [data] ... |
module MasterTablePrefix
extend ActiveSupport::Concern
module ClassMethods
def table_name_prefix
'm_'
end
end
end |
Gem::Specification.new do |s|
s.name = 'maws'
s.version = '0.8.2'
s.date = '2012-01-24'
s.summary = "MAWS"
s.description = "Tool set for provisioning and managing AWS infrastructures"
s.authors = ["Juozas Gaigalas", "Vinu Somayaji", "Bradly Feeley"]
s.email = ... |
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.1.4.rc1'
# Use postgresql as the database for Active Record
gem 'pg'
# Use Puma as the app server
gem 'puma', '~> 3.7'
# Bootstrap
gem 'bootstrap-sass', '~> 3.3.6'
gem 'bootstrap_form'
# Use SCSS for styles... |
class CreateResources < ActiveRecord::Migration[6.0]
def change
create_table :resources do |t|
t.integer :grade_level
t.string :subject
t.text :assignment
t.integer :user_id
t.integer :parent_id
t.integer :student_id
t.integer :message_id
t.timestamps
end
end... |
require 'spec_helper'
describe AdminsController do
login_admin
describe "admin profile page" do
before do
get :show, {:id => subject.current_admin.to_param}
end
it "should return http success" do
response.should be_success
end
it "should send the admin to the view" do
as... |
# This migration comes from mjweb (originally 20141104213412)
class CreateMjwebIcons < ActiveRecord::Migration
def change
create_table :mjweb_icons do |t|
t.string :name
t.string :icon
t.string :icon_black
t.string :icon_white
t.timestamps
end
end
end
|
class Tcc < ActiveRecord::Base
has_many :user
has_attached_file :arquivo
belongs_to :professor
validates_attachment_content_type :arquivo, :content_type => ["application/pdf"]
acts_as_taggable
validates_presence_of :titulo, :resumo, :data, :orientador
end
|
#TEDDIT: Strings - Student's File
# Teddit is a Ruby text based news aggregator. Think Reddit in your terminal.
# This exercise will be used throughout the ruby portion of this course.
# We will incrementally build a news aggregator (next week using API's)
# We will create a more dynamic Teddit, and pull the latest ne... |
class Work::MedicinesController < Admin::BaseController
before_action :set_medicine, only: [:show, :edit, :update, :destroy]
# GET /medicines
# GET /medicines.json
def index
@q = SearchParams.new(params[:search_params] || {})
search_params = @q.attributes(self)
@medicines = Medicine.default_where(s... |
class User < ApplicationRecord
attr_reader :password
validates :username, :session_token, uniqueness: true, presence: true
validates :password_digest, presence: true
validates :password, length: { minimum: 6 }, allow_nil: true
after_initialize :ensure_session_token
after_create :generate_wallets
ha... |
# frozen_string_literal: true
# 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).
life = Category.create(name: 'Life')
life.topics.create(name: 'Anger')
l... |
# frozen_string_literal: true
namespace :fetch do
desc 'Fetch rates'
task rates: :environment do
next if (11..19).exclude?(Time.zone.now.hour)
rates = TinkoffRates.new
rates.create_rates
end
end
|
class ConfigElementsController < ApplicationController
before_action :set_config_element, only: [:show, :edit, :update, :destroy]
# GET /config_elements
# GET /config_elements.json
def index
@config_elements = ConfigElement.all
end
# GET /config_elements/1
# GET /config_elements/1.json
def show
... |
require 'bike'
describe Bike do
describe "#working?" do
it "return true if the bike is working" do
expect(subject.working?).to be true
end
end
describe "#broken" do
it "change the bike status to broken" do
subject.broken
expect(subject.working?).to be false
end
end
describe... |
class AddCardTypeToTurnActions < ActiveRecord::Migration[5.2]
def change
add_column(:turn_actions, :card_type, :string)
remove_index(:turn_actions, [:turn_id, :card_id])
add_index(:turn_actions, [:turn_id, :card_id, :card_type], unique: true)
end
end
|
require 'rails_helper'
RSpec.describe TopicsHelper do
include TaggedContentHelpers
describe "#document_type_count" do
it "should return total counts for document types" do
mock_tagged_content = mocked_tagged_content
document_count = document_type_count(mock_tagged_content)
expect(document_... |
require 'spec_helper'
describe EventsController do
let!(:user) { User.create!(name: 'Test User') }
def valid_params
{
title: 'My Event Title',
location: 'My Event Location',
description: 'My Event Description',
date: Date.today,
user_id: user.id
}
end
def invalid_params
... |
require File.dirname(__FILE__) + '/../spec_helper'
describe "domain parser" do
before(:all) do
@domain_parser = Domainatrix::DomainParser.new("#{File.dirname(__FILE__)}/../../lib/effective_tld_names.dat")
end
describe "reading the dat file" do
it "creates a tree of the domain names" do
@domain_par... |
ActiveAdmin.register Address do
belongs_to :discount
permit_params :id, :address, :latitude, :longitude, :discount_id
end
|
module GameStatistics
def highest_total_score
games_goal_totals(games).max
end
def lowest_total_score
games_goal_totals(games).min
end
def percentage_home_wins
home_games = select_by_key_value(game_teams, :hoa, 'home')
won_home_games = select_by_key_value(home_games, :result, 'WIN')
(w... |
class Fighter < ApplicationRecord
validates :first_name, presence: true
validates :last_name, presence: true
def to_s
first_name + ' ' + last_name
end
end
|
# #subexpressions returns an array: index 0 and 2 are the flanking subexpressions, while index 1 is the value of the node-to-be. Just as in the structure of the binary tree, a node is atomic if the flanking expressions are nil.
def subexpressions(str)
if next_sub(str, 0) == [0, str.length - 1] # If there are outer par... |
require 'rails_helper'
feature 'user lands in home page' do
scenario 'successfully' do
visit '/'
expect(page).to have_current_path(root_path)
end
end
|
# frozen_string_literal: true
require 'rspec'
require_relative '../lib/github_score'
require_relative '../lib/event_fetcher'
RSpec.describe GithubScore do
let(:github_score) { GithubScore.new('test_handle') }
let(:events) do
[
{ type: 'PushEvent' },
{ type: 'IssuesEvent' }
]
end
describe ... |
class DirectoriesController < ApplicationController
before_filter :auth_user!
def auth_user!(opts = {})
if :admin_user_signed_in?
:authenticate_admin_user!
else
:authenticate_user!
end
end
# GET /directories
# GET /directories.json
def index
@directories = current_user.direc... |
class RemoveInvoice930FromQuotations < ActiveRecord::Migration
def change
Quotation.destroy_all :invoice_number => 930
end
end
|
require 'cgi'
require 'net/https'
require 'json'
unless defined? Net::HTTP::Patch
# PATCH support for 1.8.7.
Net::HTTP::Patch = Class.new(Net::HTTP::Post) { METHOD = 'PATCH' }
end
module GHI
class Client
class Error < RuntimeError
attr_reader :response
def initialize response
@response,... |
module CamaleonCms
module Apps
class ThemesAdminController < CamaleonCms::AdminController
before_action :init_theme
private
def init_theme
theme_name = params[:controller].split('/')[1]
@theme = current_theme
return render_error(404) unless current_theme.slug == theme_n... |
# frozen_string_literal: true
class RootController < AuthenticatedController
# GET /
def index
@projects = Project.includes(:boards).paginate(page: params[:page])
.order(:created_at)
end
end
|
class CreateAdvisorHasSubjects < ActiveRecord::Migration[5.2]
def change
create_table :advisor_has_subjects do |t|
t.references :advisor, foreign_key: true, null: false
t.references :subject, foreign_key: true, null: false
t.timestamps
end
end
end
|
class User < ApplicationRecord
has_many :ideas, lambda { order(created_at: :desc) }, dependent: :destroy
has_many :reivews, lambda { order(created_at: :desc) }, dependent: :destroy
has_secure_password
validates :email, presence: true, uniqueness: true,
format: /\A([\w+\-].?)+@[a-z\d\-]+(\.[a-z]+)*\.... |
# -*- encoding : utf-8 -*-
class OpenSAPConnector < AbstractXikoloConnector
NAME = 'openSAP'
ROOT_API = 'https://open.sap.com/api/'
COURSE_LINK = 'https://open.sap.com/courses/'
end
|
# frozen_string_literal: true
module Tinkoff
class CurrencyRates < Base
attr_reader :rate
def call
rates.each do |rate|
@rate = rate
next unless valid_currency?
create_currency_rates
rescue StandardError => e
puts "Message - #{e}; rate - #{rate}"
end
en... |
Gem::Specification.new do |s|
s.name = 'steam-condenser'
s.author = "Sebastian Staudt"
s.email = "koraktor@gmail.com"
s.summary = "Steam Condenser - A Steam query library"
s.description = %{A multi-language library for querying the Steam Community, Source, GoldSrc servers and Steam master servers}
s.homepag... |
require 'spec_helper.rb'
describe User do
#Assoziationen testen
it "user has_many nachrichtens" do
user = User.reflect_on_association(:nachrichtens)
user.macro.should == :has_many
end
it "user has_many nachrichts" do
user = User.reflect_on_association(:nachrichts)
user.macro.should == :has_many
end
i... |
# frozen_string_literal: true
module Zafira
module Models
class ZafiraStatus
attr_accessor :available
end
class ZafiraStatus
class Builder
AVAILABLE_STATUS = 200
def initialize(response)
self.response = response
end
def construct
return n... |
# Module that can be included (mixin) to take and output Yaml data
require 'yaml'
require 'csv'
module YamlBuddy
def take_yaml(yaml)
@data = YAML.safe_load(yaml)
end
def to_yaml
@data.to_yaml
end
end
|
class CollectionsController < ApplicationController
def index
@collections = current_user.collections.uniq
respond_to do |format|
format.html { render :index }
format.json { render json: @collections }
end
end
def new
@collection = Collection.new
end
def create
@coll... |
# frozen_string_literal: true
module MineSweeper
class Solve < ApplicationService
def initialize(map = [])
@map = map.freeze
@last_row = @map.size - 1
@last_col = @map.first.size - 1
end
def call
(0..@last_row).each_with_object(@map.dup.map(&:dup)) do |j, solved_map|
@adj... |
# frozen_string_literal: true
require 'test_helper'
module Vedeu
module Coercers
describe Colour do
let(:described) { Vedeu::Coercers::Colour }
let(:instance) { described.new(_value) }
let(:_value) {}
let(:klass) { Vedeu::Colours::Colour }
describe '#initialize' do
... |
class RegisteredApplicationsController < ApplicationController
before_action :authenticate_user!
def index
@registered_applications = RegisteredApplication.where(user_id: current_user.id)
end
def show
@registered_application = RegisteredApplication.find(params[:id])
@events = @registered_applicati... |
Pod::Spec.new do |s|
s.name = 'PicoKit'
s.version = '0.8.0'
s.summary = 'A light Web Service client framework targeting iOS platform.'
s.homepage = 'https://github.com/maxep/PicoKit'
s.author = { "William Yang" => "http://bulldog2011.github.io/",
... |
module Mutations
class CreateUser < Mutations::BaseMutation
#User args
argument :email, String, required: true
argument :username, String, required: true
argument :password, String, required: true
argument :name, String, required: true
argument :phone_number, String, required: true
#Addres... |
require File.join(File.expand_path(File.dirname(__FILE__)), '..', 'test_helper')
class ArchiverTest < ActiveSupport::TestCase
def teardown
FileUtils.rm_rf(File.join(Rails.root, 'tmp', 'videos'))
end
test "should skip screenshots" do
config = CONFIG['archiver_skip_hosts']
CONFIG['archiver_skip_host... |
# frozen_string_literal: true
require "beyond_api/utils"
module BeyondApi
class PickupOptions < Base
include BeyondApi::Utils
#
# A +GET+ request is used to list all pickup options of the shop in a paged way.
#
# $ curl 'https://api-shop.beyondshop.cloud/api/pickup-options' -i -X GET \
# ... |
class Post < ApplicationRecord
include MultipleMan::Subscriber
subscribe fields: [:token]
def self.total
tokens = Post.all.pluck(:token).sort
{
total: tokens.count,
duplicate: tokens.count - tokens.uniq.count,
missing: missing(tokens)
}
end
def self.missing(tokens)
r... |
class ChangeColumnToBookmarkedAnime < ActiveRecord::Migration[5.2]
def change
rename_column :bookmarked_animes, :bookmark_id, :user_id
end
end
|
# == Schema Information
#
# Table name: contact_messages
# id :integer not null primary key
# name :string
# email :string
# message :text
# read :boolean
# created_at :datetime
# updated_at :datetime
requi... |
#
# Author:: Matt Eldridge (<matt.eldridge@us.ibm.com>)
# © Copyright IBM Corporation 2014.
#
# LICENSE: MIT (http://opensource.org/licenses/MIT)
#
module Fog
module Softlayer
class Network
class Mock
def get_portable_subnet_package_id(address_space)
address_space.downcase!; err_msg = "... |
module Rosarium
class Promise < SimplePromise
DEFAULT_ON_FULFILL = Proc.new {|value| value}
DEFAULT_ON_REJECT = Proc.new {|reason| raise reason}
def self.resolve(value)
if value.kind_of? Promise
return value
end
deferred = defer
deferred.resolve(value)
deferred.pr... |
require 'sshkit/dsl'
module SSHKit
module DSL
def on(hosts, options = {}, &block)
if hosts.is_a?(Hash)
root_user = hosts[:options][:root_user]
options[:root_user] = root_user unless root_user && options[:root_user].to_s == "no"
hosts = hosts[:servers]
end
Coordin... |
# 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... |
## To do: Implement CSV reading/writingi
require 'csv'
require 'pp'
class ContactDatabase
class << self
def list
CSV.foreach('contacts.csv') { |row| puts "#{row[0]} (#{row[1]}) (ID:# #{row[2]}) #{row[3]}" }
end
def all
CSV.open('contacts.csv').readlines
end
def size
CSV.open('... |
# Take a file id and delete all hathi_x attribute records, and then all hathi_gd records associated with that file id.
require 'htph';
require 'set';
file_id = ARGV.shift;
if file_id.nil? then
raise "Need a file_id as 1st arg.";
end
db = HTPH::Hathidb::Db.new();
conn = db.get_conn();
attribute_table_select_sql = ... |
require 'rails_helper'
describe PagesController do
let(:user) { create(:user) }
before(:each) do
sign_in user
end
describe "GET about_us" do
it "Should render about_us page" do
get :about_us
expect(response).to render_template :about_us
end
end
end |
require 'test_helper'
class AuthenticationTest < ActionDispatch::IntegrationTest
setup do
@user = create(:user)
end
test "supply no credentials to a protected resource" do
authenticate
assert_response :unauthorized
end
test "use an Oauth access token" do
access = create(:oauth_access_token,... |
require_relative '../../spec/spec_helper'
Test 'Which' do
Scenario 'Should show all TV with screen size 32",Full HD resolution, feature Smart TV, retailer Tesco Direct' do
Which "Begin" do
Step 'Go to home page' do
goto_homepage
end
Step 'Validate url' do
validate_homepage_url... |
require File.dirname(__FILE__) + '/../../spec_helper'
describe "/users/new.html.haml" do
fuzzy :users
include UsersHelper
before(:each) do
# @user = mock_model(User)
# @user.stub!(:new_record?).and_return(true)
# @user.stub!(:full_name).and_return("MyString")
# @user.stub!(:email).and_return(... |
class Api::ActivePollsController < ApplicationController
def create
@active_poll = ActivePoll.new(active_poll_params)
if @active_poll.save
render 'api/active_polls/index'
else
render json: @active_poll.errors.full_messages, status: 422
end
end
def update
question = Question.find(... |
class Post < ApplicationRecord
include PgSearch
extend FriendlyId
validates :title, :author, :body, presence: true
has_many :comments, dependent: :destroy
friendly_id :title, use: :slugged
pg_search_scope :search,
against: %i[title author body],
associated_against: { comments: %i[body] }
end
|
require_relative '../lib/anagram'
describe "anagram" do
let(:anag){Anagram.new("Looter")}
let(:notfind){Anagram.new("notfind")}
let(:dict){["RETOOL", "ROOtlE", "TooLER", "NoT", "RELATED","TO", "123", "000", "Looter"]}
it "sort every words and make them lowcases" do
anag.formalizsel... |
class ChangeTypeToSocialTypeInBandSocials < ActiveRecord::Migration[6.1]
def change
rename_column :band_socials, :type, :social_type
end
end
|
name "avahi-daemon"
maintainer "Gerald L. Hevener Jr., M.S."
maintainer_email "jackl0phty@gmail.com"
license "Apache 2.0"
description "Installs/Configures avahi-daemon"
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version "0.0.16"
depends "iptables"
|
class ReviewsController < ApplicationController
protect_from_forgery :except => 'new_batch_from_transcript'
def show
force_login(request.fullpath) && return if @current_user.nil?
if params[:id].to_i.nil?
not_found
end
# raises RecordNotFound exception if not found
@review = Review.find(pa... |
# frozen_string_literal: true
module FeatureMacros
module Session
def sign_in(user)
visit '/'
click_link 'Login'
fill_in 'email', with: user.email
fill_in 'password', with: user.password
click_button 'Log In'
expect(page).to have_link 'Logout'
end
end
end
RSpec.configur... |
require 'rails_helper'
describe BatchesController do
before :each do
login_as_admin
end
shared_examples_for "with or without ticket kinds" do
# FIXME really
end
describe "with ticket kinds" do
it_should_behave_like "with or without ticket kinds"
before :each do
@ticket_kinds = [crea... |
# palindromic_substrings.rb
# Write a method that returns a list of all substrings of a string that are
# palindromic. That is, each substring must consist of the same sequence of
# characters forwards as it does backwards. The return value should be
# arranged in the same sequence as the substrings appear in the strin... |
FactoryGirl.define do
factory :social_info do
twitter_name "@foobar1234"
facebook_page_url "http://www.facebook.com"
web_url "http://www.fanzo.me"
hash_tags "#fanzo"
youtube_url "http://www.youtube.com/user/FanzoFans"
end
end |
class PlayerStatistic < ActiveRecord::Base
attr_accessible :max_rating,
:leaves,
:modify_date,
:losses,
:rating,
:wins,
:stat_summary_type,
:total_minion_kills,
:total_neutra... |
#!/usr/bin/ruby
require '../lib/load_lib.rb'
infile = ARGV[0] || 'input.txt'
memory = File.readlines(infile)[0].strip.split(',').map(&:to_i)
100.times do |noun|
100.times do |verb|
memory[1] = noun
memory[2] = verb
vm = Intcode::Interpreter.new(memory)
vm.run
if vm.memory_read(0) == 19690720
... |
class Role < ActiveRecord::Base
has_many :user_roles, dependent: :destroy
has_many :users,through: :user_roles
SUPER_ADMIN = 'super_administrator'
ADMIN = 'administrator'
# WAREHOUSE = 'warehouse'
# REPORT = 'report'
# CUSTOMER_SERVICE = 'customer_service'
R... |
FactoryGirl.define do
factory :artist do
name { Faker::name }
remote_image_url { Faker::Internet.url }
# name "MyString"
# remote_image_url "MyString"
end
end
|
class CommentsController < ApplicationController
def create
@comment = Comment.new(param_comment)
@article = Article.find(@comment.article_id)
if @comment.save
redirect_to article_path(@article), :notice => "Create new comment success."
else
redirect_to artic... |
class SessionsController < ApplicationController
def create
# 'auth' gets entire request from omniauth callback
auth = request.env["omniauth.auth"]
# extra info isn't necessary, so using except method and set to the variable 'session[:omniauth]'
session[:omniauth] = auth.except('extra')
# path th... |
require 'fileutils'
namespace :sidebar do
desc 'Install the default skeleton sidebar dir structure'
task :install do
sidebar_path = File.join(RAILS_ROOT,"app/views/sidebars")
global_sidebar = File.join sidebar_path, "_global.html.erb"
FileUtils.mkdir_p sidebar_path
File.open(global_sidebar, "w+") d... |
class ProductsController < ApplicationController
def index
#NOTE: search/find by category_name is temporary.
#When Category navBar is amended to use Category Model then category.id will be known and passed to Products.
if params[:category_name] == "Audio" || params[:category_name] == "TV... |
require '../intcode/intcode'
input = File.read("input").split(",").map(&:to_i)
class PaintRobot
BLACK = 0
WHITE = 1
LEFT = 0
RIGHT = 1
DIR_UP = 0
DIR_RIGHT = 1
DIR_DOWN = 2
DIR_LEFT = 3
attr_reader :panels
def initialize(input, start_color = nil, start_x = 0, start_y = 0, start_dir = PaintRobo... |
class RenameColumnNameInVotes < ActiveRecord::Migration[5.0]
def change
rename_column :votes, :type, :vote_type
end
end
|
require 'spec_helper'
require 'erb'
include ERB::Util
describe "Companys" do
describe "GET route tests" do
before do
@company = FactoryGirl.create(:company)
end
describe "GET #search" do
context "for existing company" do
it "returns success (200)" do
@uri = "/company/search/... |
require 'test_helper'
class MactansControllerTest < ActionDispatch::IntegrationTest
setup do
@mactan = mactans(:one)
end
test "should get index" do
get mactans_url
assert_response :success
end
test "should get new" do
get new_mactan_url
assert_response :success
end
test "should cre... |
require 'open3'
module ShelloutTypes
class Chroot
@@chroot_dir=''
def self.chroot_dir=(dir)
@@chroot_dir = dir
end
def initialize(dir=nil)
if !dir.nil?
@chroot_dir = dir
end
end
def run(*cmd)
stdout, stderr, status = Open3.capture3('sudo', 'chroot', chroot_d... |
class CheckoutStripe
def initialize(token, cart, user)
@token = token
@cart = cart
@user = user
end
def charge
create_customer
charge_customer
end
private
def create_customer
@customer = Stripe::Customer.create(
email: 'example@stripe.com',
card: @token
)
end
... |
require 'spec_helper'
describe 'ohmyzsh::user', :type => 'define' do
context "On a Debian OS with no package name specified" do
context 'non root user' do
let(:title) { 'someuser' }
let(:params) { { :home => "/home/#{title}" } }
it { should contain_exec "chsh -s /usr/bin/zsh #{title}" }
i... |
Pod::Spec.new do |s|
s.name = "MySdk-native"
s.version = "1.3"
s.summary = "MySdk-native"
s.description = "MySdk-native react native SDK"
s.homepage = "https://github.com/ozcanzaferayan"
s.license = "MIT"
s.author = { "Zafer AYAN" => "ozcanzaferayan@gmail.com" }
s.pl... |
require 'test_helper'
class MissionsControllerTest < ActionDispatch::IntegrationTest
setup do
@mission = missions(:one)
end
test "should get index" do
get missions_url
assert_response :success
end
test "should get new" do
get new_mission_url
assert_response :success
end
test "shoul... |
require 'rails_helper'
RSpec.describe 'admin merchants edit (/admin/merchants/merchant_id/edit)' do
let!(:merchant1) { create(:enabled_merchant) }
let!(:merchant2) { create(:enabled_merchant) }
let!(:merchant3) { create(:enabled_merchant) }
describe 'as an admin' do
context 'when I visit the admin merchan... |
class AddLayoutToEmailTemplates < ActiveRecord::Migration
def change
add_column :tr8n_email_templates, :layout, :string
add_column :tr8n_email_templates, :version, :integer
add_column :tr8n_email_templates, :state, :string
end
end
|
class Card < ApplicationRecord
validates :card_token,presence: true
belongs_to :user
end
|
Koala.configure do |config|
config.app_id = ENV.fetch('FACEBOOK_API_ID')
config.app_secret = ENV.fetch('FACEBOOK_SECRET')
config.api_version = "v6.0"
end
|
require './avalanche_calculator'
RSpec.describe AvalancheCalculator do
describe "#call" do
let(:sum) { 15_000 }
let(:first_loan) do
{
title: 'Loan #1',
payment: 3_800,
percent: 10,
amount: 23_000
}
end
let(:second_loan) do
{
title: 'Loan #2',
... |
class AddTraineeFlagToUser < ActiveRecord::Migration[5.1]
def change
add_column :users, :trainee, :boolean, default: true
add_column :users, :trainer, :boolean, default: false
end
end
|
class ResturantsController < ApplicationController
before_filter :current_user, only: [:destroy, :create, :new, :edit, :update]
# GET /resturants
# GET /resturants.json
def index
@resturants = Resturant.all
respond_to do |format|
format.html # both.html.erb
format.json { render json: @res... |
def default_seat_chart
all_seats = ['A', 'B'].product((1..5).to_a).map(&:join)
all_seats.inject(Hash.new) do |m,s|
m[s] = true
m
end
end
class Show
attr_accessor :name, :performances
attr_accessor :last_modified
def initialize(name, performances = [])
@name = name
@performances = performan... |
module Rubinius
module AST
class ArrayLiteral < Node
attr_accessor :body
def initialize(line, array)
@line = line
@body = array
end
def children
@body
end
def bytecode(g)
@body.each do |x|
x.bytecode(g)
end
g.make_ar... |
class CapistranoDeploy
attr_accessor :server
# Called when cruisecontrol starts and loads the plugin
def initialize(project = nil)
@server = ""
@project = project
end
# Runs when a build is finished (checkout, tests etc;)
def build_finished(build)
# If server isn't defined or the build fails
... |
# 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 rake db:seed
# (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Ema... |
class AddFrameNameForkTypeKcOrCbToBike < ActiveRecord::Migration[5.0]
def change
add_column :bikes, :frame_name, :string
add_column :bikes, :fork_type, :string
add_column :bikes, :tire_type, :string
end
end
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.