text stringlengths 10 2.61M |
|---|
# frozen_string_literal: true
module Vedeu
module Renderers
# Converts a grid of {Vedeu::Cells} objects or
# {Vedeu::Cells::Char} objects into a stream of characters without
# escape sequences.
#
# @api private
#
class Text < Vedeu::Renderers::File
include Vedeu::Renderers::Optio... |
require 'digest/sha1'
require 'bcrypt'
class User
include MongoMapper::Document
# info
key :email, String, :required => true
key :name, String, :required => true
key :signature, String
# stats
key :topics_count, Integer, :default => 0
key :posts_count, Integer, :default => 0
... |
class Boat < ApplicationRecord
has_many :assignments
has_many :timeslots, through: :assignments
end
|
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
# There are probably better ways to hook into "vagrant up", haven't had
# any problems with this yet, but please do contribute if you do.
if ARGV.first == "up"
# Yo... |
module Torque
module PostgreSQL
module Associations
module Association
def inversed_from(record)
return super unless reflection.connected_through_array?
self.target ||= []
self.target.push(record) unless self.target.include?(record)
@inversed = self.target.p... |
class ReviewsController < ApplicationController
before_action :set_article
def create
@review = Review.new(review_params)
@review.article = @article
@review.user = current_user
if @review.save # Valid inputs
respond_to do |format| # Get input from html or js
format.html { redirect_to ... |
require "test_helper"
class AddressTest < ActiveSupport::TestCase
setup do
@customer = customers(:one)
end
test "test save address" do
address = Address.new
address.customer_id = @customer.id
address.first_name = "Yunus Erdem"
address.last_name = "Sıhhatlı"
address.phone = "(530) 123 45 ... |
case node['platform']
when "ubuntu"
apt_repository "redis-server" do
uri 'http://ppa.launchpad.net/chris-lea/redis-server/ubuntu'
distribution node['lsb']['codename']
components ['main']
keyserver "keyserver.ubuntu.com"
key "C7917B12"
action :... |
module RackRabbit
class Response
#--------------------------------------------------------------------------
attr_reader :status, :headers, :body
def initialize(status, headers, body)
@status = status
@headers = headers
@body = body
end
#----------------------------------... |
#!/usr/local/bin/ruby -w
require "graphics"
class Ball < Graphics::Body
COUNT = 50
G = V[0, -18 / 60.0]
attr_accessor :g
def initialize w
super
self.a = rand 180
self.m = rand 100
self.g = G
end
def update
fall
move
bounce
end
def fall
self.velocity += g
end
... |
class ChangeColumnTypeForPrice < ActiveRecord::Migration
def change
change_column :purchase_options, :price, :decimal, precision: 8, scale: 2
end
end
|
class New < ApplicationRecord
has_attached_file :image, :styles => {
:thumb => '600x350>'
}
validates_attachment :image, :presence => true,
:content_type => { :content_type => /\Aimage\/.*\Z/ },
:size => { :in => 0..10.megabytes }
def next
New.where("n... |
require 'reggie/version'
require 'reggie/definition_proxy'
require 'reggie/pattern'
require 'reggie/patterns'
require 'reggie/match'
require 'byebug'
module Reggie
@registry = {}
def self.registry
@registry
end
def self.define(&block)
definition_proxy = DefinitionProxy.new
definition_proxy.instan... |
class AddUserIdToRoads < ActiveRecord::Migration
def change
add_column :roads, :user_id, :integer
end
end
|
require 'rails_helper'
RSpec.describe Version, type: :model do
describe 'validations for version' do
it { should validate_presence_of(:version_code) }
it { should validate_numericality_of(:version_number).only_integer }
end
end
|
# -*- coding: utf-8 -*-
class Meeting < ApplicationRecord
acts_as_paranoid
has_many :atendee
has_many :presenter
def view_title_times
self.title + '(第' + self.times.to_s + '回)'
end
validates :title, presence:true
validates :title, uniqueness: {scope:[:times]}
validates :times, presence:true
vali... |
require 'setup_tests'
class WindowsCoreTest < BaseTestSetup
context 'a Windows target' do
setup do
@connector = @target.connector = WMIConnector.new(@host, {})
@target.stubs(:target_profiler).returns(Profilers::WindowsCore)
@target.force_profiler_to(Profilers::WindowsCore)
@profiler = @ta... |
# == Informacion de la tabla
#
# Nombre de la tabla: *dbm_biblioteca_glosario*
#
# idGlosario :integer(11) not null, primary key
# idDescriptorGenerico :integer(11) not null
# concepto :string(255)
# definicion :text
#
# Tiene una relacion de un *Descripto... |
module VagrantPlugins
module GuestLinux
class Plugin < Vagrant.plugin("2")
guest_capability("linux", "change_host_name") do
Cap::ChangeHostName
end
guest_capability("linux", "configure_networks") do
Cap::ConfigureNetworks
end
end
end
end
Vagrant.configure(2) do |con... |
module Unimatrix::Authorization
class Railtie < Rails::Railtie
initializer "unimatrix.authorization.configure_controller" do | app |
ActiveSupport.on_load :action_controller do
include Unimatrix::Authorization
end
end
end
def retrieve_policies( resource_name, access_token, realm_uuid... |
require 'test_helper'
require 'roman_number'
describe RomanNumber do
describe 'when input string is valid' do
describe '#valid?' do
it 'returns true' do
RomanNumber.new('CDXX').valid?.must_equal true
end
end
end
describe 'when input string is Invalid' do
it 'must fail when roman ... |
class CostAssumption < ActiveRecord::Base
belongs_to :property
has_many :cost_items, as: :costable, dependent: :destroy
accepts_nested_attributes_for :cost_items, allow_destroy: true
validates :purchase_price, :down_payment, presence: true, numericality: { greater_than: 0 }
def build_default_cost_items
... |
class AddAdjectiveToCities < ActiveRecord::Migration
def change
add_column :cities, :adjective, :string
end
end
|
class ClassWorkoutSerializer < ActiveModel::Serializer
attributes :id
has_one :workout_plan
has_one :gym_class
end
|
class Api::V1::WebsitesController < ApplicationController
def basin_map
@basin_map = Website.basinmap.first
if !@basin_map
render :json => {:error => I18n.t("messages.not_found"), :success => 0}, :status => :ok
end
end
def crf
@crf = Website.crf.first
if !@crf
render :json => {:e... |
class FacebookWrapper
attr_reader :client
def initialize(auth_token)
@client = Koala::Facebook::API.new(auth_token)
end
def get_friends
client.get_connections("me", "friends")
end
end |
module Api
module Models
module Recoverable
extend ActiveSupport::Concern
def self.required_fields(klass)
[:reset_password_sent_at, :reset_password_token]
end
included do
before_update :clear_reset_password_token, if: :clear_reset_password_token?
end
# Update... |
require 'jbuilder'
require_relative 'log_formatter_base'
require_relative 'string'
module RTALogger
# json formatter which receive log_record and
# returns it's data as json string
class LogFormatterJson < LogFormatterBase
def format(log_record)
return '' unless log_record
jb = Jbuilder.new do ... |
# == Schema Information
#
# Table name: articles
#
# id :integer not null, primary key
# title :string not null
# author :string
# body :text
# created_at :datetime not null
# updated_at :datetime not null
# slug :string
# old_slug :string
#
cla... |
class ImageFile
def self.remove(file)
if CloudinaryReady.up?
Cloudinary::Uploader.destroy(file.public_id) if file.respond_to?(:public_id)
else
file_path = file.path
File.delete(file_path) if File.exist?(file_path)
end
end
def self.asset(file)
Rails.root.join('spec', 'support', '... |
class Libmemcached < Formula
desc "C and C++ client library to the memcached server"
homepage "http://libmemcached.org/"
url "https://launchpad.net/libmemcached/1.0/1.0.18/+download/libmemcached-1.0.18.tar.gz"
sha256 "e22c0bb032fde08f53de9ffbc5a128233041d9f33b5de022c0978a2149885f82"
revision 2
bottle do
... |
class Buy < ApplicationRecord
# アソシエーションの定義
has_one :purchase_historys
end
|
json.array!(@licence_people) do |licence_person|
json.extract! licence_person, :id, :licence_id, :person_id, :old_lastname, :is_teacher, :is_staffteacher, :is_student, :is_postgrad, :details
json.url licence_person_url(licence_person, format: :json)
end
|
describe "Store" do
before(:each) do
@buyer = User.create(:name => "Aaron Bodkin")
@cart = Cart.create(:buyer_id => @buyer.id)
@seller = User.create(:name => "Patricia Morris")
@store = Store.create(:seller_id => @seller.id, :name => "Lovin' Knit", :description => "a locally sourced organic knit sho... |
class PasswordEncryptor
def self.encryptor
BCrypt::Password
end
def self.encrypt(password)
encryptor.create(password)
end
def self.valid?(password_hash, password)
encryptor.new(password_hash) == password
end
end |
class Referral < ApplicationRecord
belongs_to :sponsor, class_name: "User", inverse_of: :downstream_referrals
belongs_to :referred_user, class_name: "User", inverse_of: :upstream_referral
belongs_to :event_claimed, class_name: "Event", required: false
validate :paid_4_events_before_claiming?... |
# Problem 205: Dice Game
# http://projecteuler.net/problem=205
# Peter has nine four-sided (pyramidal) dice, each with faces numbered 1, 2, 3, 4.
# Colin has six six-sided (cubic) dice, each with faces numbered 1, 2, 3, 4, 5, 6.
#
# Peter and Colin roll their dice and compare totals: the highest total wins. The resul... |
require 'test_helper'
module KanbanBoard
class ProjectTest < ActiveSupport::TestCase
def setup
@project = Project.new
@project2 = Project.new(name: "First project", description: "Project for testing", finishing_date: Date.today)
end
def teardown
Project.destroy_all
end
#validati... |
require 'rails_helper'
describe 'Bills:', type: :request do
let(:token) {"3f898544c32fe878e46e40e7186364a5"}
let(:authenticated_headers) {
LauraSpecHelper.ios_device.update 'X-AUTHENTICATION' => token
}
let(:authenticated_device) {
{
'1111111' => {
platform: 'IOS',
app_name: 'La... |
class Quote
attr_accessor :name, :ticker, :time, :price
def initialize(attributes = {})
@name = attributes[:name]
@ticker = attributes[:ticker]
@time = attributes[:time]
@price = attributes[:price]
end
def formatted_wuote
"#{@ticker}: #{@price} <#{@time}>"
end
end |
class Question < ActiveRecord::Base
belongs_to :user
has_many :answers
has_many :votes, as: :votable
validates :title, presence: true
validates :body, presence: true
end
|
class IngredientsController < ApplicationController
def dogpaw
@ingredients = Ingredient.order(name: :asc).first(15)
end
def snaketongue
@ingredient = Ingredient.new(ingredient_params)
@ingredient.save
end
private
def ingredient_params
params.require(:ingredient).permit(:name)
end
end
|
# frozen_string_literal: true
module Api::V1::Admin
class UsersController < ::Api::V1::Admin::BaseController
IMPLEMENT_METHODS = %w[index show create update destroy destroy_bulk].freeze
def create
super do |m|
m.failure(:create) do
head 409
end
end
end
end
end
|
class AddLineStringToRoads < ActiveRecord::Migration
change_table :roads do |t|
t.line_string :path, :srid => 4326
t.index :path, :spatial => true
end
end
|
module SmsMock
module Matchers
RSpec::Matchers.define :have_body do |body|
match do |message|
message.body == body
end
end
RSpec::Matchers.define :be_sent_from do |from|
match do |message|
message.from == from
end
end
RSpec::Matchers.define :be_sent_to do ... |
class V1::OrdersController < ApplicationController
before_action :authenticate_user!
# GET /orders
def index
@orders = current_account.orders
render json: @orders
end
# GET /orders/:id
def show
@order = current_account.orders.find(params[:id])
render json: @order
end
# POST /orders
... |
class Card
attr_accessor :suit, :value
def initialize(suit, value)
@suit = suit
@value = value
end
def value
if ["J", "Q", "K"].include? @value
return 10
elsif @value == "A"
return 11
else
return @value
end
end
def to_s
[suit,value].join('-')
end
end
clas... |
require "spec_helper"
feature "View selected proposals" do
let!(:accepted_b) { create(:proposal,:selected,title: "B",position: 2) }
let!(:accepted_a) { create(:proposal,:selected,title: "A",position: 1) }
let!(:unaccepted) { create(:proposal,title: "C") }
it "shows correct proposals in order" do
visit sel... |
class CreateAnnexeds < ActiveRecord::Migration[5.2]
def change
create_table :annexeds do |t|
t.belongs_to :examination, index: true
t.datetime :date
t.string :title
t.string :description
t.string :city
t.string :address
t.datetime :start_hour
t.datetime :end_hour
... |
class Library < ApplicationRecord
self.table_name = 'libraries'
after_initialize :init
belongs_to :user, class_name: 'User', required: false
belongs_to :partner, class_name: 'Partner', required: false
validates :key, :url, presence: true
def self.create_by_manual(key, current_resource)
lib = new(key... |
require 'rails_helper'
feature 'Home Page' do
include_context 'custom products'
let(:home_page) { HomePage.new }
before do
home_page.load
end
scenario 'enters home page' do
expect(home_page.product_permalinks).to include('ruby-on-rails-mug', 'ruby-on-rails-tote')
end
scenario 'clicks on a pro... |
class CreateCoursesOrganizers < ActiveRecord::Migration
def change
create_table :courses_organizers, id: false do |t|
t.integer :course_id, null: false
t.integer :organizer_id, null: false
end
add_index :courses_organizers, [:course_id, :organizer_id]
end
end
|
class User < ActiveRecord::Base
has_many :likes, dependent: :destroy
after_destroy :log_destroy_action
after_update :log_update_action
after_create :log_create_action
scope :order_by_id, -> {order(id: :asc)}
scope :likes, -> {find_by_sql("SELECT users.id, name, user_id AS 'like_from_user_i... |
require 'thor'
module CloudConductorCli
module Models
module Base
include Helpers::Record
include Helpers::Input
include Helpers::Outputter
def self.included(klass)
if klass.respond_to?(:superclass) && klass.superclass == Thor
klass.class_option :host, aliases: '-H', ty... |
RESOURCES_PATH = File.expand_path(File.join(File.dirname(__FILE__), 'resources'))
ENV['SSL_CERT_FILE'] = File.join(RESOURCES_PATH, 'cacert.pem')
require 'rexml/document'
# Load the JRuby Open SSL library unless it has already been loaded. This
# prevents multiple handlers using the same library from causing problems... |
require 'journey_walker'
require 'sinatra/base'
require 'slim'
module JourneyWalkerWeb
# This sinatra app can be created with a journey and will automatically use slim templates defined under
# /templates with the same name as the states in the journey
class Sinatra < Sinatra::Base
def initialize(parameters ... |
require 'spec_helper'
describe HalPresenters::Helpers::Rootify do
let(:hash){
{
"_links" => {
"href" => "/foo",
"href-template" => "/foo",
"nested" => {"href" => "/bar"},
"nested_template" => {"href-template" => "/bar"},
"deep_nested" => {"href" => {"href" => "/quux"}... |
class SessionsController < ApplicationController
include SessionsHelper
def new
end
def create
user = User.authenticate(params[:session][:email], params[:session][:password])
if user
session[:user_id] = user.id
redirect_to :controller => 'lancamentos', :action => 'index', :notice => "Logged... |
print 'What is the bill? '
bill = gets.chomp.to_f
print 'What is the tip percentage? '
tip = gets.chomp.to_f
tip /= 100
tip_total = bill * tip
bill += tip_total
puts 'The tip is $' + tip_total.to_s
puts 'The total is $' + bill.to_s
# Second time through:
# print "What is the bill? "
# bill = gets.chomp.to_f
# pr... |
# This class is for controlling the actions of user.
# class UsersController
class UsersController < ApplicationController
before_action :require_same_user, only: %i[edit update destroy]
before_action :require_admin, only: %i[destroy]
def index
@users = User.paginate(page: params[:page], per_page: 3).order('... |
class CreatePlans < ActiveRecord::Migration[6.0]
def change
create_table :plans do |t|
t.date :date, null: false
t.text :schedule
t.integer :alcohol_amount_plan
t.integer :small_beer
t.integer :large_beer
t.integer :japanese_sake
t.integer :wine
t.integer :shochu
... |
module HolidaysHelper
def parse_date_range(date_range)
dates = date_range.split(' - ')
start_date = Date.parse(dates[0])
end_date = Date.parse(dates[1])
return [start_date] if start_date == end_date
(start_date..end_date).to_a
end
def is_weekend?(date)
date.saturday? || date.sunday?
... |
require 'rails_helper'
describe "New paper page", type: :feature do
it "should render withour error" do
visit new_paper_path
end
it "should have a text input field for the title, venue and year" do
visit new_paper_path
expect(page).to have_field('paper[title]')
expect(page).to have_field('paper... |
$script = <<-SCRIPT
# Docker - это название открытой платформы для разработчиков и системных администраторов для создания, доставки и запуска распределенных приложений.
# С другой стороны, docker.io - это имя пакета, который вы устанавливаете в своей ОС Linux (т.е. Ubuntu).
sudo apt install docker.io -y # у... |
require_relative 'bank_account'
RSpec.describe BankAccount do
before(:each) do
@bank_account1 = BankAccount.new
end
it 'Has a getter method for retrieving the checking account balance' do
expect(@bank_account1.checking_balance).to eq(0)
end
it 'Has a getter method that retrieves ... |
# encoding: utf-8
# Core Hash class.
class Hash
# Converts self to a Node
# @return [Node] the converted Node
def to_node
Node.new.replace self
end
end
# A Node is a Hash with an array of children and a parent associated to it.
class Node < Hash
attr_reader :children
attr_accessor :parent
# Creates a ne... |
class Ride
attr_accessor :distance, :passenger, :driver
@@all = []
def initialize(distance, driver, passenger)
@distance = distance
@driver = driver
@passenger = passenger
@@all << self
end
def self.average_distance
total_distance = self.sum {|r| r.d... |
require_relative 'piece'
class SteppingPiece < Piece
KNIGHT_MOVES = [
[-1, 2],
[-1,-2],
[ 1,-2],
[ 1, 2],
[-2, 1],
[-2,-1],
[ 2, 1],
[ 2,-1]
]
KING_MOVES = [
[-1,-1],
[-1, 0],
[-1, 1],
[ 0,-1],
[ 0, 1],
[ 1,-1],
[ 1, 0],
[ 1, 1]
]
def initial... |
class Event
include DataMapper::Resource
property :id, Serial
property :startdate, Date
property :comment, String
belongs_to :user
validates_presence_of :startdate
def owner
user
end
def owner=(a_user)
self.user = a_user
end
def self.find_by_owner(user)
Event.all(:user => user)
end
d... |
require 'rails_helper'
RSpec.describe Reply, type: :model do
it { should belong_to(:sendee) }
it { should belong_to(:sub_request) }
it { should define_enum_for(:value) }
it { should validate_presence_of(:sendee_id) }
it { should validate_presence_of(:sub_request_id) }
startdatetime = Faker::Time.forward(... |
#!/usr/bin/env ruby
# Using Ruby's iterators slows this script down significantly, that's why both
# distance functions use for-loops.
def euclidiean_distance(v1, v2)
sum = 0
for i in 0..783
sum += ((v2[i] - v1[i]) ** 2)
end
Math.sqrt(sum)
end
def manhattan_distance(v1, v2)
sum = 0
for i in 0..783
... |
# https://docs.chef.io/inspec/resources/aws_s3_bucket/
describe aws_s3_bucket("my-bucket") do
it { should_not be_public }
it { should have_default_encryption_enabled }
it { should have_versioning_enabled }
end
|
require 'rails_helper'
describe CreditCard do
describe '#create'do
context 'クレジットカードで購入がうまくいかない場合'do
it "カード番号がない場合" do
card = FactoryBot.build(:credit_card, card_id: nil)
card.valid?
expect(card.errors[:card_id]).to include("を入力してください")
end
it "顧客のidがない場合" do
ca... |
require_relative 'journey.rb'
class JourneyLog
attr_reader :journey
attr_accessor :current
def initialize(journey = Journey)
@journey = journey
@journeys = []
end
def start(station)
@journeys << @current if @current != nil
@current = @journey.new
@current.start(station)
end
def fi... |
class StudentScraper
attr_accessor :urls
def scrape_all_urls
index_html = open("http://ruby007.students.flatironschool.com/")
index_doc = Nokogiri::HTML(index_html)
@urls = index_doc.search("h3 a").collect { |e| e['href'] }
end
def scrape_students
@urls.collect { |url| scrape_student(url) }
... |
class User < ApplicationRecord
has_many :messages
validates :name, presence: true, length: { in: 2..16 },
format: {
with: /\A[A-Za-z0-9\-\/\.\s]+\z/,
message: "may only consist of alphanumeric characters"
}
validates :color, presence: true, length: { is: 6 }
# Include default devise module... |
# typed: true
class AddFieldsToGltfModel < ActiveRecord::Migration[6.0]
def change
add_column :gltf_models, :bin_global_path, :text
add_column :gltf_models, :textures_directory_global_path, :text
end
end
|
class Picture < ActiveRecord::Base
validates :url, presence: true, uniqueness: true
belongs_to :tweet
belongs_to :post
enum kind: {serve: 0, maid: 1, other: 2}
def analyze
self.face_analyzing
self.update(:analyzed => true)
self.save!
end
def face_analyzing
api = DocomoAPI.new
self.... |
require File.dirname(__FILE__) + '/../../spec_helper'
describe Admin::BlogHelper do
dataset :users, :pages
before do
login_as :admin
@admin = users(:admin)
@admin.stub!(:blog_location).and_return('/parent')
helper.stub!(:current_user).and_return(@admin)
end
describe "valid_user_blog_location?(l... |
require 'backup/connection/dropbox'
module Backup
module Record
class Dropbox < Backup::Record::Base
def load_specific_settings(adapter)
end
private
def self.destroy_backups(procedure, backups)
dropbox = Backup::Connection::Dropbox.new
dropbox.static_initialize(procedure... |
# frozen_string_literal: true
# MapPosition
class MapPosition < ApplicationRecord
has_one_attached :image
end
|
class ContactsController < ApplicationController
before_action :set_contact, only: [:show, :edit, :update, :destroy]
before_filter :authenticate_user!
before_action :correct_user, only: [:show,:edit, :update]
def index
@contacts = Contact.all
end
def show
end
def new
@contact = Contact.ne... |
class Blague < ActiveRecord::Base
attr_accessible :content
validates_presence_of :content
belongs_to :user
has_many :votes
has_many :comments
end
|
require 'rails/generators'
module Enjoy::News::Config
class InstallGenerator < Rails::Generators::Base
source_root File.expand_path('../templates', __FILE__)
desc 'Enjoy::News Config generator'
def install
template 'enjoy_news.erb', "config/initializers/enjoy_news.rb"
end
end
end
|
class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable,
:confirmable, :timeoutable, :omniauthable, omn... |
class AddColumnsToUploadsTable < ActiveRecord::Migration
def change
add_column :uploads, :name, :string
add_column :uploads, :course, :string
add_column :uploads, :s3_key, :string
add_column :uploads, :s3_bucket, :string
add_reference :uploads, :user, index: true, foreign_key: true
end
end
|
# arrays_ex_6.rb
# names = ['bob', 'joe', 'susan', 'margaret']
# names['margaret'] = 'jody'
# the above code generates the following error:
=begin
TypeError: no implicit conversion of String into Integer
from (irb):2:in `[]='
from (irb):2
from /Users/username/.rvm/rubies/ruby-2.0.0-p353/bin/irb:12:in `<main>'
... |
namespace :merb_static do
desc "Compile static version of a website"
task :build => :merb_env do
Merb::Static::Archiver.build
end
desc "Delete output directory"
task :clean do
rm_rf Merb.root / "output"
end
desc "Sync generated files to remote server"
task :sync => :build do
Merb::Static:... |
class Training < ApplicationRecord
has_many :conduct_trainings, dependent: :destroy
belongs_to :genre
has_many :training_records, dependent: :destroy
validates :training_name,presence: true
validates :youtube_url,presence: true
validates :description,presence: true
validates :number_time,presence: true
end |
FactoryGirl.define do
factory :estimate do
location "MyString"
distance 1.5
final_price 1.5
fence_material "MyString"
fence_height 1.5
gate_count 1
customer
end
end
|
class Activity < ActiveRecord::Base
# validate :has_an_address
belongs_to :merchant
has_many :rules
has_many :views
has_many :slots
has_many :details
has_many :likes
belongs_to :category
has_many :shares
has_many :activities_addresses, :foreign_key => "activity_id", :class_name => "ActivitiesA... |
class CreateTeamAwaySeasons < ActiveRecord::Migration[5.1]
def change
create_table :team_away_seasons do |t|
t.integer "team_id"
t.integer "league_season_id"
t.integer "points"
t.integer "league_position"
t.integer "scored"
t.integer "conceded"
t.timestamps
end
end
... |
class Api::ItemsController < Api::ApiController
expose :items, -> { @active_company.items }
expose :item, scope: ->{ @active_company.items }
# GET api/items
def index
render json: items.includes_associated.render
end
# GET api/items/:id
def show
render json: item.render
end
# GET api/option... |
class Students::AccountsController < ApplicationController
before_filter :require_no_user
def new
@group = Group.find_by_code(params[:code])
@account = User.new(:group_code => @group.code)
end
def create
@account = Student.new(params[:user])
if @account.save_without_session_maintenance
... |
class ChildrenController < ApplicationController
before_action :set_child, only: [:edit,:update]
before_action :set_parent, only: [:new,:create,:edit,:update]
def new
@child = @parent.children.new
end
def create
@child = @parent.children.new(child_params)
respond_to do |format|
if @child.save
... |
require "spec_helper"
RSpec.describe "Day 25: The Halting Problem" do
let(:runner) { Runner.new("2017/25") }
let(:input) do
<<~TXT
Begin in state A.
Perform a diagnostic checksum after 6 steps.
In state A:
If the current value is 0:
- Write the value 1.
- Move one... |
# == Schema Information
#
# Table name: breezes
#
# id :integer not null, primary key
# description :text
# image_url :string(255)
# name :string(255)
# rang :string(255)
# created_at :datetime
# updated_at :datetime
#
class Breeze < ActiveRecord::Base
validates :name, :ran... |
desc 'Remove all files in the build directory'
task :clean do |t, args|
# kill the old package dir
rm_r 'build' rescue nil
end
desc 'Compile all files into the build directory'
task :build do
puts '## Compiling static pages'
status = system 'bundle exec middleman build'
puts status ? 'Build successful.' : 'B... |
class CreateOrderBookingLines < ActiveRecord::Migration[5.0]
def change
create_table :order_booking_lines do |t|
t.string :status
t.datetime :finished_at
t.datetime :started_at
t.integer :num_partner
t.datetime :expiry_at
t.integer :assigned_to
t.integer :request_id # Cu... |
module Cloudpassage
class Servers < Base
attr_reader :group_id
def initialize(token, group_id)
super(token)
@group_id = group_id
end
def base_path
"groups/#{group_id}/servers"
end
def type
'servers'
end
def get(id)
json(:get, "#{type}/#{id}")
end
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.