text stringlengths 10 2.61M |
|---|
class Notification < ApplicationRecord
# Events define the types of notifications. DO NOT CHANGE EXISTING EVENTS
enum event: { system_message: 0, follow_request: 1, user_message: 2, group_invite: 3,
group_invite_request: 4, event_invite: 5, event_update: 6 }
belongs_to :entity, polymorphic: true,... |
class Like < ApplicationRecord
belongs_to :error, counter_cache: :likes_count
belongs_to :user
end
|
class Alliance < ActiveRecord::Base
belongs_to :client_supplier, class_name: 'Client', foreign_key: 'client_supplier_id'
belongs_to :client_recipient, class_name: 'Client', foreign_key: 'client_recipient_id'
belongs_to :supply
belongs_to :demand
end
|
class RinventorsController < ApplicationController
before_action :set_rinventor, only: [:show, :edit, :update, :destroy]
# GET /rinventors
# GET /rinventors.json
def index
@rinventors = Rinventor.all
end
# GET /rinventors/1
# GET /rinventors/1.json
def show
end
# GET /rinventors/new
def new... |
require "dynamics_crm/version"
# CRM
require "dynamics_crm/xml/message_builder"
require 'dynamics_crm/xml/message_parser'
require "dynamics_crm/xml/fault"
require "dynamics_crm/xml/attributes"
require "dynamics_crm/xml/column_set"
require "dynamics_crm/xml/criteria"
require "dynamics_crm/xml/query"
require "dynamics_cr... |
require 'test_helper'
class CompanyMembershipsControllerTest < ActionController::TestCase
setup do
@company_membership = company_memberships(:one)
end
test "should get index" do
get :index
assert_response :success
assert_not_nil assigns(:company_memberships)
end
test "should get new" do
... |
puts 'Gerenciador de Eventos inicializado!'
contents = File.read 'event_attendees.csv' #Lê o arquivo inteiro
puts contents
lines = File.readlines 'event_atendees.csv' #Lê arquivo linha por linha
lines.each_with_index do |line, index|
next if index == 0 # Passa para a próxima linha se index for igual a zero - para... |
class ResumesController < ApplicationController
before_action :authenticate_entity!
# Definition: Lists all resumes.
# Input: void.
# Output: @resumes.
# Author: Essam Azzam.
def index
@resumes = Resume.all
end
# Definition: Lists all resumes.
# Input: resume.
# Output: void.
# Author: E... |
#
# Copyright 2009 Huygens Instituut for the History of the Netherlands, Den Haag, The Netherlands.
#
# This file is part of New Women Writers.
#
# New Women Writers is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundat... |
class AccountsController < ApplicationController
before_action :authenticate_user!, except: [:avatar, :show]
before_action :set_account, only: [:destroy, :set_default, :show, :update, :avatar]
before_action :ensure_account_is_mine, only: [:destroy, :set_default, :update]
def index
@accounts = current_user.... |
# frozen_string_literal: true
class Ticket < ApplicationRecord
extend Enumerize
belongs_to :event
belongs_to :reservation, required: false
validates :selling_option, :amount, presence: true
validates_inclusion_of :paid, in: [true, false]
scope :available, -> { where(paid: false) }
scope :not_booked, ->... |
module Blower
# Raised when a task isn't found.
class TaskNotFound < RuntimeError; end
# Raised when a command returns a non-zero exit status.
class FailedCommand < RuntimeError; end
class ExecuteError < RuntimeError
attr_accessor :status
def initialize (status)
@status = status
end
en... |
require "csv"
require "google/apis/civicinfo_v2"
require "erb"
require "date"
def clean_zipcode(zipcode)
zipcode.to_s.rjust(5, "0")[0..4]
end
def clean_phone_numbers(phone_number)
phone_number = phone_number.to_s.gsub(/[^0-9]/, "")
if phone_number.length < 10 || phone_number.length >= 11
phone_number = "12... |
class AccessoryItemsController < ApplicationController
before_action :set_accessory_item, only: [:show, :update, :destroy]
before_action :authenticate_user, only: [:create, :update, :destroy]
def index
@category = ItemCategory.find(params[:category_id]) if params[:category_id]
@accessory_items = @categ... |
#!/usr/bin/env ruby
#encoding: UTF-8
require 'mechanize'
require 'cgi'
require File.join('.', File.dirname(__FILE__), 'config/environment.rb')
pp DateTime.now
class Vacancy < ActiveRecord::Base
end
agent = Mechanize.new
search_periods = { '7' => 'за неделю', '3' => 'за 3 дня', '1' => 'за сутки' }
search_strings =... |
# 5.2 Assignment
=begin
Write a program that will allow an interior designer to enter
the details of a given client:
the client's name, age, number of children, decor theme, and whether they're doing full house update
=end
# Prompt designer for information
# Convert user input to appropriate data type
# Print hash b... |
require 'aruba/cucumber'
Before do
@aruba_timeout_seconds = 15
if ENV['DEBUG']
@puts = true
@announce_stdout = true
@announce_stderr = true
@announce_cmd = true
@announce_dir = true
@announce_env = true
end
end
|
class AddIndexToCommentLog < ActiveRecord::Migration[5.1]
def change
add_index :comment_logs, [:owner_id, :post_id, :account_id]
end
end
|
class Animate < Draco::System
filter Animated, Sprite, Visible
def tick(args)
entities.each do |entity|
entity.animated.current_frame += 1
entity.sprite.path = get_current_frame(entity.animated)
end
end
def get_current_frame(animated)
total_frames = animated.frames.reduce(0) { |total, ... |
class AuthenticationsController < InheritedResources::Base
before_filter :authenticate_user!
def index
@authentications = current_user.authentications if current_user
end
def create
auth = request.env["omniauth.auth"]
authentication = current_user.authentications.find_or_create_by_provider_and_u... |
class CreateGrantApplications < ActiveRecord::Migration
def change
create_table :grant_applications do |t|
t.references :user, index: true
t.string :contact_person
t.string :contact_email
t.string :contact_phone
t.boolean :sf_bay
t.text :grant_request
t.text :comments
... |
class AddEmpresaIdToUsuario < ActiveRecord::Migration
def change
add_column :usuarios, :empresa_id, :integer
add_index :usuarios, :empresa_id
end
end
|
Rails.application.routes.draw do
get 'users/create'
get 'users/destroy'
get 'users/my_projects', to: 'users#my_projects', as: 'my_projects'
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
root 'home#index'
resources :estimation_sessions, :partial_estimatio... |
class CreateProducts < ActiveRecord::Migration
def change
create_table :products do |t|
t.timestamps null: false
end
end
end
t.references :project, index: true
t.integer :hours
t.integer :minutes
t.text :comments
t.datetime :date
t.timestamps null: false
|
module Transfers
extend ActiveSupport::Concern
include Secured
include Activities::Breadcrumbed
included do
before_action :can_create_transfer?
end
def new
@transfer = transfer_model.new
prepare_default_activity_trail(target_activity, tab: "transfers")
add_breadcrumb t("breadcrumb.#{trans... |
class CategoriesController < ApplicationController
respond_to :html, :xml
def index
@categories = Category.find(:all, :include => :posts)
respond_with @categories
end
def show
@category = Category.find(params[:id])
respond_with @category
end
end
|
#!/usr/bin/env ruby
require 'fileutils'
require 'open-uri'
require 'open_uri_redirections'
require './lib/sequence_generator.rb'
require './lib/sequence_store.rb'
# Print welcome statement and prompt user for a URL or file path to parse
puts "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX... |
class AddDefaultToVoteUpAndVoteDownAttributes < ActiveRecord::Migration
def change
change_column_default :articles, :up_vote, 0
change_column_default :articles, :down_vote, 0
end
end
|
require 'rails_helper'
RSpec.describe UrlShortenerController, type: :request do
describe 'post #new' do
before { post '/', params: { url: 'http://farmdrop.com' } }
it 'returns http success' do
expect(response.content_type).to eq 'application/json; charset=utf-8'
end
it 'returns the short cod... |
module DashboardHelper
def filter_path(entity, options={})
exist_opts = {
state: params[:state],
scope: params[:scope],
project_id: params[:project_id],
}
options = exist_opts.merge(options)
path = request.path
path << "?#{options.to_param}"
path
end
def entities_per_p... |
# Copyright 2011-2013 innoQ Deutschland 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 required by applicable law or agreed... |
require 'test_helper'
class CreateParticipationTest < Capybara::Rails::TestCase
include Warden::Test::Helpers
Warden.test_mode!
after do
Warden.test_reset!
end
feature 'Destroy' do
scenario 'destroys a participation if admin' do
user = create :user, :admin
pres = create(:presentation, t... |
describe ManageIQ::Providers::Amazon::ContainerManager::Refresher do
it ".ems_type" do
expect(described_class.ems_type).to eq(:eks)
end
describe "#refresh" do
let(:zone) do
_guid, _server, zone = EvmSpecHelper.create_guid_miq_server_zone
zone
end
let!(:ems) do
hostname = Rails.... |
class Checkouts::KwkController < ApplicationController
before_action :ensure_sale_is_ongoing
private
def ensure_sale_is_ongoing
redirect_to root_url, error: t("checkouts.no_ongoing_sales") unless current_kwk_sales?
end
end
|
#!/usr/bin/env ruby
# encoding: utf-8
# Ruby Styles https://github.com/bbatsov/ruby-style-guide
# * Arrays.transpose, quickfind_first, find_occurences, min_out_of_cycle, index_out_of_cycle
# * Strings.min_window_span, index_of_by_rabin_karp, and combine_parens
# * SNode.find_cycle; Numbers.divide, sum, minmax, and abs... |
require 'spec_helper'
describe 'congress' do
shared_examples 'congress' do
context 'with default parameters' do
let :params do
{}
end
it 'contains deps class' do
is_expected.to contain_class('congress::deps')
end
it { is_expected.to contain_package('congress-comm... |
# -*- encoding: utf-8 -*-
require File.expand_path('../lib/rack-chain/version', __FILE__)
Gem::Specification.new do |gem|
gem.authors = ["Nick Sieger"]
gem.email = ["nick@nicksieger.com"]
gem.description = %q{Rack::Chain builds a Rack application that runs each middleware in its own fiber to mini... |
class HelpCommand < Command::Base
self.revealed = false
def output
@output ||= commands.any? ? list_commands : no_commands
end
private
def commands
Command.revealed
end
def list_commands
'<p>Here are the available commands:</p>' +
"<p style='padding-left: 20px;'>#{commands.join(' ')}... |
class Api::V1::MeaningsController < ApplicationController
def index
@meanings = Meaning.all
render json: @meanings
end
def show
@meaning = Meaning.find(params[:id])
render json: @meaning
end
end
|
class AddSpecializationToSpecialist < ActiveRecord::Migration[5.0]
def change
add_column :specialists, :specialization, :string
add_column :specialists, :hourly_rate, :integer
end
end
|
class Image < ActiveRecord::Base
attr_accessible :name, :image, :area_id, :order
# Associations
belongs_to :area, :include => :area_category, :counter_cache => true
# Callbacks
before_save :update_image_attributes
# carrierwave
mount_uploader :image, MapUploader
# Validates
validates :image, :a... |
class ProductrequestsController < ApplicationController
layout 'productrequest'
http_basic_authenticate_with name: "admin", password: "1af2af3af4af5", except: [:new, :create]
before_action :set_productrequest, only: [:show, :edit, :update, :destroy]
helper_method :set_fullfilled
# GET /productrequests
# GE... |
class Api::V1::ProjectSerializer < ActiveModel::Serializer
attributes :accessible,
:address1,
:address2,
:age_ranges,
:campuses,
:categories,
:checkin_end,
:checkin_start,
:city,
:coleaders,
... |
class Entry < ActiveRecord::Base
default_scope lambda { order 'published_at DESC' }
attr_accessor :authors
belongs_to :author, foreign_key: :author_id, class_name: 'Author', autosave: true
before_save do
author = Author.find_by_uid self.authors[0]
author ||= self.create_author uid: self.authors[0]
... |
require 'socket'
require 'timeout'
require 'optparse'
opts = OptionParser.new
opts.on("-H HOSTNAME", "--hostname NAME", String, "Hostname of Server (Required)") { |v| @hostname = v }
opts.on("-P PORT", "--port PORT", String, "Port number to test (Required)") { |v| @portnumber = v }
opts.on("-h", "--help", "Display thi... |
# frozen_string_literal: true
Rails.application.routes.draw do
root to: 'home#index'
namespace :api do
namespace :v1, defaults: { format: :json } do
resources :products, only: %i[index show create update destroy]
resources :orders, only: %i[index show create update destroy]
resources :bills,... |
class CommentsController < ApplicationController
before_action :verify_authorized
def create
@comment = current_user.comments.new(safe_params)
if @comment.save
redirect_to :posts, notice: 'Comment saved.'
else
render :new
end
end
def edit
@comment = Comment.find(params[:id])
... |
# Copyright (c) 2006, 2007 Ruffdogs Software, Inc.
# Authors: Adam Lebsack <adam@holonyx.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License.
#
# This program ... |
class KeysController < ApplicationController
def create
@key = Key.new(key_params)
if @key.save
render json: @key, status: :created
else
render json: @key.errors, status: :unprocessable_entity
end
end
private
def key_params
params.permit(:password)
end
end
|
require "menthol/provider"
require "menthol/account"
module Menthol
class UOBAM < Provider
private
def login_url
"https://echannel.uobam.co.th/fundcyber/Account/Login"
end
def login
sleep 1
submit_credentials({
username: "UserName",
password: "Password",
b... |
class AddDueDatetimeToTasks < ActiveRecord::Migration
def change
add_column :tasks, :due_datetime, :datetime
end
end
|
class TurnsController < ApplicationController
def create
@game = Game.find(params[:game_id])
if @game.take_turn(params[:square])
@game.process_ai_turns!
if @game.over?
flash[:notice] = "Game Over!"
end
redirect_to game_path(@game)
else
flash[:error] = "Error! Still ... |
class AnimalsController < ApplicationController
before_action :set_animal, only: [:show, :update, :destroy]
load_and_authorize_resource
# GET /animals
def index
@animals = Animal.all
render json: @animals
end
# GET /animals/1
def show
render json: @animal
end
# POST /animals
def crea... |
class SubjectGroup < ActiveRecord::Base
##
# Associations
has_many :subjects, :through => :subjects_subject_groups
has_many :subjects_subject_groups
##
# Attributes
# attr_accessible :description, :name, :subject_ids
##
# Callbacks
##
# Concerns
include Loggable, Indexable, Deletable
##
... |
class TwitterUser < ActiveRecord::Base
###-------------------------------------------------------------------------------
# Initializers
###-------------------------------------------------------------------------------
attr_accessible :description, :location, :name, :profile_image_url, :protected, :screen_nam... |
require_relative "account"
module Bank
class SavingsAccount < Account
def initialize(id, balance)
@id = id
@balance = balance
raise ArgumentError.new("balance must be >= 10") if balance < 10
end
def withdraw(amount)
amount += 2
raise ArgumentError.new("withdrawal amount must... |
# refresh the rank from another API
class Tasks::Cron::RefreshMarketCoinsRanks
def initialize
puts "Task initialized."
end
def perform
MarketCoin.all.each do |market_coin|
if ranks[market_coin.symbol].present?
market_coin.update!(rank: ranks[market_coin.symbol])
puts "[OK] MarketCo... |
json.array!(@admins) do |admin|
json.extract! admin, :id, :rut, :nombre, :telefono, :direccion
json.url admin_url(admin, format: :json)
end
|
require_dependency 'issue_query'
module IssueQueryPatch
def self.included(base) # :nodoc:
base.send(:include, InstanceMethods)
base.class_eval do
unloadable
alias_method_chain :available_columns, :patch
alias_method_chain :initialize_available_filters, :patch
self.available_columns.... |
module GroupDocs
class Signature::Role < Api::Entity
#
# Returns array of predefined roles.
#
# @param [Hash] options Hash of options
# @option options [String] :id Filter by identifier
# @param [Hash] access Access credentials
# @option access [String] :client_id
# @option access [St... |
require 'rubygems'
require 'rspec'
require 'pry-debugger'
require_relative '../war.rb'
<<<<<<< HEAD
describe 'Card' do
describe 'initialize' do
it "initializes as a 'Node' with an in_front and in_back pointer" do
card = Card.new(2, 2, "Spades")
expect(card.class).to eq(Card)
expect(card.in_fron... |
class Parsers::Utporn::Daily < ApplicationRecord
def self.run
start_time = Time.now
log = Log.create(title: 'Daily Parser - UtPorn', body: "Start Job - #{start_time}<br>")
require 'open-uri'
tube = Tube.find_by_name('utPorn')
return 'No Tube' if tube.nil?
# download dump
log.write_to_lo... |
class SoupBroadcastJob < ApplicationJob
queue_as :default
def perform(soup)
ActionCable.server.broadcast("soup_#{soup.id}_channel", type: "soup")
end
end
|
class ToolPhotosController < ApplicationController
before_action :authenticate
def create
blob_name = build_blob_name
container = 'tool-images'
blob_url = container + '/' + blob_name
image = {data: Base64.decode64(params[:tool][:image][:data]), filesize: params[:tool][:image][:filesize], fileName: ... |
# lib/king.rb
class King < Piece
def move?(dst_x, dst_y)
dx = (dst_x - @pos_x).abs
dy = (dst_y - @pos_y).abs
if (dx == 0 || dx == 1) &&
(dy == 0 || dy == 1)
true
else
false
end
end
end
|
require "aethyr/core/actions/commands/command_action"
module Aethyr
module Core
module Actions
module Fill
class FillCommand < Aethyr::Extend::CommandAction
def initialize(actor, **data)
super(actor, **data)
end
def action
event = @data
... |
require "test_helper"
class AdminEditsItemTest < ActionDispatch::IntegrationTest
test "admin edits item" do
admin = create(:admin)
stache = create(:stache, name: "Chaplin", price: 4, description: "kljdf",
retired: false)
ApplicationController.any_instance.stubs(:current_user)... |
class MessageBroadcastJob < ApplicationJob
queue_as :default
def perform(message)
ActionCable.server.broadcast "room_channel_#{message.room_id}", mymessage: render_message(message, true), othersmessage: render_message(message, false), id: message.user.id
end
# ビミョ!!
private
def render_message(message... |
require 'spec_helper'
describe Resty::Factory do
let(:transport) { mock('transport') }
let(:factory) { Resty::Factory.new(transport) }
describe "initialization" do
subject { factory }
its(:transport) { should == transport }
end
describe "#from" do
let(:data) { { 'a' => 12 } }
... |
# frozen_string_literal: true
RSpec.describe 'kiosk_layouts/show', type: :view do
before do
assign(:kiosk_layout, create(:kiosk_layout))
render
end
it { expect(rendered).to match(/touch/) }
end
|
require 'graphviz'
require 'erb'
module Designer
module Graph
GRAPH_ATTRIBUTES = {
:rankdir => :LR,
:ranksep => 0.5,
:nodesep => 0.4,
:pad => "0.4,0.4",
:margin => "0,0",
:concentrate => true,
:labelloc => :t,
:fontsize => 13,
:fontname => "Arial Bold"
}... |
class AdministratorPolicy < ApplicationPolicy
include Roles
attr_reader :user, :administrator
def initialize(user, administrator)
@user = user
@administrator = administrator
end
def show?
is_admin? user
end
def home?
user == @administrator
end
end
|
class CreateDealDetails < ActiveRecord::Migration
def self.up
create_table :deal_details do |t|
t.string :company_name
t.string :merchant_name
t.string :deal_name
t.string :date_to_run
t.string :deal_expiration_date
t.integer :max_total_purchase
t.integer :max_customer_pu... |
class TicketsController < ApplicationController
def index
@event = Event.find(params[:event_id])
end
def new
@event = Event.find(params[:event_id])
end
def create
@ticket_type = TicketType.new ticket_params
@ticket_type.event_id = params[:event_id]
case
when exist_price?(@ticket_type... |
ActiveAdmin.register Purchaser do
# See permitted parameters documentation:
# https://github.com/activeadmin/activeadmin/blob/master/docs/2-resource-customization.md#setting-up-strong-parameters
#
# permit_params :list, :of, :attributes, :on, :model
#
# or
#
# permit_params do
# permitted = [:permitted, :attributes]... |
class LoginController < ApplicationController
skip_before_filter :require_login, :only => [:new, :create]
layout "login"
def new
end
def create
user = User.authenticate(params)
if user
session[:current_user_id] = user.id
redirect_to user_path(user)
else
flash[:alert] = "Incor... |
# frozen_string_literal: true
# @private
# An internal join model not to be used directly
class ClaimClaimant < ApplicationRecord
belongs_to :claim
belongs_to :claimant
default_scope { order(id: :asc) }
end
|
require 'parser/current'
require_relative './ruby_class'
require_relative './node_wrapper'
require_relative './const_definition_finder'
class ClassDefinitionProcessor < Parser::AST::Processor
CLASS_OR_MODULE = %i(class module)
attr_accessor :klasses
def initialize(*)
super
@klasses = []
@nesting =... |
# -*- encoding : utf-8 -*-
require 'singleton'
module Magti
# URL for sending SMS.
SMS_SEND_URL = 'http://81.95.160.47/mt/oneway'
# URL for tracking SMS status.
SMS_TRACK_URL = 'http://81.95.160.47/bi/track.php'
# Maximum size of individual SMS message.
MAX_SIZE = 160
# Service configuration class.
... |
require 'mirrors/iseq/visitor'
require 'mirrors/marker'
module Mirrors
module ISeq
# examines opcodes and aggregates references to classes, methods, and
# fields.
#
# @!attribute [r] markers
# @return [Array<Marker>] after {#call}, the class/method/field
# references found in the byteco... |
class CartItemsController < ApplicationController
before_action :authenticate_customer!
def index
@cart_items = CartItem.where(customer_id: current_customer.id)
end
def create
@cart_item = current_customer.cart_items.build(cart_item_params)
@cart_items = current_customer.cart_items.all
unless @cart_item.qua... |
# frozen_string_literal: true
module Rokaki
module FilterModel
class BasicFilter
def initialize(keys:, prefix:, infix:, like_semantics:, i_like_semantics:, db:)
@keys = keys
@prefix = prefix
@infix = infix
@like_semantics = like_semantics
@i_like_semantics = i_like_s... |
module GroupDocs
class Signature::Envelope::Log < Api::Entity
# @attr [String] id
attr_accessor :id
# @attr [String] date
attr_accessor :date
# @attr [String] userName
attr_accessor :userName
# @attr [String] action
attr_accessor :action
# @attr [String] remoteAddress
attr_acc... |
#!/usr/bin/env ruby
require 'digest'
IN = 'eDP-1'
SLEEPSECS = 5
PIDFILE = File.join ENV['HOME'], '.monitor-hotplug.pid'
DEBUG = false
PRECMD = []
#PRECMD = ['xrandr --newmode "1920x1080" 173.00 1920 2048 2248 2576 1080 1083 1088 1120 -hsync +vsync', 'xrandr --addmode eDP-1 "1920x1080"']
POSTCMD = ['i3 restart', 'n... |
# == Schema Information
#
# Table name: book_identifiers
#
# id :integer not null, primary key
# client_id :integer not null
# book_id :integer not null
# code :string(20) not null
# created_at :datetime not null
# updated_at :datetime not null
#
... |
Rails.application.routes.draw do
default_url_options :host => "example.com"
root 'sessions#new'
get '/html' => 'prep_courses#html'
get '/javascript' => 'prep_courses#javascript'
get '/git' => 'prep_courses#git'
get '/ruby' => 'prep_courses#ruby'
get '/intro'=> 'prep_courses#intro'
get '/submit' => 'prep... |
class Tag < ActiveRecord::Base
validates :name, presence: true, uniqueness: true
has_many :recipe_tags, dependent: :destroy
has_many :recipes, through: :recipe_tags
end
|
require 'pry'
class Race < ActiveRecord::Base
has_many :drivers, through: :finishing_positions
has_many :finishing_positions
def determine_race_score(driver)
# creates a race score for a driver
skill = driver.skill_factor
technology = driver.constructor.tech_factor
rand * 10 * skill * technolog... |
class Foodstuff < ApplicationRecord
has_many :best_foodstuffs
has_many :seasons, through: :best_foodstuffs
has_many :morimori_foodstuffs
has_many :morimoris, through: :morimori_foodstuffs
has_many :foodstuff_makes
has_many :makes, through: :foodstuff_makes
belongs_to :category
end
|
# frozen_string_literal: true
class ChangeStatusFieldForAttendance < ActiveRecord::Migration[5.1]
def up
add_column :attendances, :status_string, :string
execute('UPDATE attendances SET status_string = status;')
execute('UPDATE attendances SET status = null;')
remove_column :attendances, :status
... |
Rails.application.routes.draw do
devise_for :users, controllers: { omniauth_callbacks: 'users/omniauth_callbacks', registrations: 'users/registrations' }
# sets the index action for the books controller as the root path for a signed in user
# sets up the log in page as root path for an unauthenticated user
... |
module ExamRoom::Practice
def self.table_name_prefix
'exam_room_practice_'
end
end
|
Then(/^I should be on the cfs files page for the (.*) with (.*) '([^']*)'$/) do |object_type, key, value|
expect(current_path).to eq(specific_object_path(object_type, key, value, prefix: 'cfs_files'))
end
|
Rails.application.routes.draw do
root 'application#info'
# user namespace
namespace :v1 do
post 'user_token' => 'user_token#create'
resources :offers, only: [:index, :show, :create]
end
# admin namespace
namespace Settings.routes.admin_namespace do
Sidekiq::Web.use Rack::Auth::Basic do |usern... |
require 'singleton'
class PhotoFrame
class Config
include Singleton
attr_accessor :paths, :patterns, :secret, :shuffle
attr_reader :root
def initialize
self.paths, self.patterns = [], []
self.shuffle = false
end
def root=(path)
@root = path
@root.send(:extend, Root)... |
# encoding: utf-8
module Antelope
module Ace
class Scanner
# Scans the second part of the file. The second part of the
# file _only_ contains productions (or rules). Rules have a
# label and a body; the label may be any lowercase alphabetical
# identifier followed by a colon; the body ... |
class Song < ActiveRecord::Base
belongs_to :user
has_many :votes
validates :song_title, presence: true, length: { maximum: 140 }
validates :author, presence: true, length: { maximum: 25 }
validates :url, format: { with: URI.regexp,
message: "%{value} is not valid" }
end |
class EventsController < ApplicationController
before_action :find_event, only: [:show, :edit, :update, :destroy]
def index
@active_events = Event.where(status: "Active")
@inactive_events = Event.where(status: "Inactive")
@past_events = Event.where(status: "Past")
@current_user = User.find(session... |
# encoding: UTF-8
module Decider
module Clustering
class Hierarchical < Base
def tree
unless @tree
@tree = Tree.new
corpus.documents.each do |doc|
@tree.insert(doc.name, vector(doc))
end
end
@tree
end
def root_node
... |
class Chapter
include Mongoid::Document
field :title
attr_accessible :title
belongs_to :book
end
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.