text stringlengths 10 2.61M |
|---|
# Your code goes here!
class Anagram
attr_accessor :word
def initialize(word)
@word=word
end
def match(anagrams)
@word = @word.split('')
anagrams.select { |anagram| anagram.split('').sort == @word.sort }
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_filter :authenticate, :except => [:login]
protected
def authenticate
@current_user = nil; @sm_user ... |
class AgencyMailer < ActionMailer::Base
default from: "no-reply@acfb.org"
# Subject can be set in your I18n file at config/locales/en.yml
# with the following lookup:
#
# en.agency_mailer.new_volunteer.subject
#
def new_volunteer(volunteer)
@greeting = "Hi"
@volunteer = volunteer
@users ... |
# Write your code here.
katz_deli = []
def line array
def new array
array.each_with_index.map do |value, i|
"#{i + 1}. #{value}"
end
end
if array.empty?
puts "The line is currently empty."
else
array.each
puts "The line is currently: " + (new(array)).join(' ')
end
end
... |
class Discount < ApplicationRecord
validates_presence_of :name
validates :percent_off, numericality: { greater_than: 0, less_than_or_equal_to: 100 , only_integer: true,}
validates :min_quantity, numericality: { greater_than: 0, only_integer: true }
belongs_to :merchant
end
|
# exercise5_2.rb
puts "Would you like to begin? (Type stop for no)"
answer = gets.chomp.upcase
x = 0
while answer != "STOP"
x += 1
puts "You have ran the program #{x} times!"
puts "Would you like to run the program again? (Type stop for no)"
answer = gets.chomp.upcase
end
|
#!/usr/bin/env ruby
require 'rubygems'
require 'hpricot'
require 'net/http'
$username = 'agiletips'
$password = 'c0mputer'
def twitter(command, opts={}, type=:get)
# Open an HTTP connection to twitter.com
twitter = Net::HTTP.start('twitter.com')
# Depending on the request type, create either
# ... |
class Instructor < ActiveRecord::Base
attr_accessible :name
has_many :activites
validates_presence_of :name
def as_json(options = {})
super(options.merge(:methods => [:calculated_value]))
super(options.merge(:include => [:activities]))
end
end
|
# coding: utf-8
# frozen_string_literal: true
module Pebbles
module TotsuGen
class Formatter
def initialize(body)
@body = body
end
def result
"#{header}\n#{center}\n#{footer}"
end
private
def body_length
@body.each_char.sum { |char| (char.bytesize ==... |
# 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 rails db:seed command (or created alongside the database with db:setup).
#
# Examples:
#
# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
# Ch... |
module HalPresenters
module Helpers
module Embeddable
def self.included(klass)
klass.extend(ClassMethods)
klass.instance_eval do
include(InstanceMethods)
end
end
module ClassMethods
def expose_embedded(key, presenter = nil, opts = {})
opts = Ha... |
class JsonSchemaValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
schema_path = Rails.root.join('lib','schemas',
"#{record.content_type}.json").to_s
schema = MultiJson.load(File.read(schema_path), symbolize_names: true)
errors = JSON::Validator.fully_vali... |
class Untrunc < Formula
desc "Restore a truncated mp4/mov. Improved version of ponchio/untrunc"
homepage "https://github.com/anthwlock/untrunc"
version "latest"
url "https://github.com/anthwlock/untrunc/archive/refs/tags/latest.tar.gz"
sha256 "63dcb623ea6be9f8132d76277da00313d1710a1d84161911fd98cffb37d39f37"
... |
class CalculateTotalActualCostJob < ApplicationJob
queue_as :default
def perform(task_id) # use for calculating total actual cost and hour for tasks
@task = Cultivation::Task.find(task_id)
sum_cost = 0.0
sum_minutes = 0.0
@task.time_logs.includes(:user).each do |time_log|
if time_log.start_ti... |
module Bootcamp
class Sudokku
def self.sudoku_line_valid?(line)
line.sort == [1, 2, 3, 4, 5, 6, 7, 8, 9]
end
def self.sudokku_lines_valid?(sudokku_array)
result = true
# check lines
sudokku_array.each do |line|
result = false unless sudoku_line_valid?(line)
end
... |
class Album < ApplicationRecord
belongs_to :user
has_many_attached :images,dependent: :destroy
has_many :comments
validates :album_name,presence:true
validates :album_description,presence:true
scope :sorted,lambda {order(album_name: :desc)}
end
|
class RecordingType < ApplicationRecord
acts_as_paranoid
has_many :albums
validates_presence_of :in_use, :name
validates_uniqueness_of :name, case_sensitive: false
end
|
require 'rails_helper'
# 单元测试
# share_examples
# 辅助宏 spec/support
# 自定义匹配器 spec/support/matchers
# add tag
RSpec.describe Admin::MenusController, type: :controller do
describe "GET #manage_all" do
before do
login_admin
end
it "assigns all menus as @menus" do
@menu = create :menu
get... |
def my_uniq(arr) # [1, 2, 1, 3, 3]
uniques = []
arr.each do |ele|
uniques << ele unless uniques.include?(ele)
end
uniques
end
def two_sum(arr)
pairs = []
arr.count.times do |start|
(start+1).upto(arr.length-1) do |fin|
... |
# == Schema Information
#
# Table name: discussions
#
# id :integer not null, primary key
# creator_id :integer not null
# curated_collection_id :integer not null
# title :string(255) not null
# created_at :datetime no... |
name "cryptography"
default_version "1.3.2"
dependency "python"
dependency "pip"
if ohai['platform'] == 'windows'
dependency "openssl-windows"
else
dependency "libffi" # indirectly through the `cffi` python lib cryptography depends on
dependency "openssl"
end
build do
ship_license "https://github.com/pyca/cr... |
FactoryGirl.define do
factory :recipe_ingredient do
quantity {Faker::Number.decimal(2,2)}
recipe
end
end
|
class ClassesTimetablesController < ApplicationController
before_action :set_classes_timetable, only: [:show, :edit, :update, :destroy]
# GET /classes_timetables
# GET /classes_timetables.json
def index
@classes_timetables = ClassesTimetable.all
end
# GET /classes_timetables/1
# GET /classes_timetab... |
class Team < ActiveRecord::Base
belongs_to :city
has_one :coach
validates :name, uniqueness: true
has_many :home_games, class_name: "Game", foreign_key: "home_team_id"
has_many :away_games, class_name: "Game", foreign_key: "away_team_id"
#need Team_id in Game Table
validates :conference, :division, :name... |
# frozen_string_literal: true
# This is the class that is inherited by all models
class ApplicationRecord < ActiveRecord::Base
self.abstract_class = true
end
|
require 'spec_helper'
describe "Home page" do
it "should have the content in caurseal" do
visit root_path
expect(page).to have_css('section#home-content')
end
it "should have the base title" do
visit root_path
expect(page).to have_title("RSVPO")
end
end
describe "User pages" do
subject { ... |
# == Schema Information
#
# Table name: franchises
#
# id :integer not null, primary key
# franchise_name :string(255)
# franchise_number :string(255)
# franchise_set_id :integer
# created_at :datetime
# updated_at :datetime
#
class Franchise < ActiveRecord::Base
belongs_to ... |
##
# Carrierwave plugin for Padrino
# sudo gem install carrierwave
# http://github.com/jnicklas/carrierwave
#
UPLOADER = <<-UPLOADER
class Uploader < CarrierWave::Uploader::Base
##
# Image manipulator library:
#
# include CarrierWave::RMagick
# include CarrierWave::ImageScience
include CarrierWave::MiniMag... |
class RecordsController < ApplicationController
before_filter :set_type_default, :only => :index
def index
@puzzle = Puzzle.find params[:puzzle_id]
amount = RecordType.by_short_name(params[:type]).try(:count) || 5
@records = @puzzle.records.amount(amount).paginate(:page => params[:page], :per_page => ... |
class ExportCandidatesJob < ApplicationJob
queue_as :default
def perform(id)
job = LongJob.find(id)
applicants = if job.option1.present?
j = Job.find(job.option1)
j.applicants
else
Applicant.all
end
return unles... |
Rails.application.routes.draw do
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
resources :students#, except: [:destroy]
resources :classrooms, only: [:show]
get 'search/:student', to: 'students#search'
end
|
Pod::Spec.new do |s|
s.name = "wax"
s.version = "1.2.1"
s.summary = "wax Source"
s.description = <<-DESC
Wax is a framework that lets you write native iPhone apps in Lua. It bridges Objective-C and Lua using the Objective-C runtime. With Wax, anything you can do in Object... |
class ProductQuantity < ApplicationRecord
belongs_to :product
belongs_to :user #não tem no tutorial...gerado automaticamente
belongs_to :sale, optional: true
end
|
class Profile < ActiveRecord::Base
belongs_to :user
validates :first_name, presence: true, if: "last_name.nil?"
validates :last_name, presence: true, if: "first_name.nil?"
validate :correct_gender, :sue_not_male
def correct_gender
if gender != "male" && gender != "female"
errors.add(:gender, 'incorre... |
class Game < ActiveRecord::Base
has_and_belongs_to_many :players
belongs_to :winning_player, :class_name => "Player"
end
|
require File.dirname(__FILE__) + '/../spec_helper'
context "CreditCard class with fixtures loaded" do
before :each do
@number = 4111111111111111
@month = "01"
@year = "2018"
@cvv = "999"
@first_name = "John"
@last_name = "Doe"
Account.delete_all
@cc = Factory.create(:credit_... |
require 'spec_helper'
describe Calculator do
context "Add" do
it "should return 5 when 5 is added to 0" do
calculator = Calculator.new
expect(calculator.add(5)).to eq(5)
end
end
context "Subtract" do
it "should return -5 when 5 is subtracted to 0" do
calculator = Calculator.new
... |
module AmazonTokenGenerator
extend ActiveSupport::Concern
mattr_accessor :redis, :duration
def self.redis
@@redis || $redis
end
def self.duration
@duration || (60*60)
end
def amazon_credentials
self.class.temporary_amazon_credentials_for(self)
end
included do
require "datapimp-cli... |
# 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... |
class CreateExhibits < ActiveRecord::Migration
def change
create_table :exhibits do |t|
t.text :name, null: false
t.integer :year, null: false
t.references :exhibition, index: true, null: false
t.timestamps
end
reversible do |dir|
dir.up do
'ALTER TABLE exhib... |
require 'csv'
# 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 rails db:seed command (or created alongside the database with db:setup).
#
# Examples:
#
# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rin... |
require "methadone/test/base_integration_test"
class TestSomething < Methadone::BaseIntegrationTest
def test_truth
stdout,stderr,results = run_app("cg-scout","--help")
assert_banner(stdout, "cg-scout", takes_options: true, takes_arguments: false)
assert_option(stdout,"-h", "--help")
assert_option(std... |
class CreateStudents < ActiveRecord::Migration
def change
create_table :students do |t|
t.integer :tc, :null => false, :limit => 8
t.string :first_name, :null => false
t.string :last_name, :null => false
t.string :email, :null => false
t.string :password_digest, :null => false
... |
class User < ActiveRecord::Base
validates_presence_of :username
validates_presence_of :first_name
validates_presence_of :last_name
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:re... |
module AuthorizeNet::SIM
# The SIM transaction class. Handles building the transaction payload and
# generating a set of hidden form fields to be POSTed to the gateway.
class Transaction < AuthorizeNet::KeyValueTransaction
RANDOM_SEQUENCE_MAX = (1 << 32) - 1
# Our MD5 digest generator.
@@di... |
class Task::Info < ActiveRecord::Base
acts_as_taggable_on :klasses, :keywords, :opens
acts_as_votable
has_many :contest_items, class_name: "Contest::Task",
dependent: :destroy,
foreign_key: :task_id
has_many :contests, through: :contest_items, class_name: "Contest::Info"
has_many :answers, class_na... |
require 'spec_helper'
require 'data_model/field'
describe Moon::DataModel::Field do
it 'should create a new field' do
f = described_class.new(name: :test, type: Object)
expect(f.name).to eq(:test)
expect(f.allow_nil).to eq(false)
expect(f.default).to be_kind_of Proc
expect(f.make_default).to be_n... |
# ================================================================
# Created: 2015/04/28
# Author: Thomas Nguyen - thomas_ejob@hotmail.com
# Purpose: Keep all global constant values
# PS: tabs break the program
# ================================================================
module Constants
BASE_URL = "https://sau... |
class Supplier < ActiveRecord::Base
has_many :contracts
end
|
# == Schema Information
#
# Table name: responses
#
# id :integer not null, primary key
# user_id :integer
# quiz_id :integer
# created_at :datetime not null
# updated_at :datetime not null
# answer_id :integer
# question_id ... |
class RemoveClassFromSenateSeats < ActiveRecord::Migration[5.0]
def change
remove_column :senate_seats, :class, :integer
add_column :senate_seats, :class_num, :integer
end
end
|
require 'thor'
require 'pry'
require 'nokogiri'
module Martha
# Main class for all martha methods
class Builder < Thor
include Martha
include Thor::Actions
def initialize(args = [], local_options = {}, config = {})
super
@author = 'Victor Elizalde'
@file_info = []
@description ... |
module TestdroidAPI
class Runs < CloudListResource
end
class Run < CloudResource
def initialize(uri, client, params= {})
super uri, client, "run", params
@uri, @client = uri, client
sub_items :device_runs
end
def abort()
@client.post("#{@uri}/abort", params= {})
end
end
... |
require 'yaml'
require 'logger'
require_relative '../utils/file_path'
class BaseCommand
def initialize(options)
# @configure = {}
@options = options
config_file = options["config_file"]
if config_file.nil?
config_file = File.join(File.dirname(__FILE__), *%w{ .. etc conf.yml })
end
begin
... |
require_relative 'test_helper'
class SandboxTests < SlightishTest
def test_per_suite_sandbox
suite_a = with_suite('$ touch a_file')
suite_b = with_suite(%[
$ [ -f a_file ]
? 1
])
# make a_file in the sandbox of the first suite
suite_a.run
assert(suite_a.passed?)
# and it sho... |
require 'net/http'
require 'uri'
require 'json'
module Supersaas
class Client
class << self
attr_accessor :configuration
def configure
self.configuration ||= Configuration.new
yield(configuration)
end
def instance
Thread.current['SUPER_SAAS_CLIENT'] ||= new(confi... |
# frozen_string_literal: true
class Lab < ApplicationRecord
has_many :teaching_assistants, as: :ta_duty
end
|
#
# Copyright 2013, Seth Vargo <sethvargo@gmail.com>
# Copyright 2013, CustomInk, LLC
#
# 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
#
# Un... |
class Venue < ApplicationRecord
belongs_to :spectacle
has_many :bookings
validates :key, uniqueness: true
end
|
#
# iot-server.rb : IoT Server with REST-API for sensors/actuators
# v0.2 2016/02 : make storage on mongoDB
# v0.1 2015/11 : just storage with REST-API on local FS
#
# usage:
# ruby iot-server.rb
#
Version="0.1"
require 'uri'
require 'json'
require 'webrick'
require './lib-generic.rb'
require './storage.rb'
mod... |
require 'spec_helper'
require 'date'
describe SonyCameraRemoteAPI::Client::Main, HDR_AZ1: true do
let(:client) { @client }
let(:image_dir) { 'images' }
let(:valid_date) { '20160801' }
let(:invalid_date) { '20151105' }
let(:today) { Date.today.strftime('%Y%m%d') }
describe "'contents' command" do
con... |
class CreateOffers < ActiveRecord::Migration
def change
create_table :offers do |t|
t.integer :user_id, :null => false
t.string :title
t.text :description
t.text :rules
t.integer :price_cents
t.string :price_currency, :limit => 3
t.string :quantity
t.string :slug
... |
#!/usr/bin/env ruby
require_relative 'Arc'
class InhibitorArc < Arc
def initialize(category, input_node, output_node)
check_valid_nodes(input_node, output_node)
super(category, input_node, output_node)
@type = :inhibitor_arc
end
def check_valid_nodes(input_node, output_node)
... |
class CreateClient < ActiveRecord::Migration[6.0]
def change
create_table :clients do |t|
t.references :tenant
t.string :name
t.timestamps
end
add_reference :bookings, :client
add_reference :booking_requests, :client
add_reference :users, :client
end
end
|
class PoiData < ActiveRecord::Base
belongs_to :poi
validates :poi_id, presence: true
has_many :poi_data_locations
enum data_type: {undefined: 100, marker_image: 101, metaio_config: 102, texture2D: 0, object3D: 1, audio: 2, text: 3, image: 4}
end
|
object @directory_categories
attributes :id, :category_name
|
class Card < ActiveRecord::Base
belongs_to :card_template
has_many :card_attributes, through: :card_template
belongs_to :game
has_one :pile
has_one :card_pile, through: :pile
def name
return "#{card_template.name}(#{id})"
end
def method_missing(meth, *args, &block)
attribute = card_attributes.where(key: ... |
require 'spec_helper'
describe MoviesController do
describe 'Find Movies With Same Director' do
fixtures :movies
it 'should call the model method that performs search movies with same director' do
#m = mock('Movie', :director => "George Lucas", :id=>1)
# get :new, {:title=>movies(:movie1).title, :rating=>... |
#
# Copyright 2011-2013, Dell
# Copyright 2013-2014, SUSE LINUX Products GmbH
#
# 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 requi... |
# encoding: utf-8
require 'rubygems'
require 'sinatra'
require 'sinatra/reloader'
require "sqlite3"
def init_db
@db = SQLite3::Database.new './public/leprosorium.db'
@db.results_as_hash = true
end
before do
init_db
end
configure do
init_db
@db.execute 'create table if not exists Posts (
id I... |
# Programmer: Chris Bunch
# Imports from Ruby's stdlib
require 'thread' # needed for Mutex
# Imports for RubyGems
require 'rubygems'
require 'json'
# Imports for other Neptune libraries
require 'babel'
require 'custom_exceptions'
# TaskInfo represents the result of a babel call, an object with all the
# inform... |
class Photo < ActiveRecord::Base
belongs_to :album
mount_uploader :file, PhotoUploader
# Remember to create a migration!
end
|
require_relative 'spec_helper'
describe 'Homepage' do
include PageObject::PageFactory
before do
@browser ||= Watir::Browser.new
end
after do
@browser.close
end
describe 'Empty Homepage' do
it '(Happy) should see welcome message' do
# GIVEN: on the homepage
visit_page HomePage do ... |
class AddTicketingVersionToEvent < ActiveRecord::Migration[6.0]
def change
add_column :events, :ticketing_version, :integer, null: false, default: 0
end
end
|
# encoding: utf-8
#
# © Copyright 2013 Hewlett-Packard Development Company, L.P.
# 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
#... |
class AddSpendingLimitToGroups < ActiveRecord::Migration
def change
add_column :groups, :spending_limit, :integer, null: false
end
end
|
class Customer < ApplicationRecord
has_many :invoices, dependent: :destroy
has_many :transactions, through: :invoices
has_many :invoice_items, through: :invoices
has_many :items, through: :invoice_items
has_many :merchants, through: :items
validates :first_name, presence: true
validates :last_name, prese... |
class Player < ActiveRecord::Base
validates_uniqueness_of :espn_id
# Contracts and teams
has_many :contracts
has_many :teams, through: :contracts
has_and_belongs_to_many :coalitions, -> { uniq }
has_many :players, -> { uniq }, through: :coalitions
# Appearances
has_many :appearances
# Full... |
class BestSeat < ApplicationRecord
enum map_rows: {
1 =>'A' ,
2 =>'B' ,
3 =>'C' ,
4 =>'D' ,
5 =>'E' ,
6 =>'F' ,
7 =>'G' ,
8 =>'H' ,
9 =>'I' ,
10 =>'J' ,
11 =>'K' ,
12 =>'L' ,
13 =>'M' ,
14 =>'N' ,
15 =>'O' ,
16 =>'P' ,
17 =>'Q' ,
18 =>'R' ,
... |
class CarsRelation < ROM::Relation[:sql]
schema(:cars, infer: true) do
associations do
belongs_to :user
has_many :services
end
end
dataset { order { id.desc } }
def by_user(user_id)
where(user_id: user_id)
end
def by_vin(vin)
where(vin: vin)
end
def index
select(
... |
require 'rails_helper'
describe Task do
before do
@task = FactoryGirl.create(:task)
end
subject { @task }
it { should be_valid } # valid with valid attributes
it { should respond_to(:content) }
it { should respond_to(:priority) }
it { should respond_to(:deadline) }
it { should... |
# frozen_string_literal: true
require 'spec_helper'
require 'bolt_spec/files'
require 'bolt_spec/integration'
describe "when running over the local transport" do
include BoltSpec::Files
include BoltSpec::Integration
let(:modulepath) { File.join(__dir__, '../fixtures/modules') }
let(:uri) { 'localhost,local:/... |
module InventoriesHelper
def inventory_create_date(inventory)
inventory.created_at.strftime('%d.%m.%Y')
end
def inventory_threshold_link_to(label, inventory, method)
label = content_tag(:div, label)
label << content_tag(:div, class: 'amount') do
number_to_percentage(inventory.send(method), prec... |
require "byebug"
class Array
# Write a new `Array#merge_sort` method; it should not modify the
# array it is called on, but create a new sorted array.
def merge_sort(&prc)
return self if self.length <= 1
probe = self.length / 2
left = self.take(probe)
right = self.drop(probe)
left_sorted ... |
FactoryGirl.define do
factory :visit do
line_item nil
visit_group nil
sparc_id
research_billing_qty 0
insurance_billing_qty 0
effort_billing_qty 0
trait :with_complete_procedures do
after(:create) do |visit, evaluator|
create_list(:procedure_complete, 3, visit: visit)
... |
require File.dirname(__FILE__) + '/../test_helper'
class ConversationTest < Test::Unit::TestCase
fixtures :conversations, :contacts, :contacts_conversations
def test_create_conversation
conversation = Conversation.new
conversation.when_held = Date.new(2007, 7, 27)
conversation.title = 'More advice'
... |
class CreateDownloads < ActiveRecord::Migration
def change
create_table :downloads do |t|
t.references :member
t.references :content
t.integer :download_times, default: 1
t.timestamps
end
end
end
|
class CreatePropertyTypes < ActiveRecord::Migration[5.0]
def change
create_table :property_types do |t|
t.string :ru_name
t.string :en_name
t.string :ru_measure
t.string :en_measure
t.timestamps
end
end
end
|
# 文列 = 文
# 文 = 代入文 | if文 | print文 | while文 | '{' 文列 '}'
# 代入文 = 変数 '=' 式
# if文 = 'if' 式 'then' 文 'else' 文 'end'
# input文 = 'in' 変数
# output文 = 'out' 式
# while文 = 'while'式 '{' 文 '}'
# 式 = 項 (('+'|'-')項)*
# 項 = 因子(('*'|'/')因子)*
# 因子 = '-'?(リテラル|'('式')')
# input文とif文は実装できませんでした。
class Flat
@@keywords = {
'+' => :a... |
class Occupation < ActiveRecord::Base
# See Listing 10.7
belongs_to :user
# See Listing 10.13
has_many :skills, dependent: :destroy
# See 8 minutes, http://railscasts.com/episodes/163-self-referential-association
has_many :friendships, dependent: :destroy
has_many :friends, :through => :friendships, dependent: ... |
# -*- encoding: utf-8 -*-
$:.push File.expand_path("../lib/", __FILE__)
require "gooddata/version"
Gem::Specification.new do |s|
s.name = %q{gooddata}
s.version = GoodData::VERSION
s.licenses = ['BSD']
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.... |
class AddFacaacontecerIdToUsers < ActiveRecord::Migration
def change
add_column :users, :facaacontecer_id, :integer
end
end
|
class Genre < ApplicationRecord
has_many :book_genres
has_many :books, through: :book_genres
has_many :book_authors
has_many :authors, through: :book_authors
validates :name, presence: :true
end
|
#
# Cookbook Name:: opendj
# Recipe:: default
#
# Copyright 2012, Megam Systems
#
# All rights reserved - Do Not Redistribute
#
case node[:platform]
when "debian", "ubuntu"
package "openjdk-7-jre" do
action :install
end
directory node["opendj"]["dir-path"]["tmp"] do
owner node["opendj"]["user"]
group nod... |
require 'rails_helper'
RSpec.describe Image, type: :model do
describe 'validations' do
it 'has a valid factory' do
expect(FactoryGirl.create(:image)).to be_valid
end
end
describe 'associations' do
it { should belong_to(:album) }
end
end
|
require './config/environment'
require 'uri'
class User < ActiveRecord::Base
has_many :items
has_many :categories, through: :items
has_secure_password
validates_presence_of :name, :email, :phone, :password, message: "fields cannot be blank."
validates_uniqueness_of :email, message: "email already... |
class CreateWoyongguoProducts < ActiveRecord::Migration
def self.up
create_table :woyongguo_products do |t|
t.integer :woyongguo_id
t.integer :taobao_product_id
t.timestamps
end
end
def self.down
drop_table :woyongguo_products
end
end
|
class ApplicationController < ActionController::API
include DeviseTokenAuth::Concerns::SetUserByToken
rescue_from ActiveRecord::RecordNotFound, with: :render_404
def validate_admin
render json: { message: "Not Authorized" }, status: 401 unless current_user.admin?
end
private
def render_404... |
# encoding: utf-8
class ImageUploader < CarrierWave::Uploader::Base
include CarrierWave::MiniMagick
storage :file
# storage :fog
include CarrierWave::MimeTypes
process :set_content_type
# Override the directory where uploaded files will be stored.
# This is a sensible default for uploaders that are meant... |
class FamilyMembersController < ApplicationController
def new
@family_member = FamilyMember.new
end
def create
@family_member = FamilyMember.new(family_member_params)
@family_member.save
redirect_to root_path
end
def edit
@family_member = FamilyMember.find(params[:id])
end
def upda... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.