text stringlengths 10 2.61M |
|---|
class Car < ActiveRecord::Base
belongs_to :request
has_many :codes , :dependent => :destroy
# def rate_jd
# self.codes.empty? ? 0 : self.codes.map{|code| code.rate_jd}.sum
# end
# def rate_jd_real
# self.codes.empty? ? 0 : self.codes.map{|code| code.rate_jd_real}.sum
# end
# def rate_client
# self.... |
# frozen_string_literal: true
class CinemaHall < ApplicationRecord
has_many :screenings, dependent: :destroy
validates :name, presence: true, uniqueness: true
validates :row_number, presence: true, inclusion: { in: 5..10 }
validates :row_total_seats, presence: true, inclusion: { in: 4..20 }
end
|
class Admin::Attributes::ImprovementLandsController < ApplicationController
before_filter :authenticate_admin
before_filter :current_admin
layout 'admin'
def index
@improvements = PropertyAttrImprovementLand.order('sort').all
end
def show
@improvement = PropertyAttrImprovementLand.find(params[:id]... |
#
# Cookbook Name:: authconfig
# Recipe:: default
#
# Copyright 2012, Jesse Campbell
#
# All rights reserved - Do Not Redistribute
#
# 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
#
# htt... |
require 'rails_helper'
RSpec.describe "Favorites - A user", type: :feature do
before(:each) do
@shelter_1 = Shelter.create( name: "Henry Porter's Puppies",
address: "1315 Monaco Parkway",
city: "Denver",
state: "CO",
... |
ActiveAdmin.register_page "Dashboard" do
menu priority: 1, label: proc{ I18n.t("active_admin.dashboard") }
content title: "Recent Photos" do
section "Recent Photos" do
table_for Photo.order(created_at: :desc).limit(15) do
column :title
column :description
column :user do |photo|
... |
require 'spec_helper'
module Rockauth
RSpec.describe ProviderAuthenticationsController, type: :controller, social_auth: true do
describe "GET index" do
context "when unauthenticated" do
it "denies access" do
get :index
expect(response).not_to be_success
expect(response... |
require 'spec_helper'
feature 'User adds an app', %Q{
As a user
I want to add an app
So that I can share it on the site
} do
# Acceptance Criteria:
# I must be logged in
# I must specify a title
# I must specify a description
# It must be associated with my user account
# I must provide a photo of... |
Rails.application.routes.draw do
root to: "app#index"
resource :access, only: [:new, :create, :destroy], controller: "access"
get 'admin', to: "access#show"
get "auth/facebook/callback", to: "sessions#create"
resource :user, only: [:edit, :update]
namespace :admin, defaults: { format: :json } do
put... |
require 'test_helper'
class Manage::SchoolsControllerTest < ActionDispatch::IntegrationTest
setup do
@manage_school = manage_schools(:one)
end
test "should get index" do
get manage_schools_url
assert_response :success
end
test "should get new" do
get new_manage_school_url
assert_respons... |
Then /should be on the conversation page$/ do
current_path.should == conversation_path(@conversation)
end
Then /^I will be on the invitation page$/ do
current_path.should == new_invite_path
end
Then /^I should see a textarea for invitee email addresses$/ do
page.should have_selector('textarea#invites_emails')
e... |
#
# Makes a module behave as a factory.
#
# A module that extends FactoryModule gets a method #new(klass_name, *args):
# this finds the class corresponding to klass_name and creates it with *args as
# arguments.
#
# if +klass_name+ is a class, it's used directly. Otherwise, it's converted to
# a class, and can be in u... |
require './environment'
require 'test/unit'
require 'minitest/pride'
class FlashCardTest < Test::Unit::TestCase
def test_can_initialize
assert FlashCard.new(word: 'Ruby', definition: 'A programming language', pronunciation: "sounds like it's spelled")
end
# don't have description tell how to implement, only ... |
ActiveAdmin.register Offer do
filter :producer
filter :offer_starts_at
filter :offer_ends_at
permit_params :deliver_coordinator_id, :bank_account_id, :producer_id, :title, :image, :value, :stock,
:description, :offer_ends_at, :operational_tax, :coordinator_tax,
:collect_ends_at,... |
class GuestsController < ApplicationController
def index
end
def retrieve_guest
first = params[:first_name].capitalize
last = params[:last_name].capitalize
guest = Guest.where({first_name: first, last_name: last, zip_code: params[:zip_code]}).first
if guest == nil
redirect_to "/", :flash =>... |
# frozen_string_literal: true
class AddDescriptionToParts < ActiveRecord::Migration[5.0]
def change
add_column :parts, :description, :string
end
end
|
module RSence
module Plugins
# Use the Servlet class to create responders for GET / POST urls.
#
# A Servlet's public API is accessible like the other plugins directly.
#
# == Responding to a URL consists of four phases:
# 1. PluginManager calls every {Servlet__#match #match} method
... |
# frozen_string_literal: true
# From the moment you require this file "config/application.rb"
# the booting process goes like this:
#
# 1) require "config/boot.rb" to setup load paths
# a) custom: require "config/settings.rb" to make all ENV variables available under the Settings class
# b) custom: require ... |
class ::String
# These methods should not be used in new code
# Instead use the examples provided.
# Don't use! Instead, write like this:
#
# require 'active_support'
# require 'active_support/core_ext/string/inflections'
#
# 'ActiveSupportString'.underscore # result: "active_support_string"
def to_s... |
require 'rails_helper'
require 'sidekiq/testing'
RSpec.describe ManualBatchTradeService do
let(:user) {
User.create!(
email: 'foo@bar.com',
password: 'abcdabcd',
huobi_access_key: 'oo',
huobi_secret_key: 'ooo',
trader_id: trader.id,
)
}
let(:trader) {
Trader.create!(web... |
require 'spec_helper'
require 'timecop'
RSpec.describe Bambooing::Support::Date do
describe '.cweekdays' do
before do
Timecop.freeze(Date.new(2019,5,28))
end
it 'returns the weekdays for the current week' do
result = described_class.cweekdays
expect(result).to eq([
Date.new(201... |
class City < ActiveRecord::Base
has_many :neighborhoods
has_many :listings, :through => :neighborhoods
has_many :reservations, through: :listings
def city_openings(date_1, date_2)
start_date = Date.parse(date_1)
end_date = Date.parse(date_2)
open_listings = []
listings.each do |listing|
taken = listing.... |
class SecretsController < ApplicationController
before_action :require_login
skip_before_action :require_login, only: [:index, :login]
def home
@user = session[:current_user]
end
def show
end
def require_login
redirect_to login_path unless session.include? :name
end
end
|
require 'rails_helper'
require 'support/user_factory'
require 'support/store_factory'
describe StoresController do
let(:user) { UserFactory.create }
describe 'GET #new' do
it 'renders new template' do
get :new, session: { user_id: user.id }, params: { user_id: user.id }
expect(response).to render... |
# Notebooks controller
class NotebooksController < ApplicationController
collection_methods = [ # rubocop: disable Lint/UselessAssignment
:index,
:stars,
:suggested,
:recently_executed
]
member_readers_anonymous = %i[
show
download
uuid
friendly_url
]
member_readers_login = %i[... |
class AddressesController < ApplicationController
before_action :set_address
def index
@addresses = Address.all
end
def new
@address = Address.new
end
def show
redirect_to edit_address_path(@address)
end
def create
@address = Address.new(address_params)
if @address.save
red... |
=begin
Write a program called age.rb that asks a user how old they are and then tells them how old they will be in 10, 20, 30 and 40 years. Below is the output for someone 20 years old.
=end
puts "How old are you?"
age = gets.to_i
# .to_i converts the string into an integer so we can add it later. good reminder that g... |
#
# Cookbook Name:: cubrid
# Attributes:: default
#
# Copyright 2012, Esen Sagynov <kadishmal@gmail.com>
#
# Distributed under MIT license
#
include_attribute "cubrid::broker"
include_attribute "cubrid::database"
# Latest build numbers for each CUBRID version in the form of 'version'=>'build_number'.
build_numbers = ... |
class BookingsController < ApplicationController
def new
@listing = Listing.find(params[:listing_id])
@booking = @listing.bookings.new
end
def create
@listing = Listing.find(params[:listing_id])
@total_price = (Date.strptime(params[:booking][:end_date], '%Y-%m-%d') - Date.strptime(params[:booking][:start_da... |
# Desc: Rakefile for c++ projects
##################################
# the final executable file name:
FINAL = %w[bin/main.exe]
# compiler options:
CC = "g++ -Wall"
INCS = "-Iinclude"
OPTS = "-std=c++0x -g" # <- (-g= debug symbols), (c++0x= regex support)
LIBS = ""
# file lists:
EXE = FileList['bin/*.exe']
SR... |
class Vote < ApplicationRecord
## Associations
belongs_to :user
belongs_to :election
## Validations
validates_presence_of :user_id, :election_id
validates_uniqueness_of :user_id, scope: :election_id, message: "You have already casted your vote."
end
|
module JWT
class Middleware
def initialize(app)
@app = app
end
def call(env)
encoded_token = extract_bearer(env['HTTP_AUTHORIZATION'])
begin
env['jwt.token.payload'] = Token.decode!(encoded_token)
.payload
rescue JWT::DecodeError,... |
class ReportsController < ApplicationController
before_action :set_report, only: [:show, :edit, :update, :destroy]
before_action :authenticate_user!
# GET /reports
# GET /reports.json
def index
reported_posts = Report.get_reported_posts
@reports = Array.new
reported_posts.each do |post|
repo... |
require_relative '../great_circle_distance'
RSpec.describe GreatCircleDistance do
describe '#calculate' do
let(:lat1) { 53.1302756 }
let(:lon1) { -6.2397222 }
let(:lat2) { -6.257664 }
let(:lon2) { 53.339428 }
let(:subject) { GreatCircleDistance.new(lat1: lat1, lon1: lon1, lat2: lat2, ... |
class Organization < ApplicationRecord
has_many :events
has_many :memberships
has_many :users, through: :memberships
has_many :notification_preferences, as: :settable, dependent: :destroy
validates :name, presence: true
end
|
class Post < ApplicationRecord
extend FriendlyId
friendly_id :title, use: :slugged
mount_uploader :image, AvatarUploader
belongs_to :user
default_scope { order("created_at DESC") }
validates :title, :body, presence: true
has_many :comments, dependent: :destroy
end
|
class RemoveColumnCollectDateFromExams < ActiveRecord::Migration
def change
remove_column :exams, :collect_date
end
end
|
class DmCms::Admin::CmsPostsController < DmCms::Admin::AdminController
include DmCms::PermittedParams
before_filter :blog_lookup
before_filter :post_lookup, :except => [:new, :create]
#------------------------------------------------------------------------------
def new
@post = @blog.posts.build... |
class CreateCycleScores < ActiveRecord::Migration
def change
create_table :cycle_scores do |t|
t.integer :score
t.belongs_to :cycle, foreign_key: true, index: true
t.belongs_to :organization, foreign_key: true, index: true
t.timestamps null: false
end
end
end
|
class User < ActiveRecord::Base
has_many :bookings
has_many :rooms, through: :bookings
end
|
class UserSerializer < ActiveModel::Serializer
attributes :id,
:username,
:phone_number,
:email,
:fridges
end
|
# for i in ["a", "b", "c"] do
# puts i
# end
# iterators are methods that loop over a given set of data and allow you to operate on each element
# each is the method that works on arrays and hashes then it begins executing the code within the block. the block is defined by the {}. the var is defined in || then imple... |
require_relative 'constant'
require_relative 'addition'
require_relative 'subtraction'
require_relative 'multiplication'
require_relative 'division'
class ExpressionReader
def self.read(expression)
expression_token = expression.split(' ')
first_constant = Constant.new(expression_token[Operators::FIRST_CONSTA... |
# Связь тега тикета и тикета
class TicketTagRelation < ActiveRecord::Base
belongs_to :ticket
belongs_to :ticket_tag
validates :ticket, :ticket_tag, presence: true
attr_accessible :active, as: :admin
after_save :subscribe_users, if: :active?
scope :active, joins(:ticket_tag).where(ticket_tags: { sta... |
class CreateSymptomSubdoshas < ActiveRecord::Migration
def change
create_table :symptom_subdoshas do |t|
t.references :symptom, index: true
t.references :subdosha, index: true
t.timestamps
end
end
end
|
require 'pry'
module Log
attr_accessor :logs
class << self
def get_logs
@logs=""
puts "Enter number of logs"
n= gets.to_i
while n>0
begin
puts "Iteration #{n}"
puts "enter duration in hh:mm:ss"
duration = gets.chomp
# raise exception if regex doesn't match
raise unless duration.ma... |
FakeWeb.allow_net_connect = false
# Some WSDL and SOAP request.
FakeWeb.register_uri :post, EndpointHelper.soap_endpoint, :body => ResponseFixture.authentication
# WSDL and SOAP request with a Savon::SOAPFault.
FakeWeb.register_uri :post, EndpointHelper.soap_endpoint(:soap_fault), :body => ResponseFixture.soap_fault
... |
module FunWithJsonApi
module Attributes
class FloatAttribute < FunWithJsonApi::Attribute
def call(value)
Float(value.to_s) if value
rescue ArgumentError => exception
raise build_invalid_attribute_error(exception, value)
end
private
def build_invalid_attribute_error(... |
class ContactsController < ApplicationController
def new
@contact = Contact.new
end
def create
@contact = Contact.create(contact_params)
if @contact.save
#InfoMailer.form_contact(@contact).deliver
redirect_to root_path, notice: "se ha enviado tu mensaje de contacto"
else
redirec... |
require 'rails_helper'
RSpec.describe PaymentDecorator, :payment do
describe 'methods' do
context 'with account' do
it '#human_ref is returned' do
property = property_create human_ref: 15, account: account_new
payment = described_class.new payment_new
payment.account_id = property.a... |
class Comment
include Mongoid::Document
include Mongoid::Timestamps
field :content, type: String
field :user_name, type: String
field :user_id, type: String
scope :recent, order_by(created_at: :desc)
scope :check_new, ->(user_id, since) { excludes(user_id: user_id).where(:created_at.gt => since) }
... |
# frozen_string_literal: true
require 'minitest/autorun'
require 'minitest/pride'
require_relative 'best_users'
# main test class
class BestUsers < Minitest::Test
def test_basic_array_1
a1 = %w[A042 B004 A025 A042 C025]
a2 = %w[B009 B040 B004 A042 A025 A042]
a3 = %w[A042 A025 B004]
assert_equal(id_... |
require 'wlang/encoder'
module WLang
#
# This class allows grouping encoders together to build a given dialect.
# Encoders are always added with add_encoder, which also allows creating simple
# encoders on the fly (that is, without subclassing Encoder).
#
# Examples:
# # we will create a simple encode... |
#coding: utf-8
class Dashboard::EmailsController < Dashboard::ApplicationController
inherit_resources
before_filter :check_permissions
belongs_to :mail_box
defaults :route_prefix => "dashboard"
respond_to :html
protected
def collection
@emails ||= end_of_association_chain.paginate(page: params[:p... |
# 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 AlunosController < ApplicationController
before_action :set_aluno, only: [:show, :edit, :update, :destroy]
before_action :authenticate_user!, except: [:index, :show]
require 'csv'
# GET /alunos
# GET /alunos.json
def index
if session[:curso_id] == nil
redirect_to root_url and return
... |
require 'prawn'
require 'mongo'
class PlaylistController < ApplicationController
before_filter :authenticate_user, :prepare_session
def initialize
@fs = Mongo::GridFileSystem.new(MongoMapper.database)
@grid = Mongo::Grid.new(MongoMapper.database)
# Invoke initialize in superclass, so rails can do it... |
# frozen_string_literal: true
module Decidim
module Participations
# A command with all the business logic when a user updates a participation.
class UpdateParticipation < Rectify::Command
# Public: Initializes the command.
#
# form - A form object with the params.
# current_u... |
# == Schema Information
#
# Table name: posts
#
# id :integer not null, primary key
# title :string(255)
# content :text(65535)
# start_date :date
# budget :float(24)
# username :string(255)
# created_at :datetime not null
# updated_at :datetime not... |
$: << 'C:\M1\dlr\Languages\Ruby\Libs'
require 'socket'
require 'fcntl'
require 'thread'
class WebServer
def initialize
@tokens = SizedQueue.new(5)
5.times{ @tokens.push(nil) }
end
def run
thgroup = ThreadGroup.new
@status = :Running
@listeners = [TCPServer.new("127.0.0.1", 3000)]
while @status == :... |
require 'test_helper'
class MongoTest < ActiveSupport::TestCase
test "the truth" do
assert true
end
test "be able to write and read connection" do
conn = Mongo::MongoClient.new
MongoMapper.connection = conn
assert_not_nil(MongoMapper.connection)
end
test "save a user to the database" do
... |
# frozen_string_literal: true
# rubocop:todo all
# Copyright (C) 2014-2020 MongoDB Inc.
#
# 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
#
# U... |
class CreateSitePages < ActiveRecord::Migration
def change
create_table :site_pages do |t|
t.references :site, index: true
t.string :key
t.string :title
t.string :keywords
t.string :description
t.text :content
t.timestamps
end
add_index :site_pages, :key, unique:... |
require File.join(File.dirname(__FILE__), '..', '..', 'spec_helper')
describe Twitter::Client, "#favorites" do
before(:each) do
@uri = '/favorites.json'
@request = mas_net_http_get(:basic_auth => nil)
@twitter = client_context
@default_header = @twitter.send(:http_header)
@response = mas_net_http... |
class UsersController < ApplicationController
include ReportHelper
before_action :set_user, only: [:show, :edit, :update, :destroy, :report]
before_action :ensure_that_signed_in, except: [:new, :create]
before_action :ensure_authority, only: [:edit, :update, :destroy]
# GET /users/1
# GET /users/1.json
d... |
module Domgen
module Generator
module EJB
TEMPLATE_DIRECTORY = "#{File.dirname(__FILE__)}/templates"
FACETS = [:ejb]
HELPERS = [Domgen::Java::Helper, Domgen::JAXB::Helper]
end
end
end
Domgen.template_set(:ejb_services => [:ee_exceptions]) do |template_set|
template_set.template(Domgen::G... |
class Post < ActiveRecord::Base
has_many :post_categories
has_many :categories, :through => :post_categories
has_many :taggings, :as => :taggable
has_many :tags, :through => :taggings
belongs_to :user
end
|
require "active_model/validations/presence"
module Paperclip
module Validators
class AttachmentFileTypeIgnoranceValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
# This doesn't do anything. It's just to mark that you don't care about
# the file_names or cont... |
class UpdateShows < ActiveRecord::Migration[5.1]
def change
add_column :shows, :end_date, :datetime
# HubSpot Shows
add_column :shows, :from_hubspot, :boolean, default: false
# Compensation
add_column :shows, :fee, :integer
add_column :shows, :hotel, :string
add_column :shows, :ground, :... |
# === DEBUG STUFF ===
debug = true
harmless = false
testrun = false
attached = true
short = false
# === INITS ===
dir_list = Hash.new
class String
def cut_trailing_slash
if self[-1] == "/"
self.slice!(-1)
end
end
end
unless testrun
# === USER INPUT ===
# Make parent dummy directory
puts "Let'... |
class Array
# The include of Enumerable is necessary so that the specs that ensure
# Array includes Enumerable pass. We immediately override most of
# Enumerable (but *do* pick up on the sort).
include Enumerable
# These are the overrides of Enumerable for performance reasons
#
# TODO: After Enumerable ... |
class ReviewsController < ApplicationController
before_filter :find_item, only: [:create, :edit, :update, :destroy]
def create
@review = @item.reviews.build(review_params)
if @review.save
flash[:notice] = "Thanks for the review!"
else
flash[:error] = @review.errors.full_messages.join(", ")
... |
class CSVFormatter
attr_reader :parsed_data
def initialize(parsed_data)
@parsed_data = parsed_data
end
def all_words
format_words(words)
end
private
def words
parsed_data.inject("") do |words, row|
words += row['transcript'] + " "
end
end
def format_words(words)
words.gs... |
require 'objects/f5_object'
require 'utils/resolution'
module F5_Object
# Abstract F5_Object that manages all facility-level objects in a data center
class Facility < F5_Object
include Resolution
# Hacky way to have global access to current Facility name
# Generally no collisions because there is alwa... |
module WebServer
class Request
attr_reader :http_method, :uri, :version, :headers, :body, :params, :socket
def initialize(socket)
@socket = socket
@headers = Hash.new
@body = String.new
@params = Hash.new
end
# I've added this as a convenience method, see TODO (This is calle... |
class Inventory < ActiveRecord::Base
attr_accessible :balance_on_hand, :min_balance, :product_id
belongs_to :product
after_save :check_inventory_level
def check_inventory_level
if self.balance_on_hand < self.min_balance
inv = Invoice.new
inv.invoice_date = Time.now()
inv.product_id = self.produ... |
require_relative '../../classes/substitution_box'
describe SubstitutionBox do
describe '#sub_bytes' do
it 'transforms [0x9a] to [0xb8]' do
expect(SubstitutionBox.new.sub_bytes([0x9a])).to eq [0Xb8]
end
end
end |
require "spec_helper"
describe JsonSpec::Matchers::IncludeJson do
it "matches included array elements" do
json = %(["one",1,1.0,true,false,null])
expect(json).to include_json(%("one"))
expect(json).to include_json(%(1))
expect(json).to include_json(%(1.0))
expect(json).to include_json(%(true))
... |
class Api < ActiveRecord::Base
include AnuBase
include IdentityCache
self.table_name = 'sys_interface'
self.primary_key = 'if_code'
cache_index :if_code
cache_attribute :uri, :by => [:if_code]
class<<self
def uri if_code
Api.fetch_uri_by_if_code if_code
end
end
end |
class CreateRuleTags < ActiveRecord::Migration
def change
create_table :rule_tags do |t|
t.integer :rule_id
t.integer :tag_id
t.boolean :is_published, :default => false
t.timestamps
end
add_index :rule_tags, :rule_id
add_index :rule_tags, :tag_id
add_index :rule_tags, :is... |
require 'test_helper'
class Asciibook::Converter::LiteralTest < Asciibook::Test
def test_convert_literal
doc = <<~EOF
....
Text
....
EOF
html = <<~EOF
<pre class="literal">Text</pre>
EOF
assert_convert_body html, doc
end
end
|
require 'spec_helper'
describe Immutable::Hash do
describe '#sample' do
let(:hash) { Immutable::Hash.new((:a..:z).zip(1..26)) }
it 'returns a randomly chosen item' do
chosen = 250.times.map { hash.sample }.sort.uniq
chosen.each { |item| hash.include?(item[0]).should == true }
hash.each { |... |
require 'pry'
require './rule_based_translator.rb'
require './simple_equation_solver.rb'
class Student < RuleBasedTranslator
class << self
attr_accessor :student_rules
def format_symbols(string)
string = string.dup
symbols = [".", ",", "%", "$", "+", "-", "*", "/"]
symbols.each { |sym| st... |
class SessionsController < ApplicationController
def new
end
def create
@user = User.find_by_username(params[:session][:username])
if @user && @user.authenticate(params[:session][:password])
session[:user_id] = @user.id
if current_vendor?
redirect_to vendor_dashboard_path(@user.vendor... |
require 'chef/provider'
class Chef
class Provider
class MongodInstance < Chef::Provider
include ::Opscode::MongoDB::ProviderHelpers
def load_current_resource
# it does nothing, but this method must be defined
end
def action_enable
executable = ::File.join(@new_resource.... |
class AddProductsAAuthors < ActiveRecord::Migration
def change
add_column :products, :a_authors, :string, :array => true
reversible do |r|
r.up do
Product.transaction do
Product.where('not(a_authors_json is null)').find_each do |product|
begin
authors = JSON.... |
FactoryBot.define do
factory :user do
nickname { Faker::Name.name }
email { Faker::Internet.free_email }
password { 'password1234' }
password_confirmation { password }
last_name { '苗字' }
first_name { '名前' }
last_name_furigana { 'ミョウジ' }
first_name_furigana { 'ナマエ' }
birthday { '193... |
class AddCheckinIdColumns < ActiveRecord::Migration
# This migration is part of the process of making Checkins more central
# to this application's functions, specifically comments/grading/rating
# functionality.
def up
# NOTE: The following checkin_id columns make the respective tables'
# user_id colu... |
module Kuhsaft
class Page < ActiveRecord::Base
include Kuhsaft::Engine.routes.url_helpers
include Kuhsaft::Orderable
include Kuhsaft::Translatable
include Kuhsaft::BrickList
include Kuhsaft::Searchable
has_ancestry
acts_as_brick_list
translate :title, :page_title, :slug, :keywords, :... |
# frozen_string_literal: true
module BeyondCanvas
module Authentication # :nodoc:
extend ActiveSupport::Concern
private
def beyond_canvas_parameter_sanitizer
@beyond_canvas_parameter_sanitizer ||= BeyondCanvas::ParameterSanitizer.new(:shop, params)
end
end
end
|
class Restaurant < ActiveRecord::Base
has_many :reservations
has_many :users, through: :reservations
belongs_to :owner, class_name: "User", foreign_key: :user_id
has_many :reviews
has_many :users, through: :reviews
validates :name, :address, :phone, :capacity, presence: true
def seats_remaining(time)
... |
class TissEvaluationsController < ApplicationController
before_action :authenticate_user!
before_action :load_patient, only: [ :new, :create ]
load_and_authorize_resource
def index
@patients = Patient.joins(:tiss_evaluations).merge(TissEvaluation.yesterday).order(:name)
@tiss = TissEvaluation.fifteen_d... |
class CreateStockfeatures < ActiveRecord::Migration
def change
create_table :stockfeatures do |t|
t.string :name
t.string :description
t.references :stockproduct, index: true
t.timestamps null: false
end
add_foreign_key :stockfeatures, :stockproducts
end
end
|
class CreateLocations < ActiveRecord::Migration
def up
create_table :locations do |t|
t.string :name
t.string :address
t.float :lat
t.float :long
t.column :rating, :decimal, :precision=> 2, :scale=>1
t.string :redemption_password
t.string :city
t.string :state
... |
module Admin
class AdminUsersController < SuperAdminApplicationController
# GET /admin_users
def index
@admin_users = TeamMember.get_members_for_team(params[:team_id])
@team_id = params[:team_id]
end
# GET /admin_users/1
def show
end
# GET /admin_users/new
def new... |
actions :create, :delete
default_action :create
attribute :work_dir, kind_of: String, default: nil
attribute :instance, kind_of: String, name_attribute: true
attribute :package_name, kind_of: String, default: 'apache2'
attribute :package_version, kind_of: String, default: nil
attribute :bind_address, kind_of: String, ... |
# frozen_string_literal: true
# == Schema Information
#
# Table name: data_tables
#
# id :integer not null, primary key
# admin_id :integer
# category_id :integer not null
# title :string not null
# description ... |
module Spree
module Calculator::Shipping
module Usps
class Base < Spree::Calculator::Shipping::ActiveShipping::Base
PO_BOX_DELIVERY = true
SERVICE_CODE_PREFIX ||= {
:international => 'intl',
:domestic => 'dom'
}
def self.rate_from(result)
... |
class ContactsController < ApplicationController
# protect_from_forgery with: :exception
before_action :authenticate_user! # this will protect the page when not signed in
before_action :find_contact, only: [:show, :edit,:update,:destroy, :delete]
before_action :all_contacts, only: [:index, :show]
def inde... |
module NodeAbxn
# A high level abstraction of node
class Molecule
attr_accessor :type, :conn
def initialize(conn = {},type = :basic)
@type = type # TODO: Temporary skip for this level of abx
@conn = conn # TODO: Temporary skip for this level of abx
end
# Temporary set processing for eac... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.