text stringlengths 10 2.61M |
|---|
require 'securerandom'
require 'rack-rabbit'
require 'rack-rabbit/adapter'
require 'rack-rabbit/message'
require 'rack-rabbit/response'
module RackRabbit
class Client
#--------------------------------------------------------------------------
attr_reader :rabbit
def initialize(options = nil)
@r... |
# Package description
Package.new(
name: 'EventExtender4',
version: vsn(4, 6, 4),
authors: {
'Grim' => 'grimfw@gmail.com'
},
components: ['EE.rb'],
description: 'Event-making is a thankless discipline because it often requires a lot of patience to do things that can be very easy to conceive (I\'m thinking of... |
class User < ActiveRecord::Base
has_secure_password
has_many :products
has_many :version_users
has_many :versions, through: :version_users
def slug
self.username.gsub(" ", "-").downcase
end
def self.find_by_slug(slug)
self.all.find{ |instance| instance.slug == slug }
end
def claimed_tasks # o... |
# include Rails.application.routes.url_helpers
class ActivitySerializer < ApplicationSerializer
object_as :activity, model: "PublicActivity::Activity"
attributes(
:id,
:trackable_type,
:trackable_id,
:owner_type,
:owner_id,
:key,
:parameters,
:recipient_type,
:recipient_id,
... |
require 'active_model'
class EmailAlertSignup
include ActiveModel::Model
validates_presence_of :signup_page
attr_reader :subscription_url
def initialize(signup_page)
@signup_page = signup_page
@base_path = signup_page['base_path'] if signup_page
end
def save
if valid?
@subscription_ur... |
class CreateClusterStates < ActiveRecord::Migration
def self.up
create_table :cluster_states do |t|
t.integer :minion_count, null: false, default: 0
end
end
def self.down
drop_table :cluster_states
end
end
|
require_relative 'replacement_cipher'
require_relative 'vigenere_cipher'
ALPHABET = [
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'Ñ', 'O', 'P', 'Q', 'R', 'S',
'T', 'U', 'V', 'W', 'X', 'Y', 'Z'
]
EMPTY_DICTIONARY = {
'A' => nil,
'B' => nil,
'C' => nil,
'D' => nil,
'E' => nil,
... |
class AddAdditionalProfileQuestionsToUsers < ActiveRecord::Migration
def change
add_column :users, :fun_fact, :string
add_column :users, :fitness_goal, :string
end
end
|
class Patient
attr_accessor :name, :doctors, :appointments
def initialize(name)
@name = name
@appointments = Array.new
@doctors = Array.new
end
def add_appointment(appt_object)
appt_object.patient = self
@appointments << appt_object
@doctors << appt_object.doctor if !@docto... |
# frozen_string_literal: true
$LOAD_PATH.unshift(File.expand_path("../../lib", __FILE__))
require "kafka"
logger = Logger.new(STDOUT)
brokers = ENV.fetch("KAFKA_BROKERS", "localhost:9092").split(",")
# Make sure to create this topic in your Kafka cluster or configure the
# cluster to auto-create topics.
topic = "te... |
class Root < Grape::API
helpers do
def current_user
User.find_by(email: headers['Uid'])
end
def authorize()
error!('401 Unauthorized', 401) unless current_user
end
end
version 'v1'
mount Estates
end
|
class RenameRolesToProducts < ActiveRecord::Migration
def change
rename_table :roles, :products
end
end
|
require 'spec_helper'
RSpec.describe Qualtrics::API::ResponseImportResource do
subject(:resource) { described_class.new(connection: connection) }
include_context 'resources'
describe '#import' do
it 'returns the id of the imported responses' do
response = api_fixture('response_imports/import')
a... |
FactoryBot.define do
factory :member do
association :user, name: 'Juanito'
end
end
|
class User < ApplicationRecord
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable #standaard devise validaties
validates_presence_of :fir... |
# frozen_string_literal: true
class TwoFactorResetJob < ApplicationJob
queue_as :default
def perform(user)
user.update!(two_factor_code: SecureRandom.urlsafe_base64(nil, false))
end
end
|
class User < ActiveRecord::Base
validates :email, :password_digest, :session_token, :fname, presence: true
validates :email, :session_token, uniqueness: true
validates :password, length: { minimum: 6, allow_nil: true }
after_initialize :ensure_session_token
attr_reader :password
has_many :comments, depende... |
class CreateAccounts < ActiveRecord::Migration
def change
create_table :accounts do |t|
t.string :number
t.string :company
t.string :inn
t.string :kpp
t.string :bik
t.string :agreement_number
t.datetime :date
t.string :accountable_type
t.integer :accountable_i... |
class Mailer < ActionMailer::Base
default_url_options[:host] = Gemcutter::HOST
default_url_options[:protocol] = Gemcutter::PROTOCOL
def email_reset(user)
@user = user
mail from: Clearance.configuration.mailer_sender,
to: user.email,
subject: I18n.t(:confirmation,
scope: [:cle... |
class CreateAdminCatalogTranslations < ActiveRecord::Migration
def change
create_table :admin_catalog_translations do |t|
t.string :locale, :null => false
t.integer :admin_catalog_id
t.string :name
t.timestamps
end
add_index :admin_catalog_translations, :admin_catalog... |
class AddNotesToBundles < ActiveRecord::Migration
def change
add_column :bundles, :notes, :string
end
end
|
# frozen_string_literal: true
class Course::Survey::Response < ActiveRecord::Base
include Course::Survey::Response::TodoConcern
acts_as_experience_points_record
belongs_to :survey, inverse_of: :responses
has_many :answers, inverse_of: :response, dependent: :destroy
accepts_nested_attributes_for :answers
... |
class Post < ApplicationRecord
extend FriendlyId
mount_uploader :avatar, AvatarUploader
validate :avatar_size_validation
validates :challenge_id, :title, :content, presence: true
validates_presence_of :challenge_id, :title, :content, on: :update
validates :title, length: {maximum: 75}
validates :conten... |
module PUBG
class Player
require "pubg/player/links"
require "pubg/player/data"
require "pubg/player/matches"
require "pubg/player/season"
def initialize(args, s=false)
@s = s
@args = args
end
def original
@args
end
def data
if @s
data = []
@args["data"].each do |player|
... |
class ContractMailer < ApplicationMailer
default from: 'info@example.com'
def contracted(user)
@user = user
@url = 'http://example.com/contracts/index'
mail(to: "eveve0418@gmail.com", from: "info@example1.com" ,subject: 'ご契約が成立しました!')
end
end
|
require 'fastercsv'
require 'yahoo'
require 'dm-core'
require 'do_sqlite3'
require 'json'
require 'digest/md5'
ENV['DATABASE_URL'] ||= "sqlite3://#{Dir.pwd}/db.sqlite3"
case ENV['DATABASE_URL']
when /postgres/
require 'do_postgres'
when /mysql/
require 'do_mysql'
when /sqlite/
require 'do_sqlite3'
end
DataMappe... |
class Context
attr_accessor :input, :output
def initialize(input)
@input = input
@output = 0
end
end
|
module Featurable
extend ActiveSupport::Concern
included do
has_many :featured, class_name: 'ResourceFeatured', as: :resource
scope :only_featured, -> {
joins("LEFT JOIN resource_featured ON resource_featured.resource_id = #{table_name}.id")
.select("#{table_name}.*, count(resource_featured.id... |
class Dogpicture < ActiveRecord::Base
attr_accessible :title, :intro, :file, :dog_id
belongs_to :dog
mount_uploader :file, DogpictureUploader
end
|
class CommentsController < ApplicationController
before_action :set_team_and_task
def create
@comment = @task.comments.create(comment_params)
authorize @comment
redirect_to team_task_path(@team, @task), info: 'Комментарий добавлен'
end
def destroy
@comment = @task.comments.find(params[:id])
... |
module Api
module V1
class ApiController < ApplicationController
skip_before_action :verify_authenticity_token
def candidate_schedules
# curl -X GET http://localhost:3000/api/v1/candidate_schedules/?count=2
count = params[:count].to_i
schedules = get_schedules
if (coun... |
# Something, something, darkside.
module Shanty
RSpec::Matchers.define(:subscribe_to) do |event|
match do |actual|
expect(actual.instance_variable_get(:@class_callbacks)).to include(event => @callbacks)
end
chain(:with) do |*callbacks|
@callbacks = callbacks
end
end
end
|
class AddFk1ToSubjectDetails < ActiveRecord::Migration
def up
add_foreign_key "subject_details", "subjects", name: "sub_deta_fk1"
end
def down
remove_foregin_key "subject_details", name: "sub_deta_fk1"
end
end
|
class AddSpeciesColumnToCaughtpokemon < ActiveRecord::Migration[6.0]
def change
add_column :caught_pokemons, :species, :string
end
end
|
class AddFormUrlToPrograms < ActiveRecord::Migration
def change
add_column :programs, :form_url, :string
end
end
|
class Api::PhonesController < Api::BaseController
def index
has_params!(:shouji) or return
@phone = Phone.search(params[:shouji])
api_success(message: '请求成功', data: @phone.json_builder)
end
end
|
# Get a list of cluster nodes to monitor
cluster_nodes_objs = get_all_nodes.compact
graphite_query_time = "#{node["bcpc"]["hadoop"]["zabbix"]["graphite_query_time"]}m"
triggers_sensitivity = "#{node["bcpc"]["hadoop"]["zabbix"]["triggers_sensitivity"]}m"
head_nodes_objs = get_head_nodes(true)
bootstrap_hostname = get_... |
module YouTubeR
using Rafini::Odometers
def self.dump(results)
puts JSON.pretty_generate results
end
def self.report(results, color=CONFIG[:SoftColor].to_sym)
length = results['items'].length
puts
results['items'].each do |item|
# init
title=type=published=channel=description=nil
... |
class CreateCustomers < ActiveRecord::Migration[5.2]
def change
create_table :customers do |t|
t.string :first_name
t.string :last_name
t.string :middle_initial
t.datetime :date_of_birth
t.string :gender
t.string :email_address
end
end
end
|
class Photo < ActiveRecord::Base
attr_accessible :url, :user_id
belongs_to :user
end
|
#
# Author:: Celso Fernandes (<fernandes@zertico.com>)
# © Copyright IBM Corporation 2014.
#
# LICENSE: MIT (http://opensource.org/licenses/MIT)
#
require 'fog/core/collection'
require 'fog/softlayer/models/compute/server'
module Fog
module DNS
class Softlayer
class Domains < Fog::Collection
mode... |
require 'redmine'
require 'redmine_subtasks'
Redmine::Plugin.register :redmine_subtasks do
name 'Redmine Subtasks Plugin'
url 'https://github.com/patajones/redmine_subtasks'
author 'Bernardes (originalmente rodrigoa)'
author_url 'mailto:Grupo SCORP <grupo.scorp@stj.jus.br>?subject=redmine_subtasks'
descr... |
class ScoresController < ApplicationController
def show
@score = Score.find(params[:id])
end
def new
@score = Score.new
if params[:workout_id].nil?
redirect_to root_url, :error => "Could not find workout" if @workout.nil?
else
@workout = Workout.find(params[:workout_id])
end
end... |
class TorrentBot
DOWNLOAD_ROOT = File.join(ENV["HOME"], "Downloads").freeze
DESTINATION_ROOT = File.join("/", "mnt", "5TB").freeze
PROCESSORS = []
def self.lib_root
File.join(File.expand_path(File.dirname(__FILE__)), "torrent-bot")
end
def self.logs_root
File.join(File.expand_path("..", File.dirna... |
#!/usr/bin/env ruby
#
#
# Handles parsing and tests done on RSS items.
#
require 'open-uri'
require 'lib/downloaded'
class ItemHandler
def initialize(feed, log)
@feed = feed
@log = log
end
def name
@url = URI.parse(@item.enclosure.url)
if @item.description[/Filename: (... |
require 'unit/spec_helper'
describe 'sprout-terminal::update_font' do
let(:chef_run) { ChefSpec::Runner.new }
let(:file) { '/home/fauxhai/Library/Preferences/com.apple.Terminal.plist' }
let(:plist_cmd) { '/usr/libexec/PlistBuddy -c' }
let(:font_path) { '/var/chef/cache/customFont.bin' }
before do
Mixlib... |
require 'spec_helper'
describe Organization do
before do
@organization = FactoryGirl.create(:populated_organization)
@unit1 = @organization.units.first
@unit2 = FactoryGirl.create(:unit, :organization => @organization)
@hub1 = @organization.hubs.first
@hub2 = FactoryGirl.create(:hub, :unit => ... |
class CreateAutos < ActiveRecord::Migration
def change
create_table :autos do |t|
t.string :brand, null: false, limit: 40
t.string :model, null: false, limit: 40
t.string :series, null: false, limit: 40
t.string :color, null: false, limit:... |
# frozen_string_literal: true
module FacebookAds
# https://developers.facebook.com/docs/marketing-api/reference/product-catalog
class AdProductCatalog < Base
FIELDS = %w[id name vertical product_count feed_count].freeze
class << self
def all(query = {})
get("/#{FacebookAds.business_id}/owned... |
logger = Shoryuken::Logging.initialize_logger(STDOUT)
logger.formatter = Proc.new { |severity, datetime, progname, msg| "[#{SecureRandom.uuid}] [#{datetime.strftime("%B %d %H:%M:%S")}] [#{$$}] [#{severity}] [#{Rails.application.class.parent_name}], #{msg}\n"}
logger.level = Logger::INFO
Rails.logger = logger
module Sh... |
module Product
def use
raise NotImplementedError.new("#{self.class}##{__class__}が実装されていません。")
end
end
|
#!/usr/bin/ruby -w
require 'dbi'
begin
# connect to the MySQL server
dbh = DBI.connect("DBI:Mysql:TESTDB:localhost", "testuser", "test123")
dbh.do( "INSERT INTO EMPLOYEE(FIRST_NAME,
LAST_NAME,
AGE,
SEX,
INCOME)
VALUES ('MAC', 'Mohan', 20, '... |
class Deck < ActiveRecord::Base
has_and_belongs_to_many :users
has_many :cards, order: 'position'
attr_accessible :name
end
|
feature "User sign up" do
scenario "users can sign up to chitter with their details" do
register_user
expect(page).to have_content("Thank you for registering to chitter")
end
end
|
require 'test_helper'
class AdminLinksTest < ActionDispatch::IntegrationTest
VARIATIONS = %w(a b c d e f g)
def setup
stub_request(:head, "http://www.mit.edu/").
to_return(status: 200)
stub_request(:head, "http://github.com/inertia186/cobblebot").
to_return(status: 200)
VARIATIONS.... |
require_relative '../lib/item'
describe Item do
before { @product = described_class.new('code', 'name', 10.99) }
it { expect(@product.code).to eq('code') }
it { expect(@product.name).to eq('name') }
it { expect(@product.price).to eq(10.99) }
end
|
class HomePage < SitePrism::Page
#set_url Rails.application.routes.url_helpers.root_path
set_url '/'
element :search_field, 'input#q'
element :search_button, 'button#search-button'
def search_for(query)
search_field.set(query)
search_button.click
end
end |
require 'socket'
require 'cgi'
HOST = ARGV[0] || '127.0.0.1'
PORT = ARGV[1] || '8080'
SERVER = TCPServer.new(HOST, PORT)
MINE_TYPES = {} # quick access to mime types based on file ext (key = extension, value = mime type)
# parse definitions of supported extensions (last item per line is the mine type)
File.read(File.... |
#数値オブジェクト -Numeric Class
x = 10 #整数値
y = 20.5 #実数値
z = 1/3 # 文数値 Retional(1,3)
=begin
アンダーバーを無視する仕様があるので
100_000_000などがあり。
=end
# + - * / % **の計算ができる。
p x % 3 #1
p y ** 3 #1000
p z * 2 #2/3
#自己代入
x = x+5
#は
X += 5
#と表せる
p x #15
#ラウンドメソッド四捨五入
p y .round |
SCHEDULER.every '60s' do
send_event('usage', { current: 0 })
end |
class Symptom < ApplicationRecord
belongs_to :symptom_group
has_many :check_in_symptoms, dependent: :destroy
has_many :supplements, through: :effects
has_many :effects
validates :name, :description, :symptom_group, presence: true
delegate :points, :icon, to: :symptom_group
class << self
def for_use... |
# frozen_string_literal: true
module FilesForEds
FILES_NAMES = ["ПСП-0.01-16_Положение об отделе менеджмента качества образования",
"ПСП-0.03-18_Положение о РМЦ ДОД",
"ПСП-0.04-19_Положение об ОБТиСК",
"ПСП-0.05-19_Положение об ОКиНОД",
"ПСП-0.06-19_Положение об ОСИД с изменениями от 31.03.2021г",
... |
module Hadupils::Search
# Searches for directory containing a subdirectory `name`, starting at
# the specified `start` directory and walking upwards until it can go
# no farther. On first match, the absolute path to that subdirectory
# is returned. If not found, returns nil.
def self.find_from_dir(name, sta... |
pg_dba = input('pg_dba')
pg_dba_password = input('pg_dba_password')
pg_db = input('pg_db')
pg_host = input('pg_host')
pg_version = input('pg_version')
control "V-72845" do
title "Security-relevant software updates to PostgreSQL must be installed
within the time period directed by an authoritative source (e.g.,... |
class ReviewForm < ActiveRecord::Base
belongs_to :cubicle_label, :foreign_key => :cubicle_id
belongs_to :user, :foreign_key => :user_id
belongs_to :account
has_many :review_form_review_questions, :dependent => :destroy
has_many :review_questions, :through => :review_form_review_questions, :uniq => true #, :jo... |
# frozen_string_literal: true
FactoryBot.define do
factory :ticket do
event
cost { 0 }
limit { nil }
label { SecureRandom.uuid }
identifier { rand(100..149) }
shift_responsibilities { 0 }
pass_type { :event_pass }
Ticket.pass_types.each do |key, _value|
trait key.to_sym do
... |
#Fedena
#Copyright 2011 Foradian Technologies Private Limited
#
#This product includes software developed at
#Project Fedena - http://www.projectfedena.org/
#
#Licensed under the Apache License, Version 2.0 (the "License");
#you may not use this file except in compliance with the License.
#You may obtain a copy of the ... |
class AddTimestampToKeychain < ActiveRecord::Migration
def change
remove_column :keychains, :timestamp
add_column :keychains, :created_at, :datetime
add_column :keychains, :updated_at, :datetime
end
end
|
#!/usr/bin/env ruby
if ARGV.empty?
STDERR.puts "Usage:\n\n\t#{__FILE__} github-user/repo-name"
STDERR.puts "\nProvide authentication details via the GITHUB_USER and GITHUB_PASSWORD env vars."
exit 1
end
repo = ARGV.first
require 'octokit'
# Provide authentication credentials
Octokit.configure do |c|
c.login... |
class FontSignikaNegativeSc < Formula
head "https://github.com/google/fonts.git", verified: "github.com/google/fonts", branch: "main", only_path: "ofl/signikanegativesc"
desc "Signika Negative SC"
desc "Alternative version of the Signika SC font"
homepage "https://fonts.google.com/specimen/Signika+Negative"
d... |
class AddUniqueConstraintToTemplateName < ActiveRecord::Migration[6.0]
def change
add_index :templates, :name, :unique => true
end
end
|
module Fog
module Brightbox
module Storage
class ManagementUrlUnknown < Fog::Errors::Error
end
class AuthenticationRequired < Fog::Errors::Error
end
end
end
end
|
Pod::Spec.new do |spec|
spec.name = "ZeroAuthCielo"
spec.version = "1.0.2"
spec.summary = "Biblioteca de validação de cartões de crédito"
spec.description = <<-DESC
Biblioteca Cielo/Braspag de validação de cartões de crédito.
DESC
spec.homepage = "https://github.... |
#!/usr/bin/env ruby
#coding: utf-8
system 'clear'
require 'gepub'
require 'fileutils'
builder = GEPUB::Builder.new {
language 'en'
unique_identifier 'http:/example.jp/bookid_in_url', 'BookID', 'URL'
title 'GEPUB Sample Book'
subtitle 'This book is just a sample'
creator 'KOJIMA Satoshi'
contributors 'De... |
class Meeting < ApplicationRecord
belongs_to :user
belongs_to :room
has_many :attendees, dependent: :destroy
has_many :attendee_users, through: :attendees, source: :user
validates_presence_of :description, :start_time, :end_time
accepts_nested_attributes_for :attendees, allow_destroy: true
ransacke... |
class ClientsController < ApplicationController
before_filter :authenticate_user!
before_filter :check_for_release
def index
end
def new
@client = Client.new
@client.build_logo
end
def create
@client = current_user.clients.new(params[:client])
if @client.save
create_asset if... |
#!/usr/bin/env ruby
# file: humble_rpi-plugin-vibrationsensor.rb
require 'rpi_pinin_msgout'
require 'chronic_duration'
# Hardware test setup:
#
# * vibration sensor (SW-18010P) only connected between a GPIO pin and ground
#
# Trigger an event
#
# * To trigger a vibration event, tap the sensor at any angle
class H... |
module ApplicationConcern
extend ActiveSupport::Concern
included do
helper_method :set_resource, :model_params
end
def set_resource
model_name.find_by!(id: params[:id], user: current_user)
end
def model_params(model)
params.require(model).permit(model_name::PARAMS)
end
private
def mod... |
#
# Cookbook Name:: jenkins
# Based on hudson
# Resource:: remote_host_config
#
# Author:: Valeriu Craciun
#
actions :create
attribute :url, :kind_of => String
attribute :description, :kind_of => String
attribute :job_name, :kind_of => String
attribute :config_template, :kind_of => String
attribute :remote_host, :kin... |
class CountriesController < ApplicationController
def show
country = Country.find(params[:id])
respond_to do |format|
format.js do
render :json => country.to_json
end
end
end
end
|
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
module PostSweeperSpecHelper
def valid_post_attributes
{
:title => 'Post Title',
:publish_date => Date.today,
:body => 'Phasellus pulvinar, nulla non *aliquam* eleifend, "tortor":http://google.com wisi scelerisque felis, in s... |
class GenerateProductsGroupJob < ActiveJob::Base
queue_as :default
def perform(job, select_params)
# logger.info "start job #{job.id}"
@select_params = select_params
categories = @select_params.map {|id, brands| id }
@categories = Category.where(id: categories).order(:id)
@all_categories = @ca... |
class Listing < ActiveRecord::Base
validates :price, numericality: true, allow_nil: false
end
|
# frozen_string_literal: true
FactoryBot.define do
factory :comment do
content { 'MyText' }
user
for_case # default to the :for_comment trait if none is specified
trait :for_case do
association :commentable, factory: :case
end
end
end
|
require 'spec_helper'
describe "LayoutLinks" do
it "should have a Home page at '/'" do
get '/'
response.should have_selector('title', :content => "Home")
end
it "should have a Contact page at '/splash'" do
get '/splash'
response.should have_selector('title', :content => "Splash")
end
it "s... |
require 'spec_helper'
describe "Timeline tooltip", reset: false do
before :all do
Capybara.reset_sessions!
page.driver.resize_window(1280, 1024)
load_page :search, project: ['C179003030-ORNL_DAAC'], view: :project
pan_timeline(-16.days)
wait_for_xhr
end
context "when viewing month zoom level... |
require 'test_helper'
class OrderTest < ActiveSupport::TestCase
test "Order with minimal information is valid" do
assert orders(:valid_order).valid?
end
test "Paid orders must have a cc_number" do
assert orders(:no_cc_number).invalid?
end
test "Paid orders must have a cc_expiration" do
assert ... |
input_file = ARGV.first
# call the read method on 'f'
def print_all(f)
puts f.read
end
# call the seek method on the 'f' with a parameter of 0
def rewind(f)
f.seek(0)
end
def print_a_line(line_count, f)
# the gets method is called on 'f' to take input from the file.
puts "#{line_count}, #{f.gets.chomp}"
end
c... |
# `gem update --system` says:
#
# ERROR: While executing gem ... (RuntimeError)
# gem update --system is disabled on Debian, because it will overwrite the content of the rubygems Debian package, and might break your Debian system in subtle ways. The Debian-supported way to update rubygems is through apt-get, using... |
class Film
# -------------------------------------------------------------------
# Sous-classe Film.Scenes
# -------------------------------------------------------------------
class Scenes
# Instance du film
attr_reader :film
def initialize film
@film = film
end
# Retourne... |
module CDI
module V1
class PresentationSerializer < SimplePresentationSerializer
has_one :learning_track, serializer: SimpleLearningTrackSerializer
has_one :user, serializer: SimpleUserSerializer
has_many :slides, serializer: SimplePresentationSlideSerializer
end
end
end
|
class GroupWaitingsController < ApplicationController
before_action :set_group_waiting, only: [:destroy]
def create
@group_waiting = GroupWaiting.new(group_waiting_params)
if @group_waiting.save
flash[:success] = '그룹 가입신청 되었습니다.'
redirect_to :back
else
render action: 'new'
end
... |
class Image < ActiveRecord::Base
has_attached_file :avatar, :styles => { :large => "1000x350>", :thumb => "350x150!" }, :default_url => "missing.png"
validates_attachment_content_type :avatar, :content_type => /\Aimage\/.*\Z/
belongs_to :imageable, :polymorphic => true
end
|
require 'rails_helper'
RSpec.describe Review, :type => :model do
context 'review score validation' do
it 'is valid with a rating between 1 and 5 and associated with a restaurant' do
restaurant = Restaurant.create(name: 'Nandos', location_name: 'Shoreditch')
review = restaurant.reviews.new(rating: 5)
... |
class TopMenu < ApplicationRecord
has_many :sub_menus
end
|
class AddsNullsToUsers < ActiveRecord::Migration
def change
change_column :users, :orientation, :string, null: false
change_column :users, :gender, :string, null: false
change_column :users, :country, :string, null: false
change_column :users, :zip_code, :integer, null: false
end
end
|
require 'open3'
module XbindR
class Prediction
WIN_LEN_35 = 11
WIN_LEN_60 = 21
attr_accessor :res_seq, :cutoff, :res_status, :res_ri
attr_accessor :runtimestamp, :runtime_root, :fn_root, :winlength
attr_accessor :seq_fn, :pssm_assic_fn, :pssm_chk_fn, :psipass2_fn, :rfmat_fn
attr_accessor :n... |
class Profile < ApplicationRecord
has_one_attached :image
belongs_to :user
validates :user_id, uniqueness: true
end
|
#! /usr/bin/env ruby
require 'log2carbon'
## get the configuration first, most of the config applies to the daemon
app_options_index = ARGV.index("--")
app_options = app_options_index ? Hash[*ARGV[(app_options_index + 1)..-1]] : {}
config_filename = app_options["-c"] || "/etc/log2carbon/log2carbon.conf"
app_e... |
require "downloader"
require "downloader/util"
require "downloader/errors"
RSpec.describe Downloader::Util do
describe '#rename_to_number' do
it 'returns a filename containing a number and the original file extension' do
expect(Downloader::Util.rename_to_number("cat.jpg", 2)).to eq("2.jpg")
end
it... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.