text stringlengths 10 2.61M |
|---|
class Address < ApplicationRecord
belongs_to :place, inverse_of: :address
validates_presence_of :city
end
|
class ToolsController < ApplicationController
before_action :set_tool, only: [:show, :update, :destroy]
before_action :authenticate
require 'azure/storage'
# GET /tool
def index
@tool = Tool.all
render json: @tool, :root => false
end
#GET /tool/search_tools
def search_tools
@tool = Tool.w... |
class Card < ActiveRecord::Base
belongs_to :deck
has_one :answer
validates :term, presence: true, uniqueness: true
validates :definition, presence: true
def answered?(round_id)
Answer.where(card_id: self.id, round_id: round_id).empty?
end
def answer(round_id)
a = Answer.where(card_id: self.id, r... |
stoplight = ['green', 'yellow', 'red'].sample
case stoplight
when 'green' then p 'Go!'
when 'yellow' then p 'Slow down!'
else p 'Stop!'
end |
require 'rails_helper'
RSpec.describe Item, type: :model do
describe '#create' do
before do
@item = FactoryBot.build(:item)
end
# 画像が空では登録できない
context '出品登録できないとき' do
it '画像が空では登録できない' do
@item.image = nil
@item.valid?
expect(@item.errors.full_messages).to include(... |
module ActiveRecord
module Persistence
extend ActiveSupport::Concern
module ClassMethods
def update_bulk(records = [], &block)
if records.is_a? Array
sql = records.map{|record| new(record, &block).update_for_bulk(record.keys)}.compact.join(";")
self.connection.execute(sql, "... |
# frozen_string_literal: true
require "spec_helper"
module Renalware::Forms::Generic
RSpec.describe Homecare::V1::PatientDetails do
it do
hash = default_test_arg_values.update(
given_name: "John",
family_name: "SMITH",
title: "Mr",
modality: "HD",
born_on: "2001-01-... |
class BuildElements
def initialize (product_list)
@product_list = product_list
end
def iterate
products = []
@product_list.each do |product_element|
name = text_from_css(product_element, "h3")
rating = text_from_css(product_element, ".star-rating span")
price = text_from_css(product... |
# Used in related questions modules, etc.
# For now, the only model that has questions is a medication
# Flag determines where it should be shown since medications
# have multiple sections.
# Question ids correspond to UserQuestion.id in ht-webapp12
class RelatedQuestion < ActiveRecord::Base
validates_presence_of :qu... |
# select the elements in the array whose indexs are fibonacci numbers
# define an is_fib?(num) method to return boolean
# do an array.select with is_fib? providing the returns
def is_fib?(num)
first = 1
second = 1
until second > num do
return true if second == num
first, second = second, first + second
... |
#!/usr/bin/env ruby
# frozen_string_literal: true
require 'pathname'
require_relative 'intcode'
def part_one(program)
outputs = (0..4).to_a.permutation.map do |phases|
input = 0
phases.each do |phase|
input = Intcode.new(program, [phase, input]).execute!.outputs.first
end
input # the last in... |
class RemoveColumnFromAppService < ActiveRecord::Migration
def change
remove_column :app_services, :price
remove_column :app_services, :unit
remove_column :app_services, :active
end
end
|
# 初期設定(自動販売機インスタンスを作成して、vmという変数に代入する)
vm = VendingMachine.new
# 作成した自動販売機に100円を入れる
vm.slot_money (100)
# 作成した自動販売機に入れたお金がいくらかを確認する(表示する)
# vm.current_slot_money
# 作成した自動販売機に入れたお金を返してもらう
# vm.return_money
class VendingMachine
# ステップ0 お金の投入と払い戻しの例コード
# ステップ1 扱えないお金の例コード
# 10円玉、50円玉、100円玉、500円玉、1000円札を1つずつ投入できる。
... |
class ApplicationController < ActionController::Base
protect_from_forgery
helper_method :current_user
rescue_from ActiveRecord::RecordNotUnique, with: :duplicate_record
def duplicate_record
puts "in duplicate record"
render json: {error: "duplicate record", status: 409}, status: 409
end
def current_user... |
#encoding: UTF-8
require 'spec_helper'
describe Egnyte::EgnyteError do
let!(:session) {Egnyte::Session.new({
key: 'api_key',
domain: 'test',
access_token: 'access_token'
}, :implicit, 0.0)}
let!(:client) { Egnyte::Client.new(session) }
subject {client.file('/Shared/example.txt')}
def stub_succ... |
# Various code snippets used in a Ruby workshop I once lead.
class Car
def initialize continent
@continent = continent
@distance = 0.0
end
def drive km, unit=:km
if unit == :km
@distance += km
else
@distance += km * 0.62
end
end
def distance
if @continent == :America
... |
class User < ApplicationRecord
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
devise :trackable, :omniauthable, omniauth_providers: %i(google)
has_many :player
def self.dummy_user(id)
User.where(id: id).first_or_create(name:... |
require 'ship'
describe Ship do
let(:ship) {Ship.new}
let(:cell) {double :cell}
it 'should be floating on water when initialized' do
expect(ship.sunk?).to be false
end
it 'should be able to sink' do
ship.sink!
expect(ship.sunk?).to be true
end
it 'must initialise without any cells' do
expect(ship.c... |
class AddUuidToAddresses < ActiveRecord::Migration
def change
add_column :addresses, :uuid, :string
end
end
|
class ProductPurchase < ApplicationRecord
has_one :shipping_address
belongs_to :product
belongs_to :user
end
|
# @param {Integer[]} nums
# @return {Integer[]}
def running_sum(nums)
result = []
return result unless nums || nums.empty?
previous_value = 0
0.upto(nums.size - 1) do |i|
nums[i] = nums[i] + previous_value
previous_value = nums[i]
end
return nums
end
|
class Cart < ApplicationRecord
belongs_to :customer
has_many :line_items
has_many :products, through: :line_items
end
|
class Board < ActiveRecord::Base
self.primary_key = 'name'
has_many :tread
end
|
class UserController < ApplicationController
def recommendations
@games = UserGame.unplayed_games(current_user)
end
end
|
module DynaForm
class Base
extend ActiveModel::Naming
extend DynaForm::Constants
include ActiveModel::Conversion
include ActiveModel::Validations
class << self
def submit(*args, hash)
updated_hsh = hash.with_indifferent_access
unless updated_hsh.length == SUBMIT_HASH_LIMIT ... |
class HomeController < ApplicationController
before_action :authenticate_user!, :except => [:index]
def index
render layout: "home"
end
end
|
# Methods added to this helper will be available to all templates in the application.
module ApplicationHelper
def reset_index_visits
session[:counter]=0
end
def count_index_visits
if session[:counter].nil?
reset_index_visits
else
session[:counter]+=1
end
end
def report_index_vi... |
class AddProductToLists < ActiveRecord::Migration
def change
add_column :lists, :product, :string
end
end
|
module Sidekick::ReviewsHelper
def link_to_add_fields(name, f, association, my_class = nil)
new_object = f.object.class.reflect_on_association(association).klass.new
fields = f.fields_for(association,new_object,:child_index => "new_#{association}") do |builder|
render :partial => association.to_s.singu... |
require "gosu"
require_relative "player"
require_relative "enemy"
require_relative "bullet"
require_relative "explosion"
require_relative "enemy_bullet"
require_relative "health"
require_relative "credit"
class TenaciousTanks < Gosu::Window
WIDTH = 1200
HEIGHT = 800
def initialize
super(WIDTH, HEIGHT)
self.cap... |
class AddColumnsToUser < ActiveRecord::Migration[5.2]
def change
add_column :users, :about_contents_complete, :boolean, null: false, default: false
add_index :users, :about_contents_complete
add_column :users, :business_details_complete, :boolean, null: false, default: false
add_index :users, :busines... |
OBJC_LANGUAGE = {
name: 'Objective C',
file_extension: '(h|m)',
comments: {
line_single: '//',
line_multi: {
start: '/\*',
end: '\*/'
}
},
keywords_comments: {
# keywords that denote good practices
potentially_good: [
'#pragma mark:'
],
potentially_neutral: [
... |
# encoding: utf-8
class AddColumnCaloryToRecipes < ActiveRecord::Migration
def up
add_column :recipes, :calory, :integer, null: true
end
def down
remove_column :recipes, :calory
end
end
|
require_relative 'p05_hash_map'
require_relative 'p04_linked_list'
class LRUCache
attr_reader :count
def initialize(max, prc)
@map = HashMap.new
@store = LinkedList.new
@max = max
@prc = prc
end
def count
@map.count
end
def get(key)
puts count
if @map.include?(key)
updat... |
description 'Basic sidebar implementation'
dependencies 'engine/engine'
class Olelo::Application
hook :layout do |name, doc|
page = Page.find(Config.sidebar_page) rescue nil
doc.css('#sidebar').first << if page
Cache.cache("sidebar-#{page.version}", :update => request.no_cache?, :defer => true) do |co... |
class AddBillHeaderToQueryCache < ActiveRecord::Migration
def change
add_column :query_caches, :bill_header, :longtext
end
end
|
class Fertilization < ActiveRecord::Base
belongs_to :field
belongs_to :fertilizer
validates_presence_of :date, :dose
end
|
namespace :db do
desc 'Erase and fill database'
task populate: :environment do
require 'faker'
require 'cpf_cnpj'
[Academic, Institution, ExternalMember, BaseActivity].each(&:delete_all)
Professor.where.not(username: 'marczal').destroy_all
100.times do
Academic.create(
name: Fak... |
class ReimbursementsController < ApplicationController
before_action :authenticate_user!
def index
load_reimbursements
end
def new
build_reimbursement
end
def edit
load_reimbursement
end
def create
build_reimbursement
save_reimbursement or render 'new'
end
def update
load_... |
$:.unshift(File.dirname(__FILE__)) unless $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
require 'dataMetaDom'
require 'dataMetaDom/ver'
require 'treetop'
require 'dataMetaParse'
require 'bigdecimal'
require 'set'
require 'logger'
require 'erb'
require 'fileutils'
require ... |
module QueryMethodsExtend
module Like extend ActiveSupport::Concern
included do
attr_accessor :extend_like_string
def self.like agrs
@extend_like_string = '%{?}%'
like_basic agrs
end
def self.l_like agrs
@extend_like_string = '%{?}'
like_basic agrs
e... |
#!/usr/bin/ruby
require 'serrano'
require 'nokogiri'
def finddoi(query)
begin
response = Serrano.works(query: query)
rescue => e
puts "Something went wrong while getting the DOI: "
puts e
return ""
end
items = response['message']['items']
items.each do |item|
if (item['title'] && item... |
class Notification < ApplicationRecord
belongs_to :recipient, class_name: 'User'
belongs_to :actor, class_name: 'User'
belongs_to :target, polymorphic: true
# target can be answer, friendrequest, friendship, assignment, highlight or comment
# polymorphic type이기 때문에 target만 보내주면 target_id와 target_type이 알아서 ... |
ActiveAdmin.register Quest do
form :html => { :enctype => "multipart/form-data" } do |f|
f.inputs "Details" do
f.input :title
f.input :points
f.input :description
f.input :image, :as => :file, :hint => f.template.image_tag(f.object.image.url(:thumb)), :required => false
end
f.actio... |
FactoryBot.define do
factory :product do
name { FFaker::Name.name }
price 100
end
end |
class CreateVendorToServices < ActiveRecord::Migration[5.2]
def change
create_table :vendor_to_services do |t|
t.integer :vendor_id
t.integer :service_id
t.float :price
t.timestamps
end
end
end
|
require 'spec_helper'
class ApiTester
include Collins::Api
attr_reader :logger
def initialize logger
@logger = logger
end
end
describe Collins::Api do
it "#trace" do
logger = double("logger")
logger.should_receive(:debug).exactly(1).times
a = ApiTester.new logger
a.trace("Hello world")
... |
require 'net/http'
require 'json'
require 'pp'
namespace :check do
namespace :migrate do
# run this task inside check-api container with
# `bundle exec rake check:migrate:remove_vector_768_and_reindex['https://ES_URL','USER','PWD']``
desc 'trigger reindexing of ProjectMedia that only have de... |
class Review < ApplicationRecord
belongs_to :user, class_name: "User", foreign_key: "user_id"
belongs_to :movie, class_name: "Movie", foreign_key: "movie_id"
end
|
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "timveil/centos7-hdp-base"
config.vm.box_check_update = true
config.vm.hostname = "hadoop3"
config.vbguest.auto_update = true
config.vbguest.no_remote = false
config.vbguest.no_install = false
config.vm... |
class MeasurementPreviewSerializer < ActiveModel::Serializer
attributes :id, :value, :time, :source
end
|
# frozen_string_literal: true
require 'spec_helper'
describe Dotloop::Task do
let(:client) { Dotloop::Client.new(access_token: SecureRandom.uuid) }
subject(:dotloop_task) { Dotloop::Task.new(client: client) }
describe '#initialize' do
it 'exist' do
expect(dotloop_task).to_not be_nil
end
it '... |
class AddStartdayEnddayStarttimeEndtimeToOffer < ActiveRecord::Migration
def change
add_column :offers, :start_day, :text
add_column :offers, :end_day, :text
add_column :offers, :start_time, :string
add_column :offers, :end_time, :string
end
end
|
class Permission < ApplicationRecord
belongs_to :metric_unit
belongs_to :user
end
|
class Users::FollowsController < Users::BaseController
def index
if follow_params[:relation] == "followings"
@relation_type = "following"
@relations = current_user.followings
elsif follow_params[:relation] == "followers"
@relation_type = "follower"
@relations = current_user.followers
... |
require 'faraday'
require 'faraday_middleware'
require 'platforms/yammer/api'
module Platforms
module Yammer
# A REST client for Yammer
#
# Assumes all of the OAuth2 authentication has been done previously,
# and a valid token is available.
#
# Uses Faraday to conduct HTTP requests and receiv... |
require 'spec_helper'
describe ApplicationHelper do
describe "#close_standup" do
it "picks a closing" do
helper.should_receive(:rand).and_return(0)
helper.standup_closing.should == "STRETCH!"
end
end
describe "#pending_post_count" do
let(:standup) { create(:standup) }
let(:other_stan... |
class AddAttsToJob < ActiveRecord::Migration
def change
add_column :jobs, :title, :string
add_column :jobs, :user_id, :integer
add_column :jobs, :description, :string
add_column :jobs, :duration, :integer #In hours
add_column :jobs, :rate_min, :float
add_column :jobs, :rate_max, :float
add_column... |
require 'spec_helper'
describe Enriched::Youtube do
let(:youtube) { described_class.new('https://www.youtube.com/watch?v=_-MJqF-NIsc') }
describe '#id' do
it 'returns the correct id for different formats' do
[
'https://www.youtube.com/watch?v=_-MJqF-NIsc',
'https://youtu.be/_-MJqF-NIsc',... |
# frozen_string_literal: true
class UserShowSerializer < ActiveModel::Serializer
attributes :id, :first_name, :last_name, :full_name, :email, :tel_num,
:date_of_birth, :created_at, :updated_at, :age, :avatar, :gender,
:role, :last_seen_at, :cars, :rides_as_driver
def avatar
object.av... |
module Gnomika
##
# Writes given quotes to files according to the given options.
# @param options GnomikaOptions object containing file output options
# @param quotes Hash matching each subcategory to an Array with quotes
def self.write_files(options, quotes)
# If no custom directory is specified, use th... |
class StateScraper
attr_reader :state, :url
BASE_URL = "https://ballotpedia.org"
def initialize(state)
@state = state
@url = "#{BASE_URL}/#{state.name}_2020_ballot_measures".sub(" ", "_")
@ballot_array = []
end
def scrape_for_state
parse_ballots(request_state_ballots)
determine_scraper
... |
require_relative "transaction"
class Customer
@@customers = []
attr_reader :name, :products
attr_accessor :cash
def initialize(options={})
@name = options[:name]
@cash = options[:cash] || 100
@products = []
if self.class.find_by_name(@name)
raise Duplicate... |
require 'spec_helper'
describe ReceptionsController do
describe "routing" do
it "recognizes and generates #index to give a quick index over the incoming receptions" do
{ :get => "/receptions" }.should route_to(:controller => "receptions", :action => "index")
end
it "recognizes and generates #show ... |
# # frozen_string_literal: true
require 'rails_helper'
RSpec.describe Message, type: :model do
include AppHelper
context 'Validation Model' do
it 'ensure room Id presence' do
message = Message.new(
room_id: nil,
sender_id: current_user.id,
content: 'Test empty room id'
).sa... |
class User < ActiveRecord::Base
validates :username, :email, :password, presence: true
validates :email, uniqueness: true, format: { with: /\A([\w+\-].?)+@[a-z\d\-]+(\.[a-z]+)*\.[a-z]+\z/i }
def authenticate(password)
return false if self == nil
self.password == password
end
def password
@passwo... |
class Car
# Os atributos da classe só podem ser acessados via getter e setter
def initialize(manufacturer, model, year)
@manufacturer = manufacturer
@model = model
@year = year
end
#getter
def model
return @model
end
#getter
def manufacturer
re... |
# frozen_string_literal: true
# Based on:
# https://github.com/ReneB/activerecord-like/blob/72ca9d3c11f3d5a34f9bee530df5d43303259f51/test/helper.rb
module Test
module Postgres
def self.connect_db
ActiveRecord::Base.establish_connection(postgres_config)
end
def self.drop_and_create_database
... |
require 'fog'
class LinodeDriver < Provider
PROVIDER='Linode'
PROVIDER_ID = 90
LOG_PROVIDER='linode'
MAXJOBS = 1
LOGIN_AS = 'root'
DEFIMAGE = '124'
def self.get_active location, all, &block
s = get_auth location
servers = s.servers.each do |server|
next if server.attributes[:datacenterid].... |
class WorkingTime
include Mongoid::Document
field :mon_open, :type => Boolean
field :tue_open, :type => Boolean
field :wed_open, :type => Boolean
field :thu_open, :type => Boolean
field :fri_open, :type => Boolean
field :sat_open, :type => Boolean
field :sun_open, :type => Boolean
field :mon_from, :... |
FactoryBot.define do
factory :user do
sequence(:name) { |n| "sample#{n}" }
sequence(:email) { |n| "sample#{n}@sample.com" }
password { 'password' }
password_confirmation { 'password' }
confirmed_at { Date.today }
trait :guest do
name { 'guest' }
em... |
require 'open-uri'
class TweetIndexer
def self.index
@api ||= IndexTank::Client.new(ENV['HEROKUTANK_API_URL'])
# @api ||= IndexTank::Client.new("http://:Az8QXRhHLzMRiJ@d24bu.api.indextank.com")
@index ||= @api.indexes('herokutest')
create_index unless @index.exists?
@index
end
def self.create_... |
class RemoveDeviceTokenAndType < ActiveRecord::Migration
def up
remove_column :devices, :token
remove_column :devices, :operating_system
end
def down
add_column :devices, :token, :string
add_column :devices, :operating_system, :string
end
end
|
class CreateRounds < ActiveRecord::Migration
def change
create_table :rounds do |t|
t.integer :game_id
t.text :story_fragment
t.timestamps
end
add_index :rounds, :game_id
end
end
|
class Course < ApplicationRecord
TYPES = [
'Frontend',
'Backend',
'Fullstack',
'Data',
'Resume',
'Leetcode',
'Interview',
'OOD',
'System Design',
].sort.freeze
validates :course_name, :description, :course_type, :image_url, presence:tr... |
#
# Cookbook Name:: hosts
# Recipe:: default
#
# Copyright 2009, Opscode, 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 ... |
module RouteTranslator
module RouteSet
module Translator
# Translate a specific RouteSet, usually Rails.application.routes, but can
# be a RouteSet of a gem, plugin/engine etc.
def translate
Rails.logger.info "Translating routes (default locale: #{default_locale})" if defined?(Rails) && ... |
class Match < ActiveRecord::Base
belongs_to :winner, class_name: 'Player'
belongs_to :loser, class_name: 'Player'
def self.get_winner_matches player_id
sql_inner_join = "INNER JOIN 'players' ON 'players'.'id' = 'matches'.'winner_id'"
sql_where = "'players'.'id' = #{player_id}"
Match.joins(sql_inner_... |
class MissingBiblePassageAnnotionFields < ActiveRecord::Migration
def change
add_column :bible_passage_annotations, :study_passage_id, :integer
end
end
|
require 'http'
require 'application_helper'
class R
attr_accessor :subreddit, :posts, :page
URL = 'http://www.reddit.com/r/'
def initialize(subreddit, page)
@subreddit = subreddit
@page = page ? page.to_i : 1
@posts = []
end
def valid_json?(json)
begin
JSON.parse(json)
rescue Exc... |
require 'active_support/concern'
module IsUpdateable
extend ActiveSupport::Concern
included do
def self.update(params, resource, proxy)
has_programs(params)
.has_languages(params)
.has_password(params, resource, proxy)
end
scope :has_programs, proc { |params|
if params[:progra... |
class TitlesController < ApplicationController
respond_to :html, :json
caches_action :search, :expires_in => 1.hour, :cache_path => proc { |c| {:query => c.params[:q]} }
def index
@new_releases = Title.new_releases
@new_on_dvd = Title.new_on_dvd
@recently_added = Title.recently_added
@recently_... |
######################
# 一些公用方法 #
######################
module ApiHelpers
#
# 获取logger
#
def logger
GGA.logger
end
#
# 认证用户
#
def authenticate!
error!('401 Unauthorized', 401) unless current_user
end
#
# 当前用户
#
def current_user
@current_user ||= User.find_by_session_key... |
class Part < ApplicationRecord
belongs_to :warehouse
belongs_to :remover, foreign_key: :removed_by_id, class_name: :Employee, optional: true
belongs_to :receiver, foreign_key: :received_by_id, class_name: :Employee, optional: true
belongs_to :order, optional: true
def self.all_of_type_in_inventory(part_no)
... |
### conditional.rb code Start #####
puts "Put in a number"
a = gets.chomp.to_i
if a == 3
puts "a is 3"
elsif a== 4
puts "a is 4"
else
puts "a is neither 3, no 4"
end
### conditional.rb code End #####
### case_statement.rb code Start #####
puts "Put in a number"
a = gets.chomp.to_i
case a
when 5
puts "a is 5"
... |
class ActivationsController < ApplicationController
respond_to :json
def create
new_password = params[:user] && params[:user][:password]
token = params[:confirmation_token]
if !new_password
render_errors({"password"=>["can't be blank"]}.to_json)
elsif (@user = User.for_confirmation_token(t... |
class Branch < ApplicationRecord
belongs_to :doctor
has_many :pacients
end
|
class CreateSubInvoices < ActiveRecord::Migration
def change
create_table :sub_invoices do |t|
t.string :title
t.text :comment
t.integer :status
t.integer :echeance
t.decimal :total
t.datetime :starttime, :endtime
t.references :invoice, index: true
t.timestamps
... |
class EbayFindingApi
def self.get_api_response(params)
baseUrl = "http://svcs.ebay.com/services/search/FindingService/v1?"
query_string = QueryBuilder.query_string_from_hash(params)
request = HTTP.get(baseUrl + query_string)
Hash.from_xml(request.body)
end
def self.find_item_by_product(id:, ... |
require 'csv'
class BaseImporter
def initialize(import_task)
@import_task = import_task
end
def import
import_class
:success
rescue => e
# Call exceptions tracker
log_file.write("Something went wrong: #{e.message}")
:failure
ensure
save_log_file
end
private
def import_cl... |
Rails.application.routes.draw do
default_url_options host: 'localhost', port: 3000
devise_for :users
# The priority is based upon order of creation: first created -> highest priority.
# See how all your routes lay out with "rake routes".
# You can have the root of your site routed with "root"
# root 'welco... |
# frozen_string_literal: true
class CreateTeachers < ActiveRecord::Migration[5.1]
def change
create_table :teachers, id: :uuid do |t|
t.string :first_name, limit: 30, null: false
t.string :last_name, limit: 30, null: false
t.string :grade, limit: 15, null: false
t.integer :is_active, defa... |
# class des joueurs
class Player
attr_accessor :name, :life_points, :enemies
@@enemies = []
def initialize(name)
@name = name
@life_points = 10
@@enemies << self
end
def self.all_player
@@enemies
end
# montre l'état d'un Player
def show_state
if self.is_alive? == true
retu... |
class AddAbstractToUsers < ActiveRecord::Migration[5.1]
def change
add_column :users, :abstract, :string
end
end
|
require 'simplecov'
SimpleCov.start
gem 'minitest', '~> 5.2'
require 'minitest/autorun'
require 'minitest/pride'
require 'pry'
require_relative '../lib/offset'
class OffsetTest < Minitest::Test
attr_reader :offset
def setup
@offset = Offset.new
end
def test_it_exists
assert Offset
end
def test_... |
class RegistrationsController < ApplicationController
before_action :set_event
before_action :require_signin
def index
@registrations = @event.registrations
end
def new
@registration = @event.registrations.new
end
def create
@registration = @event.registrations.new(registration_params)
@registration.us... |
# coding: utf-8
require 'spec_helper'
describe Link do
it { should validate_presence_of(:network) }
it { should validate_presence_of(:channel) }
it { should validate_presence_of(:sender) }
it { should validate_presence_of(:line) }
it { described_class.should respond_to(:search_text) }
describe ".search_te... |
Rails.application.routes.draw do
namespace :api do
namespace :v1 do
resources :translations, only: [:index, :create, :update, :destroy]
end
end
root "pages#index"
# Redirect all unknown routes to root_url / keep at the bottom of routes.rb
get '*path' => redirect('/')
end
|
require 'spec_helper'
module TicTacToe
describe "TicTacToe" do
IO = Struct.new(:inputs) do
attr_reader :outputs
def puts(message)
@outputs ||= []
@outputs << message
end
def gets
inputs.shift
end
end
def io(jeff = nil, anna = nil)
@io ||= IO... |
class ChangeProductoToInsumoInCompras < ActiveRecord::Migration
def change
remove_column :compras, :producto
add_column :compras, :insumo, :string
end
end
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.