text stringlengths 10 2.61M |
|---|
require 'rails_helper'
\
describe Organization do
context 'attributes' do
before(:each) do
@organization = Organization.new({login: 'github', avatar_url: 'https://github.com/images/error/octocat_happy.gif'})
end
it 'has a name' do
expect(@organization.name).to eq('github')
end
it 'has... |
class StageCommonOption < ActiveRecord::Base
belongs_to :group
has_one :fes_year, through: :group
# 存在チェック
validates :group_id, :stage_content, presence: true
validates :group_id, uniqueness: true
validates :own_equipment, :bgm, :camera_permittion, :loud_sound, inclusion: {in: [true, false]}
end
|
# frozen_string_literal: true
require 'test_helper'
module Vedeu
module Input
describe Keymap do
let(:described) { Vedeu::Input::Keymap }
let(:instance) { described.new(attributes) }
let(:attributes) {
{
name: map_name,
keys: keys
}
}
let(:... |
module CronSpec
##
# Represents a wildcard value
#
class WildcardCronValue < CronValueBase
##
# Constructs a new WildcardCronValue with the specified limits.
#
def initialize(lower_limit, upper_limit)
super(lower_limit, upper_limit)
end
##
# Returns true if the specified val... |
FactoryGirl.define do
factory :question do
question_template
association :template_questionable, factory: :learning_track
categories { [create(:category)] }
factory :question_with_answers do
transient do
answers_count 5
end
after(:create) do |question, evaluator|
cr... |
class Category < ActiveRecord::Base
belongs_to :food_type
belongs_to :ecommer
end
|
class AddTypeTwoToPokemons < ActiveRecord::Migration[5.2]
def change
add_column :pokemons, :type_two, :string
end
end
|
require "pathname"
class LibraryInteractor
attr_accessor :library
def initialize
self.library = Pathname.new(ComicDirectory)
end
def get_folders
self.library.children.select { |c| c.directory? }
end
end
|
##
# La classe représente un bouton dans la grille du jeu
##
# * +couleur+ la couleur actuellement appliquée au bouton
# * +boutton+ Instance de la classe Gtk::Button
class Boutton
##
# * +css+ Le css a appliquer sur le boutton à l'init
def Boutton.creer(css)
new(css)
end
private_cla... |
require 'json'
def main
puts "Starting..."
file = File.read('db/questions.json')
data = JSON.parse(file)
num_complete = 0
data.each_with_index do |question|
puts "Num of Qs in DB: #{num_complete}" if num_complete % 1000 == 0
create_question(question)
num_complete += 1
end
puts "DATA: #{num_... |
class UserSerializer < ActiveModel::Serializer
attributes :id, :email, :username
type 'user'
has_many :blogs
end
|
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Emanuel... |
describe Importer::Appeals do
include_context "importer"
let(:record) {{
:case_type=>"Appeal",
:case_subtype=>"Reconsideration",
:status=>"Closed",
:case_no=>"20192106",
:appeal_no => "xyzzy",
:requester=>"Norris, Chuck",
:custodian=>"Executive Office of Public Safety and Security - Mas... |
class Purchase
attr_accessor :number, :amount, :purpose
def initialize(number, amount, purpose)
@number = number
@amount = amount
@purpose = purpose
end
end
|
class AddUnitsToExternals < ActiveRecord::Migration
def change
add_column :externals, :units, :string
end
end
|
class BoardPin < ActiveRecord::Base
attr_accessible :board_id, :description, :pin_id
before_destroy :check_pin_status
belongs_to :board
belongs_to :pin
has_many :favorites
validates_presence_of :board_id, :pin_id
#if original pin no longer connected to any board, delete it
# otherwise would pins wit... |
# frozen_string_literal: true
require 'csv'
require 'octokit'
require_relative './home_maintenance/version'
require_relative './home_maintenance/errors'
require_relative './home_maintenance/task'
require_relative './home_maintenance/time_framer'
# Read data on tasks. Convert them to task objects.
class HomeMaintenan... |
class Item < ApplicationRecord
belongs_to :category
belongs_to :users , dependent: :destroy, optional: true
before_save :name_save
scope :last_n, -> (n) { order('size desc').limit(n)}
scope :user, -> { where(item_id: false)}
after_destroy :delete_item
def name_save
a = self.name
a.capitalize!
a.sa... |
class CreateSearches < ActiveRecord::Migration[5.0]
def change
create_table :searches do |t|
t.text :spot_category
t.text :group_category
t.text :city
end
end
end
|
class Artist < ActiveRecord::Base
has_many :songs
has_many :genres, through: :songs
def slug
name.downcase.gsub(" ", "-")
end
def self.find_by_slug(slug) #use find
self.all.find do |song|
if song.slug == slug
@song = song
end
end
@song
end
... |
class UpdateProfile < Mutations::Command
required do
model :user
end
optional do
string :email
hash :profile do
optional do
string :display_name
string :thumbnail_content
string :thumbnail_url
string :location
string :timezone
float :latitude
... |
require "observer"
require Core::ROOT + "model/Configuration.rb"
## => Author:: DanAurea
## => version:: 0.1
## => copyright:: © 2016
## => license:: Distributes under the same terms as Ruby
##
## Classe permettant de dessiner les cases d'une grille de Sudoku
##
class CaseDessin < Gtk::DrawingArea
... |
require "rgeo/geo_json"
require "pr_geohash"
require "rgeo"
module Geoq
class Entity
attr_reader :entity, :raw
def initialize(entity, raw)
@entity = entity
@raw = raw
end
def as_geojson(feature = false)
geom = RGeo::GeoJSON.encode(entity)
if feature
{type: "Feature",... |
class RenameDateTimesToDateTime < ActiveRecord::Migration[6.0]
def change
rename_column :parties, :date_times, :date_time
end
end
|
#!/usr/bin/env ruby
require 'pathname'
require 'fileutils'
include FileUtils
def detect_os
if `uname`.chomp == "Darwin"
'mac'
elsif `expr substr $(uname -s) 1 5`.chomp == "Linux"
'linux'
end
end
def install_pg_dev
case detect_os
when 'mac'
puts "Attempting Homebrew installation of 'libpq'; if yo... |
class MoviePhoto < ActiveRecord::Base
belongs_to :movie
belongs_to :photo
attr_accessor :association_should_exist
end
|
require 'spec_helper'
feature 'Label Management' do
scenario 'User views labels' do
visit labels_path
expect(page).to have_content 'Abandoned Chats'
end
scenario 'User assigns label to first case' do
visit labels_path
page.first('[value="Assign to first case"]').click
expect(page).to have_... |
json.array!(@orders) do |order|
json.extract! order, :id, :address, :name, :morning_of, :greeting
json.url order_url(order, format: :json)
end
|
class EntriesController < ApplicationController
before_action :find_entry, only: [:show, :edit, :update, :destroy]
def index
@entries = Entry.all
end
def show
# @entry = Entry.find(params[:id])
end
def new
@entry = Entry.new
end
def create
@entry = Entry.new(entry_params)
if @entry.sav... |
class Password
LENGTH_SALT = 4
NUM_ITERATIONS = 10
def self.encode plain_text
salt = self.random_salt
hash = salt + plain_text
NUM_ITERATIONS.times do
hash = Digest::SHA1.hexdigest hash
end
"#{salt}#{hash}"
end
def self.random_salt
SecureRandom.hex[0...LENGTH_SALT]
end
end
|
# frozen_string_literal: true
class ImportLog < ApplicationRecord
serialize :proto, BPS::Update::UserDataImport
def self.latest
all.order(:created_at).last
end
# :nocov:
def self.archives
BPS::S3.new(:files).list('user_imports/').map do |f|
f.key.delete('user_imports/').delete('.proto').to_i
... |
class SellBook
class << self
def call(shop_id:, book_id:, copies_number:)
book =
Shop.find(shop_id)
.sell(
book_id,
copies_number
)
[:ok, book]
rescue Shop::BookAbsentError, Shop::TooLittleCopiesError => e
Rails.logger.error e.to_s
... |
def run_as_multi_tenant?
ENV.key?("RUN_AS_MULTI_TENANT") &&
![nil, "", "false", 0, "0"].include?(ENV["RUN_AS_MULTI_TENANT"])
end
|
class Pin < ActiveRecord::Base
attr_accessible :user_id, :wedding_id, :image
belongs_to :user
validates :user_id, presence: true
mount_uploader :image, ImageUploader
end
|
require_relative '../src/person'
require_relative '../src/subject'
require_relative '../src/control'
describe 'Control' do
before(:all) do
@person = Person.new('小铭', '男', 22)
@subjects = [Subject.new('数学', 95),
Subject.new('语文', 97),
Subject.new('英语', 90)]
end
it 'should ... |
require File.expand_path(File.dirname(__FILE__) + '/../../../test_helper')
class TinyCI::SourceControl::GitTest < ActiveSupport::TestCase
test "should do the update workflow" do
git = TinyCI::SourceControl::Git.new(stub, {})
git.expects(:clone_or_update)
git.expects(:find_or_checkout_revision)
git.ex... |
require 'formula'
class GreenplumDb < Formula
homepage 'http://gopivotal.com/products/pivotal-greenplum-database'
url 'http://dist.vfabric.com.s3.amazonaws.com/greenplum-db-4.2.2.4.tgz'
sha1 '0e66a34da5bb361ebd917a737ec98483c64c4eae'
version "4.2.2.4"
def install
# Install files
prefix.install Dir... |
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe UserIgnore, type: :model do
it { should validate_presence_of(:user) }
it { should validate_presence_of(:ignored) }
it 'should have correct association' do
should belong_to(:user)
should belong_to(:ignored)
end
end
|
VENT_MATCHER = /(?<x1>\d+),(?<y1>\d+) -> (?<x2>\d+),(?<y2>\d+)/
VENTS = INPUT.split("\n").map { |line| line.match(VENT_MATCHER) }
def range_for(begins, ends)
min = [begins, ends].min
(min == begins) ? (begins..ends).to_a : begins.downto(ends).to_a
end
def map_for(vents, diagonals: false)
vents.each_with_object(... |
# frozen_string_literal: true
require_relative 'spec_helper'
require_relative '../lib/extensions/string.rb'
RSpec.describe String do
it 'should ignore an already camel cased string' do
expect('MyApp'.camel_case).to eq('MyApp')
end
it 'should capitalize an all lower case string' do
expect('myapp'.camel_c... |
class Comment < ActiveRecord::Base
validates :text, presence: true
validates :points, presence: true
belongs_to :user # a user writes a comment, this must be true
belongs_to :post # a post contains a comment,
# BUT a comment doesn't necessarily belong to a post
# a comment's direct parent can be either a ... |
require 'fileutils'
require 'pathname'
require 'rim/file_helper'
require 'rim/git'
require 'rim/rim_exception'
require 'rake'
require 'pathname'
require 'uri'
require 'digest/sha1'
module RIM
class Processor
MaxThreads = 10
GerritServer = "ssh://gerrit/"
def initialize(workspace_root, logger)
@ws_root = workspace... |
require 'omniauth-oauth2'
module OAuth2
module Strategy
class ClientCredentials < Base
def get_token(params = {}, opts = {})
params.merge!('grant_type' => 'client_credentials')
params.merge! client_params
@client.get_token(params, opts.merge('refresh_token' => nil))
end
en... |
# frozen_string_literal: true
# == Schema Information
#
# Table name: ad_media # 広告媒体マスターテーブル
#
# id :bigint not null, primary key
# name(媒体名) :string not null
# created_at :datetime not null
# updated_at :datetime not null
# company_id(企業I... |
require 'active_record'
module Joyce
class Activity < ActiveRecord::Base
self.table_name = 'joyce_activities'
belongs_to :actor, :polymorphic => true
belongs_to :obj, :polymorphic => true
has_and_belongs_to_many :streams, :join_table => "joyce_activities_streams"
has_many :activity_targets, :dep... |
module CDI
module V1
module ServiceConcerns
module GamePollsParams
extend ActiveSupport::Concern
WHITELIST_ATTRIBUTES = [
:image
]
included do
def game_poll_params
@game_poll_params ||= filter_hash(@options[:game] || @options[:poll], WHITELIS... |
# this should be the folder name under `ios` for your project
project_name = 'makingLunch'
# NOTE: This is meant to be run on CI where it changes everything before building the app.
# Usage:
# `RN_RELEASE_TYPE=beta fastlane prep_release_type` (on CI these ENV variables should be set via the UI)
desc "Updates the app ... |
require_relative '../spec_helper'
include Butcher
describe Service do
let(:service_class) do
Class.new do
include Service
def path
'/v1/beers'
end
def source
'http://api.openbeerdatabase.com'
end
def build_collection(response)
data = parse_json(res... |
FactoryGirl.define do
factory :category do
sequence(:name) { |n| "Category #{n}" }
end
factory :item do
sequence(:description) { |n| "Description #{n}" }
factory :item_with_user do
user
end
end
factory :user do
sequence(:email) { |n| "test#{n}@example.com" }
password 'f4k3p455... |
require 'spec_helper'
describe SessionsController do
fixtures 'users'
# describe "Start a new session" do
# it "should redirect to the login page" do
# user = User.create! valid_attributes
# get 'new', {:user => valid_attributes}
# get 'new'
# response.should redirect_to(login_url)
# end
... |
require 'cloudformation_mapper/resource'
class CloudformationMapper::Resource::AwsPropertiesRoute53Recordset < CloudformationMapper::Resource
register_type 'AWS::Route53::RecordSet'
type 'Template'
parameter do
type 'Template'
name :Properties
parameter do
type 'AliasTarget'
name :Al... |
# Copyright 2019 The inspec-gcp-cis-benchmark Authors
#
# 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
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law... |
class TestcasesController < ApplicationController
before_action :authenticate_user!, only: [:index, :show, :edit, :update, :destroy, :create, :new]
before_action :set_testcase, only: [:show, :edit, :update, :destroy]
before_action :set_paper_trail_whodunnit
load_and_authorize_resource
include ApplicationHelpe... |
require 'rspec'
require 'printer'
describe Printer, '#print' do
it "return text for a single digit" do
printer = Printer.new
printer.print('1').should eq(
<<RAW
d888
d8888
888
888
888
888
888
8888888
RAW
)
end
it "return text for a string of digits" do
printer = Printer.n... |
class Mod < ApplicationRecord
has_many :jointure_meals
has_many :meals, through: :jointure_meals
end
|
class Attender < ApplicationRecord
validates :class_date_id, presence: true
validates :student_id, presence: true
belongs_to :class_date
belongs_to :student
end
|
# encoding: utf-8
class SocialNetworksController < ApplicationController
before_filter :authenticate_user!
before_filter :has_admin_credentials?
def index
@social_networks = SocialNetwork.all
end
def new
@social_network = SocialNetwork.new
end
def edit
@social_network = SocialNetwork.find(p... |
class SalesController < ApplicationController
def show
# sale is not an instance variable as it is not used elsewhere (no views (yet))
sale = Sale.find_with_password params[:id], params[:password]
if sale
render json: { data: sale }, status: :created
else
# TODO: staus: 403 if sale with i... |
require 'spec_helper'
describe Guard::TestVersion do
it 'has the right version number' do
expect(described_class::VERSION).to eq '2.0.5'
end
end
|
class CandidateReviewer < ActiveRecord::Base
attr_accessible :reviews_required, :name
belongs_to :candidate
belongs_to :reviewer
validates_uniqueness_of :candidate_id, :scope => :reviewer_id
end |
require 'mirren/info/price'
require 'mirren/rigs/stats'
module Mirren
module Info
class Algorithm < BaseStruct
attribute :name, Types::String
attribute :display, Types::String
attribute :suggested_price, Price
attribute :stats do
attribute :available, Rigs::Stats
attribute... |
=begin
#===============================================================================
Title: Use Condition Tags
Author: Hime
Date: Nov 4, 2013
--------------------------------------------------------------------------------
** Change log
Nov 4, 2013
- Initial Release
------------------------------------------... |
class AddMessageToNotifications < ActiveRecord::Migration[5.1]
def change
add_column :new_notifications, :message, :text
end
end |
# == Schema Information
#
# Table name: styles
#
# created_at :datetime not null
# id :integer not null, primary key
# key :string
# updated_at :datetime not null
#
class Style < ApplicationRecord
### Model Config ###
### Modules ###
### Constants ###
### Associations ##... |
class Algo
attr_reader :lost_files
def initialize(source_dir, logger)
@source_dir = source_dir
@repo = Repo.new(@source_dir)
@result_tracker = ResultTracker.new(@repo)
@lost_files = LostFiles.new(logger)
end
def run!
@repo.each_commit do |commit|
@repo.checkout_older_revision!(commit... |
require 'rails_helper'
describe Game do
let(:home_team) { Team.create }
let(:away_team) { Team.create }
describe "#winning_team" do
context "when the home team wins" do
it "returns the home team" do
game = Game.create home_team: home_team, away_team: away_team,
home_score: 7, away_sc... |
require "#{File.dirname(__FILE__)}/spec_helper"
describe FriendshipMessage do
it "should require a body" do
@message = FriendshipMessage.new
@message.should_not be_valid
@message.errors[:body].should == "can't be blank"
end
end
|
module ApplicationHelper
def current_locale?(locale)
locale.to_s.downcase == I18n.locale
end
def loginout_link
(user_signed_in? ? link_to(t(:logout), destroy_user_session_path, method: :delete) : link_to(t(:login), new_user_session_path))
end
def global_menus
GlobalMenu.each do |menu_container, ... |
require "spec_helper"
describe Concern::Associations::ContentAlarmAssociation do
describe '#should_reject_alarm?' do
it "rejects alarm is alarm doesn't exist and the fire_at fields are blank" do
story = build :test_class_story
story.alarm.should eq nil
# Is there a better way to test this?
... |
class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
before_create :set_access_token
belongs_to :room
... |
class AddColumnsToSearches < ActiveRecord::Migration
def change
add_column :searches, :comment, :text
add_column :searches, :saved, :boolean, default: false
add_column :searches, :applied, :boolean, default: false
end
end |
require 'spec_helper'
describe file('/usr/local/bin/uwsgi') do
it { should be_file }
it { should be_executable }
end
describe service('uwsgi'), :if => os[:family] == 'ubuntu' do
it { should be_enabled }
it { should be_running }
end
describe port(8080) do
it { should be_listening }
end
describe file('/e... |
# coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'talis/version'
# rubocop:disable Metrics/LineLength
Gem::Specification.new do |spec|
spec.name = 'talis'
spec.version = Talis::VERSION
spec.authors = ['Omar Qureshi', '... |
# frozen_string_literal: true
require 'test_helper'
class ConversationTest < ActiveSupport::TestCase
def setup
@user1 = users(:maymie)
@user2 = users(:ronny)
@conversation = conversations(:first)
end
test 'should be valid' do
assert @conversation.valid?
end
test 'sender and receiver should... |
# User case for student class - authentication systems in web applications
# For now think of students as users
# Done with usernames and passwords
# Security for user information is very important
# Passwords are virtually never stores in their string forms
# Hashed digests are stored in dbs
# In popular hashing algor... |
# As a Maker
# So that I can post messages on Chitter as me
# I want to log in to Chitter
feature 'Signing in' do
scenario 'successfully redirects to index page' do
sign_in
expect(current_path).to eq '/'
end
scenario 'user full name is displayed in the navbar' do
sign_in
expect(page).to have_cont... |
class ScenesController < ApplicationController
before_action :set_scene, only: [:show, :edit, :update, :destroy]
before_action :set_novel
# GET /scenes
# GET /scenes.json
def index
@scenes = @novel.scenes
end
# GET /scenes/1
# GET /scenes/1.json
def show
@characters = @scene.characters;
... |
require 'lib/tchat/command/register_command.rb'
require 'lib/tchat/command/signin_command.rb'
module TChat
module Command
class IdentificationCommandFactory
def initialize(users_manager)
@users_manager = users_manager
end
def create_command(command_string, socket)
command_arg... |
# controller for handling friend requests
class FriendRequestsController < ApplicationController
include FriendRequestsHelper
def index
@friends = current_user.friend_requests.chronological_order.pluck(:friend_id).uniq
end
def create
friend = User.find params[:friend_id]
friend.friend_requests.crea... |
require 'spec_helper'
describe Advert do
describe 'model' do
subject {@advert = Advert.new }
it {should respond_to( :id)}
it {should respond_to( :title)}
it {should respond_to( :text)}
end
end
|
# frozen_string_literal: true
module Customerio
class TrackJob < ApplicationJob
queue_as :customerio
def perform(user_id:, event:, **attributes)
Customerio::TrackService.new.call(user_id: user_id, event: event, **attributes)
end
end
end
|
class EncodingHelper
class << self
# convert all characters in a UTF-8 string to %uXXXX encoded
# assumes input is UTF-8 string
def create_unicode_encoded_rep(input)
input # => "aé…"
.unpack("U*") ... |
# frozen_string_literal: true
module Api::V1
class VideoCategorySerializer < Api::V1::BaseSerializer
type 'video_categories'
attribute :name
end
end
|
class User < ApplicationRecord
has_and_belongs_to_many :projects
has_many :assignments
has_many :tasks, :through => :assignments
validates_uniqueness_of :email
validates_presence_of :email, :name
scope :search_name, ->(full_name) { where("name ilike ?", "%#{sanitize_sql_like(full_name)}%") }
end
|
class AddGuestToEpisodes < ActiveRecord::Migration
def change
add_column :episodes, :guest_name, :string
add_column :episodes, :guest_twitter, :string
end
end
|
class DnsRecord < ApplicationRecord
has_and_belongs_to_many :hostnames, :autosave => true
accepts_nested_attributes_for :hostnames
validates :ip_address, presence: true, uniqueness: true
validates_associated :hostnames
scope :with_related_hostnames, ->(hostnames_list) {
joins(:hostnames)
... |
#
# 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 required by applicable law or agreed to in writing,
# software distributed
# under the Li... |
class ChangeColumnName < ActiveRecord::Migration[5.2]
def change
rename_column :sales, :sales, :state
end
end
|
FactoryGirl.define do
factory :user do
name "Jeremy Davis"
email "jeremy.davis@redhat.com"
password "foobar"
password_confirmation "foobar"
end
end |
class BashTest < Formula
desc "Simple test runner for Bash."
homepage "https://github.com/campanda/bash-test"
url "https://github.com/campanda/bash-test/archive/v0.2.0.tar.gz"
sha256 "7ac0b41cb4345830d8feb6825af9028090baef6aa214bea2f5ec8d235022aadf"
head "https://github.com/campanda/bash-test.git"
bottle :... |
class EmployeeMailer < ActionMailer::Base
default :from => "webportaldiag@gmail.com"
def registration_confirmation(employee)
@employee = employee
mail(:to => "#{employee.nome} <#{employee.email}>", :subject => "Registration Confirmation")
end
def password_reset(employee)
@employee = employee
... |
class OutletPromotions < ActiveRecord::Base
belongs_to :outlet
belongs_to :promotion
accepts_nested_attributes_for :outlet
end
|
#--
# Copyright (c) 2013 Michael Berkovich, tr8nhub.com
#
# 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, copy, mo... |
require "csv"
# TODO: refactor csv2html POC and add spec tests
# TODO: consolidate scale results code here
module PerfResultsHelper
HTML_START = <<-HEREDOC.freeze
<!DOCTYPE html>
<html lang="en">
<head>
<title>Scale Test Results</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-... |
FactoryBot.define do
factory :brand do
id {'3'}
name {'Gucci'}
end
end |
class Student < ActiveRecord::Base
belongs_to :classroom
has_many :exam_results
has_many :exams, through: :classrooms
has_attached_file :avatar, styles: {large: "300x300>", medium: "100x100>", thumb: "40x40>" }, default_url: "/default-avatar.gif"
validates_attachment_content_type :avatar, content_type: /\Aimage\... |
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Emanuel... |
# Read about factories at https://github.com/thoughtbot/factory_girl
FactoryGirl.define do
factory :customer, aliases: [:notable, :mark_twain] do
firstname "Mark"
lastname "Twain"
email "mt@yahoo.com"
description "he used to be samuel clemens"
creator
updater
end
factory :charles_dickens, class: Custom... |
#!/usr/bin/env ruby
require 'date'
require 'optparse'
require 'pathname'
require 'fileutils'
def ensure_folder_exists(folder_path)
unless Dir.exists?folder_path
FileUtils.mkpath(folder_path)
end
end
def delete_empty_folder(folder_path)
if (Dir.entries(folder_path) - %w{ . .. }).empty?
Dir.delete(folder... |
class AddTokensToUsers < ActiveRecord::Migration
def change
add_column :users, :current_token, :string
end
end
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.