text
stringlengths
10
2.61M
require 'mini_magick' module Fastlane module Actions class AndroidAppiconAction < Action def self.needed_icons { launcher: { :ldpi => ['36x36'], :mdpi => ['48x48'], :hdpi => ['72x72'], :xhdpi => ['96x96'], :xxhdpi => ['144x144']...
# -*- coding: utf-8 -*- module PlanningHelper def week_day ["Dimanche", "Lundi", "Mardi", "Mercredi", "Jeudi", "Vendredi", "Samedi" ] end def months ["Months", "Janvier", "Février", "Mars", "Avril", "Mai", "Juin", "Juillet", "Août...
require 'file_mover/filter' require 'file_mover/password' require 'active_support/core_ext/class/attribute' module FileMover # subclasses must implement #cmd(tmp_dir, pathes) # and target_pathes(tmp_dir,pathes) class Cmd < Filter include Password class_attribute :single_mode, instance_writer: false ...
Rails.application.routes.draw do root 'welcome#router' get 'activities', to: 'activities#query' devise_for :stoics, path: '', path_names: {sign_in: 'login'} authenticate :stoic do scope ':stoic' do get '', to: 'stoics#home' get 'inventory', to: 'stoics#inventory' resources :activities,...
require 'uri' module Fn module Salesforce class Transaction attr_reader :client, :plan, :failed, :result attr_accessor :logger def initialize(client, plan, logger: Logger.new(STDOUT)) @logger = logger @client = client @plan = plan @result = [] @failed ...
#! /usr/bin/env ruby require 'json' # This complicated looking regex will count the number of facts that are named via interpolated strings. # in other words, Facter.add("interface#{count}") or the like. problems = [] Dir.glob('lib/facter/*').each do |fact| next unless File.file? fact if File.read(fact) =~ /Facte...
class FilterController < ApplicationController def index end def car # Check if car_id present in params: unless params.has_key?(:car_id) render plain: "No car id provided", :status => :bad_request and return end # Check that the driver and the car really exist: unless Car.exists?(...
require 'set' class Triangle attr_reader :x_1, :x_2, :x_3, :y_1, :y_2, :y_3 def initialize(p_1, p_2, p_3) @x_1, @y_1 = p_1 @x_2, @y_2 = p_2 @x_3, @y_3 = p_3 end def distinct_points? [x_1, y_1] != [x_2, y_2] && [x_2, y_2] != [x_3, y_3] && [x_1, y_1] != [x_3, y_3] end def non_coline...
# Default url mappings are: # a controller called Main is mapped on the root of the site: / # a controller called Something is mapped on: /something # If you want to override this, add a line like this inside the class # map '/otherurl' # this will force the controller to be mounted on: /otherurl class MainControll...
module SessionsHelper # 渡された生産者idでログイン def log_in(producer) session[:producer_id] = producer.id end # 生産者のセッションを永続的ににする def remember(producer) producer.remember cookies.permanent.signed[:producer_id] = producer.id cookies.permanent[:remember_token] = producer.remember_token end # 渡された生産者...
# == Schema Information # # Table name: comments # # id :integer not null, primary key # user_id :integer # photo_id :integer # content :text # created_at :datetime not null # updated_at :datetime not null # # Indexes # # index_comments_on_photo_id (photo_id) # index_co...
module Structus::Instance extend Forwardable class << self def def_wrapped_enums(recepter, *methods) methods.each do |method| def_delegator recepter, method, :"_#{method}" define_method method do |*args, &block| return to_enum(method) unless block_given? __sen...
class RemoveImageUrlColumnsFromMovies < ActiveRecord::Migration def self.up remove_column :movies, :poster_url remove_column :movies, :purchase_bg_url remove_column :movies, :watch_bg_url remove_column :movies, :splash_image_url remove_column :movies, :thumb_popup_image remove_column :movies, ...
class Profile < ActiveRecord::Base belongs_to :user def display_name case when self.first_name && self.last_name "#{self.first_name} #{self.last_name}" when self.first_name self.first_name when self.last_name self.last_name when self.nickname self.nickname end end end
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') describe ListedDoc do before do @admin = mock_model(Kbuser, :username=>'Admin', :signed_up? => true, :administrator? => true) @list_creator = mock_model(Kbuser, :username=>'Chuck', :signed_up? => true, :administrator? => false) @other_u...
class PostRate < ActiveRecord::Base #belongs_to :post, :counter_cache => true belongs_to :user validates_presence_of :user_id validates_presence_of :post_id validates_presence_of :rate ################## create #################### def self.create_post_rate(params,post,user) post_rate = PostRa...
require 'yaml' require 'logger' require 'active_record' class Database def self.migrate connect ActiveRecord::Migration.verbose = true ActiveRecord::Migrator.migrate "db/migrations" end def self.drop connect File.delete(config["database"]) end def self.rollback connect Ac...
FactoryGirl.define do factory :review do title { Faker::Lorem.sentence } description { Faker::Lorem.paragraphs(3).join(' ') } overal_rating { rand(5) } user apartment end end
class Stores attr_reader :name, :city, :distance, :phone_number, :store_type def initialize(store) @name = store[:longName] @city = store[:city] @distance = store[:distance] @phone_number = store[:phone] @store_type =...
# encoding: utf-8 module Api module V1 class OauthsController < ::Api::BaseApiController #before_filter :authenticate_user! #before_filter :get_user def create @user = create_new_user sign_in @user, :bypass => true @user.reset_authentication_token! # user_id, sn...
require 'csv' module Dabooks class CLI::RunningCommand DETAILS = { description: 'Shows a running total for a given account.', usage: 'dabooks running [options] <account> <filename>+', schema: { csv: { long: '--csv', short: '-c', doc: 'Output in CSV format' }, }, ...
class CreateFeedbacks < ActiveRecord::Migration def change create_table :feedbacks do |t| t.integer :writer_id t.integer :receiver_id t.integer :goal_id t.integer :interaction_id t.integer :request_id t.text :qualitative_fb t.integer :quantitative_fb t.timestamps ...
class StudentClass < ActiveRecord::Base include Accessable include Codeable include Statusable include PubsubConcerns::Publisher include ReportSQL::StudentClasses include ResourceVisibilitable include PgSearch include AchievementConcerns::StudentClassAchievementable STATUS = { active: 'active', ...
require 'rails_helper' describe 'user can logout' do scenario 'by clicking the log out link' do default_user = create(:user) allow_any_instance_of(ApplicationController).to receive(:current_user).and_return(default_user) visit user_path(default_user) click_link "Log Out" expect(current_path)....
class IdeaTemplatePage < SitePrism::Page element :savetemplate_button, :xpath, "//a/span[text()='Save Template']" element :viewxml_button, :xpath, ".//*[@class='view_xml']" element :xml_popup, :xpath, ".//pre[@class='ui-dialog-content ui-widget-content']" element :close_button, :xpath, ".//button[@title='close...
require 'rails_helper' RSpec.describe Donor, type: :model do donor_attributes = [:logo, :name, :level, :link] donor_attributes.each do |atrb| it { should respond_to(atrb) } end it { should validate_presence_of(:name) } it { should validate_presence_of(:level) } it { should allow_value('http://foo.co...
class Person attr_accessor :name attr_accessor :cash def initialize(person_name, cash_on_hand) @name = person_name @cash = cash_on_hand puts "Hi, #{name}. You have $#{@cash}!" end end class Bank attr_accessor :bank attr_accessor :accounts attr_accessor :amount attr_accessor :withdraw attr_access...
class Paciente < Individuo attr_reader :nombre, :edad, :sexo, :peso, :altura, :circunferencia_cintura, :circunferencia_cadera, :actividad_fisica include Comparable def initialize(nombre, edad, sexo, peso, altura, circunferencia_cintura, circunferencia_cadera, actividad_fisica) super(nomb...
# -*- mode: ruby -*- # vi: set ft=ruby : boxes = [ { :name => :jobtracker, :ip => '192.168.33.10', :ssh_port => 2202, :cpus => 1, :mem => 1024, :mac => "720002691321" }, { :name => :namenode, :ip => '192.168.33.11', :ssh_port => 2203, :cpus => 1, :mem => 1024, :mac => "720002691332" }, { :name => ...
require 'test_helper' class EyeExamsControllerTest < ActionDispatch::IntegrationTest setup do @eye_exam = eye_exams(:one) end test "should get index" do get eye_exams_url assert_response :success end test "should get new" do get new_eye_exam_url assert_response :success end test "s...
# frozen_string_literal: true module MeshHelper def import_mesh_terms m = Qa::Authorities::MeshTools::MeshImporter.new File.open(file_fixture('mesh_terms.txt')) do |f| m.import_from_file(f) end end end
require 'vagrant/errors' module Vagrant module Butcher module Errors class KeyCopyFailure < ::Vagrant::Errors::VagrantError end class NoSyncedFolder < ::Vagrant::Errors::VagrantError end end end end
class ApplicationController < ActionController::Base # Prevent CSRF attacks by raising an exception. # For APIs, you may want to use :null_session instead. protect_from_forgery with: :exception before_action :set_locale helper_method :page_title, :login_user, :admin? private def default_url_options(opt...
require 'rails_helper' RSpec.describe SitesController, type: :controller do let(:user) { create :user } before do login_user(user) end describe "#index" do before do get :index end it_behaves_like "renders index" end describe "#destroy" do let(:params) { { id: create(:site, ...
Rails.application.routes.draw do root 'welcome#index' get 'rules', to: 'welcome#rules' # get 'dashboard', to:'welcome#dashboard' get 'register', to: 'welcome#register' get 'register/check/:hash', to: 'welcome#check_hash' get 'register/:hash', to: 'welcome#register_hash' get 'login', to: 'welcome#lo...
%w(.vim .vim/bundle).each do |folder| directory "#{node[:home]}/#{folder}" do user node[:user] group node[:group] mode '0755' action :create end end %w(vim).each do |package_name| package package_name do action :install end end git "#{node[:home]}/.vim/bundle/neobundle.vim" do user node[...
# -*- encoding : utf-8 -*- require 'spec_helper' describe JobsController do describe :show do before(:each) do @similar_job = stub_model(Job) @job = stub_model(Job) @admission = stub_model(Admission) @admission.should_receive(:appliable?).and_return(true) @job.stub(:admission).and_...
require_relative 'vocabulary_operator' module ConceptQL module Operators # A SourceVocabularyOperator is a superclass for a operator that represents a criterion whose column stores information associated with a source vocabulary. # # If that seems confusing, then think of ICD-9 or NDC criteria. That typ...
class Poly1305aes < Formula desc "State-of-the-art message-authentication code" homepage "https://cr.yp.to/mac.html" url "https://cr.yp.to/mac/poly1305aes-20050218.tar.gz" sha256 "1ff45c186f85a8a2533d88ae10b6ea7510be93d592c22d751db21023ef0a7133" fails_with :clang do cause "fatal: all tests failed!" end...
class Foothold < ActiveRecord::Base belongs_to :affiliate belongs_to :work end
require 'spec_helper' describe ProductWarranty do let(:product_warranty) { FactoryGirl.create(:product_warranty) } subject { product_warranty } describe "validations" do it { should be_an_instance_of(ProductWarranty) } it { should be_valid } it { should validate_presence_of(:name) } it { should...
module Phcmembers class Member::Address < ApplicationRecord # Clean URL Initialize extend FriendlyId # Paper Trail Initialize has_paper_trail :class_name => 'Phcmembers::AddressVersions' # Relationships belongs_to :profile, class_name: 'Phcmembers::Member::Profile' # Form Fields Validati...
# frozen_string_literal: true module Roster class PastCommandersController < ::RosterController # This class defines no public methods. def _; end private def model Roster::PastCommander end def clean_params params.require(:roster_past_commander).permit( :id, :user_id, :n...
class Docutils < Formula include Language::Python::Virtualenv desc "Text processing system for reStructuredText" homepage "https://docutils.sourceforge.io" url "https://downloads.sourceforge.net/project/docutils/docutils/0.16/docutils-0.16.tar.gz" sha256 "7d4e999cca74a52611773a42912088078363a30912e8822f7a3d3...
require 'grid2d' describe Grid2D do describe "initialize" do it "with only a height and a width all elemenst are nil" do g = Grid2D.new 3,3 list = [] g.each {|element| list << element} list.size.should eql 9 list.all?{|element| element.nil?}.should be_true end end describe "...
class Zone < ActiveRecord::Base belongs_to :created_by, :class_name => "User", :foreign_key => "user_id" has_many :adoption_requests end
# frozen_string_literal: true require "date" require "json" require "faraday" class Redox::Source include MonitorMixin SECONDS_PER_DAY = 60 * 60 * 24 ACCESS_TOKEN_EXPIRATION_BUFFER = Rational(300, SECONDS_PER_DAY) attr_reader :endpoint, :api_key, :access_token_expires_at def initialize(endpoint:, api_key...
class SharesController < ApplicationController #only to be used in development skip_before_action :verify_authenticity_token def index shares = Share.all render json: shares end # shows all the shares owned by a certain user, NOT a specific share def show user = U...
# Model model: rest_name: cloudsubnetdata resource_name: cloudsubnetdata entity_name: CloudSubnetData package: yeul group: pcn/infrastructure description: Parameters associated with a subnet. detached: true # Attributes attributes: v1: - name: address description: Address CIDR of the Subnet. ...
module Enjoy::News module Admin module Category def self.config(fields = {}) Proc.new { navigation_label I18n.t('enjoy.news') list do scopes [:sorted, :enabled, nil] field :enabled, :toggle do searchable false end fi...
# # encoding: utf-8 # Inspec test for recipe test::default describe package('git') do it { should be_installed } end describe file('/etc/profile.d/nodenv.sh') do it { should exist } end global_version = '8.2.1' describe bash('sudo -H -u vagrant bash -c "source /etc/profile.d/nodenv.sh && nodenv global"') do ...
class User < ActiveRecord::Base has_many :albums validates :username, uniqueness: true def self.authenticate(passed_in_username, passed_in_password) @user = User.where(username: passed_in_username).first if @user && @user.password == passed_in_password @user else nil end end end
class PostController < ApplicationController def index require 'nokogiri' require 'open-uri' @user = current_user @base_url = 'http://pitchfork.com' @docs = {} @user.follows.each do |follow| artist_name = follow["artist_name"] @docs[artist_name] = Nokogiri::HTML(open("http://pit...
require 'oystercard' describe Oystercard do let(:station){ double :station } # it 'stores the entry station' do # subject.top_up(1) # subject.touch_in(station) # expect(subject.entry_station).to eq station # end it 'has a balance of zero' do expect(subject.balance).to eq(...
require 'spec_helper' describe Channel do before(:each) do @attr = { :name => "OuterSpace", :zone => 1 } end it "should create a new instance given valid attributes" do Channel.create!(@attr) end it "should require a name" do no_name_channel = Channel.new(@attr.merge(:name => "")) no...
require 'VCR' require 'rspec' Given /^I am not yet monitoring a build$/ do end When /^I start the JenkinsLight monitor$/ do start_the_monitor end Then /^I should see "(.*?)"$/ do |message| output.messages.should include(message) end Then /^I should see a message with the current time and "(.*?)"$/ do |message| ...
class Admin::MessagesController < Admin::BaseAdminController load_and_authorize_resource skip_load_resource only: :index before_action :set_messages before_action :require_same_user, only: :show before_action :set_recipients, only: :create def new; end def create sent_messages_count = current_active...
# encoding: UTF-8 # Copyright 2012 Twitter, Inc # http://www.apache.org/licenses/LICENSE-2.0 require 'spec_helper' describe TwitterCldr::Shared::Territory do let(:code) { '013' } let(:territory) { described_class.new(code) } let(:containment) { TwitterCldr::Shared::TerritoriesContainment } describe '#parent...
module JWT class UrlSigner CONFIG_PATH = File.join(Rails.root, "config", "paperclip_signing_settings.yml") class << self attr_reader :secret_key attr_reader :expiry def configure @signing_enabled = false if File.exi...
# frozen_string_literal: true # Copyright (c) 2018 Yegor Bugayenko # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the 'Software'), to deal # in the Software without restriction, including without limitation the rights # to use, co...
# frozen_string_literal: true class PasswordResetsController < ApplicationController before_action :get_user, only: %i[edit update] before_action :valid_user, only: %i[edit] before_action :check_expiration, only: %i[edit] def new; end def create @user = User.find_by(email: params[:password_resets][:e...
# Problem 263: An engineers' dream come true # http://projecteuler.net/problem=263 # # Consider the number 6. The divisors of 6 are: 1,2,3 and 6. # Every number from 1 up to and including 6 can be written as a sum of distinct divisors of 6: # 1=1, 2=2, 3=1+2, 4=1+3, 5=2+3, 6=6. # A number n is called a practical numb...
require 'fastercsv' ## # Imports contacts from a CSV file class Graybook::Importer::Csv < Graybook::Importer::Base DEFAULT_COLUMNS = [:name,:email,:misc] ## # Matches this importer to a file that contains CSV values def =~(options) options && options[:file].respond_to?(:open) ? true : false end ##...
class AddColumnsToProjects < ActiveRecord::Migration def change add_column :websites, :title, :string add_column :websites, :description, :text add_column :brandings, :title, :string add_column :brandings, :description, :text end end
$:.push File.expand_path("../lib", __FILE__) # Maintain your gem's version: require "dynamic_nested_forms/version" # Describe your gem and declare its dependencies: Gem::Specification.new do |s| s.name = "dynamic_nested_forms" s.version = DynamicNestedForms::VERSION s.authors = ["Nikolay Lipovtse...
require File.join(File.dirname(__FILE__), '..', '..', '..', '..', 'main', 'ruby', 'maven', 'tools', 'rails_project.rb') describe Maven::Tools::RailsProject do before :each do @project = Maven::Tools::RailsProject.new("test") end it 'should load Gemfile from a simple rails application with applied defaul...
class AddCoverToPost < ActiveRecord::Migration def change add_column :comfy_blog_posts, :cover, :text, :default => nil end end
class FavoritesController < ApplicationController before_action :restrict_access! def index render json: current_user.favorites end def create favorite = current_user.create_favorite(favorites_params) if favorite.persisted? render json: favorite, status: :created else render json:...
class SimsCavVehicle < ApplicationRecord if Rails.env == 'development' self.establish_connection :sims_development elsif Rails.env == 'production' self.establish_connection :sims_production end self.table_name = "cav.tb_visitante_veic" self.primary_key = "visveicid" scope :carros, -> (query) ...
# This migration comes from advertisement_management (originally 20130802020750) class CreateAdvertisementLists < ActiveRecord::Migration def change unless ActiveRecord::Base.connection.table_exists?('advertisement_lists') create_table "advertisement_lists" do |t| t.integer "advertisement_id" ...
require 'spec_helper' describe FriendNotify do let(:sender) { FactoryGirl.create(:user) } let(:accepter) { FactoryGirl.create(:user) } describe "#friend_request" do let(:mail) { FriendNotify.friend_request(sender.id, accepter.id) } it 'renders the subject' do mail.subject....
require 'json' require 'fileutils' require 'uri' require 'open3' require_relative 'generator' require_relative 'network' require_relative 'boxes_manager' require_relative 'repo_manager' require_relative 'out' class Session attr_accessor :boxes attr_accessor :configs attr_accessor :versions attr_accessor :co...
class ProfileManager < ApplicationRecord belongs_to :social, optional: true belongs_to :address, optional: true belongs_to :user, optional: true belongs_to :contact, optional: true belongs_to :rank, optional: true belongs_to :skill, optional: true end
class TeamsController < ApplicationController before_action :authenticate_user!, except: %i[index show] def index @event = Event.friendly.find(params[:event_id]) @teams = @event.teams if user_signed_in? @user_team = @event.participant(current_user).team end end def show @team = Team....
require 'spec_helper' describe EventParticipant do context "join a event" do before(:each) do @user = create(:user) @event = create(:event) ep_info = {:telephone => '13472466606', :user_id => @user.id, :email => @user.email, :note => "here is ...
# frozen_string_literal: true feature 'New user', js: true do before(:each) do @user = User.new @home_page = HomePage.new @home_page.load expect(@home_page.header.text).to include 'Redmine@testautomate.me' end scenario 'Register new user' do @home_page.menu.sigh_up_link.click sign_up_us...
class CreateEolTaxonConcepts < ActiveRecord::Migration def change create_table :eol_taxon_concepts do |t| t.integer :query_id t.timestamps end add_index :eol_taxon_concepts, :query_id end end
# frozen_string_literal: true module RubyNext VERSION = "0.8.0" end
require 'credova/api' module Credova module Payments extend Credova::API ENDPOINTS = { lowest_payment_option: "calculator/store/%s/amount/%s/lowestpaymentoption".freeze, lender_payment_options: "calculator/lender/%s/amount/%s".freeze, store_payment_options: "calculator/store/%s/amount/%...
require './lib/node' require './lib/linked_list' class JungleBeat attr_reader :list def initialize @list = LinkedList.new end def append(sounds) split_sounds = sounds.split(" ") split_sounds.each {|sound| @list.append(sound)} end def count @list.count end def play `say -r 200 #{...
class Venue < ActiveRecord::Base has_many :venue_activities has_many :activities, through: :venue_activities def coordinates [long, lat] end def activity_names activities.map(&:name) end def to_geojson properties_map = Activity::KINDS.inject({}) do |activity_map, activity| activity_ma...
require 'rails_helper' RSpec.describe FamilyMember, type: :model do describe "with valid attributes" do let(:family_member) {FamilyMember.create(first_name: "Sample", last_name: "Example", dob: "1991-01-01", email: "sample@example.com")} it "family member is created" do expect(family_member).to_not be_...
FactoryGirl.define do factory :bike do maker_name "merida" year 2017 bike_series "Ride" bike_name "Ride3000" frame_type 1 rear_derailleur "105" front_derailleur "105" crank "オリジナル" brake "105" chain "105" sprocket "105" sti_lever "105ミックス" ...
class FontNotoSerifNpHmong < Formula head "https://github.com/google/fonts/raw/main/ofl/notoserifnphmong/NotoSerifNPHmong%5Bwght%5D.ttf", verified: "github.com/google/fonts/" desc "Noto Serif NP Hmong" homepage "https://fonts.google.com/specimen/Noto+Serif+NP+Hmong" def install (share/"fonts").install "Noto...
require "cfnresponse/version" require "json" require "net/http" require "uri" module Cfnresponse class Error < StandardError; end # Debugging puts kept to help debug custom resources def send_response(event, context, response_status, response_data={}, physical_id="PhysicalId", reason=nil) reason ||= "See th...
# encoding: utf-8 require 'erb' require 'json' module Global module Base extend self attr_writer :environment, :config_directory, :namespace, :except, :only def configure yield self end def configuration @configuration ||= load_configuration(config_directory, environment) end ...
class Bookmark < ApplicationRecord belongs_to :movie, dependent: :destroy belongs_to :list validates :comment, length: { minimum: 6 } validates :list, uniqueness: { scope: :movie, message: 'should be unique :)' } end
# -*- mode: ruby -*- # vi: set ft=ruby : current_dir = File.dirname(__FILE__) require 'json' nagios_id = JSON.parse(File.read "#{current_dir}/data_bags/drupal_sites/demo-local.json")['nagios_id'] Vagrant.configure("2") do |config| config.vm.box = "lucid64" config.vm.box_url = "http://files.vagrantup.com/lucid64....
# frozen_string_literal: true module AttrEncrypted # Contains information about this gem's version module Version MAJOR = 4 MINOR = 0 PATCH = 0 # Returns a version string by joining <tt>MAJOR</tt>, <tt>MINOR</tt>, and <tt>PATCH</tt> with <tt>'.'</tt> # # Example # # Version.strin...
module ValidJson module Validator class ObjectValidator < GeneralValidator def validate(data) super + validate_properties(data) + validate_required(data) end private def validate_properties(data) return [] unless @schema["properties"] errors = [] ...
class CreateAnglePosts < ActiveRecord::Migration def self.up create_table :angle_posts, :force => true do |t| t.string :content,:limit=>210 t.string :logo,:limit=>50 t.integer :angle_comments_count,:default=>0 t.boolean :is_hide,:default=>false t.integer :age_id t.integer :tag_...
# All Vagrant configuration is done below. The "2" in Vagrant.configure # configures the configuration version (we support older styles for # backwards compatibility). Please don't change it unless you know what # you're doing. Vagrant.configure(2) do |config| # Every Vagrant development environment requires a box...
require "bundler/capistrano" # use local SSH keys ssh_options[:forward_agent] = true set :application, "constellation" set :user, "dkd" set :scm, :git set :deploy_via, :copy set :repository, "git@git.dkd.de:constellation-app.git" set :use_sudo, false set :deploy_to, "/var/www/demo.constellatio...
class AddForUserPrices < ActiveRecord::Migration def change add_column :users, :user_prices, :string end end
# #= User の属性、アソシエーションを管理するモジュール # module Concerns::Page::Association extend ActiveSupport::Concern included do belongs_to :genre, class_name: 'Genre' has_many :section_news, class_name: 'SectionNews', dependent: :destroy has_many :contents, -> { order('page_contents.id DESC') }, class_nam...
require_relative '../data/invoice.rb' class PostInvoice attr_accessor :params def initialize(params) @params = params end def response { data: InvoiceData.new(params).to_hash, affordances: [] } end end
=begin Get all the records with an agency and a sudoc. Stem the sudoc and normalize the agency. Make hash with key=sudoc stem and value=agency. =end require 'htph'; require 'json'; require 'set'; class Array def slurp (filename) # for slurping lists of lines from file into array HTPH::Hathidata.read(filename) d...
class AddCancelToNotification < ActiveRecord::Migration def change add_column :notifications, :cancel, :boolean, :after => :read end end
require 'rails_helper' RSpec.describe OrderAddress, type: :model do before do @order = FactoryBot.build(:order_address) end describe '商品購入機能' do context '購入ができる' do it 'すべての値が正しく入力されていれば、購入できる' do expect(@order).to be_valid end it '建物名の記載がなくても、購入できる' do @order.buildi...
require 'date' class Lesson1 def sum(val = 0) val.to_s.split('').map(&:to_i).inject(0, :+) end def age(birthday) if birthday birthday = Date.parse(birthday) today = Date.today age = today.year - birthday.year age_in_days = today - birthday "Я живу #{age} года или #{age_in_da...