text stringlengths 10 2.61M |
|---|
class Task
attr_reader :content, :id, :created_at
attr_accessor :complete, :updated_at
@@current_id = 0
def initialize(content)
@content = content
@id = @@current_id
@@current_id += 1
@complete = false
@created_at = Time.now
@updated_at = nil
end
def complete?
@complete ? true : false
end
def comp... |
class FontIbmPlexSansJp < Formula
head "https://github.com/google/fonts.git", verified: "github.com/google/fonts", branch: "main", only_path: "ofl/ibmplexsansjp"
desc "IBM Plex Sans JP"
homepage "https://fonts.google.com/specimen/IBM+Plex+Sans+JP"
def install
(share/"fonts").install "IBMPlexSansJP-Bold.ttf"... |
class RemoveTotalLikesAndTotalDislikesAndTotalVotesAndRatioFromMovie < ActiveRecord::Migration[5.2]
def change
remove_column :movies, :total_likes, :integer
remove_column :movies, :total_dislikes, :integer
remove_column :movies, :total_votes, :integer
remove_column :movies, :ratio, :float
end
end
|
class Link < ActiveRecord::Base
validates_presence_of :given_url
has_many :clicks
has_many :users, :through => :clicks
validates :given_url, format: URI::regexp(%w[http https])
def shorten(url)
chars = ['0'..'9', 'A'..'Z', 'a'..'z'].map { |range| range.to_a }.flatten
self.shortened_url = 5.times.map ... |
# 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... |
class RemoveTimestampsFromFlights < ActiveRecord::Migration[5.0]
def change
remove_column :flights, :created_at
end
end
|
# frozen_string_literal: true
class LineItem < ApplicationRecord
# defines an accessor method
# tells rails that rows in line_items are the children of rows in carts and products
# no line item can exist unless the corresponding carts and product rows exist
# Great rule of thumb - if a table has any columns wh... |
class HomeGroupDecorator < Draper::Decorator
delegate_all
def week_day
h.t('date.day_names')[object.week_day].mb_chars.capitalize.to_s if object.week_day
end
def time
h.l(object.time, format: :time) if object.time
end
def place
h.link_to object.place, [configus.map_search_link, object.place].... |
class CustomersController < ApplicationController
before_filter :authenticate_user!
load_and_authorize_resource
# GET /customers
# GET /customers.json
def index
@customers = Customer.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @customers }
en... |
require 'test_helper'
class ParameterControlsControllerTest < ActionDispatch::IntegrationTest
setup do
@parameter_control = parameter_controls(:one)
end
test "should get index" do
get parameter_controls_url
assert_response :success
end
test "should get new" do
get new_parameter_control_url
... |
module Roglew
class InvalidPixelFormatError < StandardError; end
class OpenGLError < StandardError; end
class CompileError < StandardError; end
class RenderContextError < StandardError; end
end |
class MyObfuscate
class Mysql
def parse_insert_statement(line)
unless line.valid_encoding?
line = line.encode!('UTF-8', 'binary', invalid: :replace, undef: :replace, replace: '')
end
if regex_match = INSERT_REGEX.match(line)
{
:table_name => regex_match[1].to_sym,
... |
require "rails_helper"
describe Post do
it { should validate_attachment_content_type(:post_image).
allowing("image/png", "image/gif", "image/jpg").
rejecting("text/plain", "text/xml") }
it "has proper attributes" do
post = build(:post)
expect(post).to be_valid
end
it "can't be created ... |
class SpotsController < ApplicationController
def new
@spot = Spot.new
end
def index
@spots = Spot.all
# @topics = Topic.all.includes(:favorite_users).order(created_at: :desc)
end
def create
@spot = Spot.new(spot_params)
if @spot.save
redirect_to new_plan_spot_path(@spot.plan_id), ... |
class MergeReportingRelationshipsController < ApplicationController
before_action :authenticate_user!
skip_after_action :intercom_rails_auto_include
def create
rr_current = ReportingRelationship.find_by(
user: current_user,
client: Client.find(merge_params[:client_id])
)
rr_selected = Rep... |
class SnapshotClusterPair
include Mongoid::Document
include Mongoid::Timestamps
belongs_to :e1, class_name: 'SnapshotCluster'
belongs_to :e2, class_name: 'SnapshotCluster'
field :log_distance
field :proportion_distance
index({ e1: 1 })
index({ e2: 1 })
index({ e1: 1 , e2: 1 }, { :unique => true })
... |
class AddGenderToFacilitator < ActiveRecord::Migration
def change
add_column :facilitators, :gender, :string
end
end
|
# A sample Guardfile
# More info at https://github.com/guard/guard#readme
guard 'livereload' do
watch(%r{source/.+\.(erb|haml|slim)})
watch(%r{source/javascripts/\w+(.+\.(coffee|js)).*}) { |m| "/javascripts/all.js" }
watch(%r{source/stylesheets/\w+(.+\.(css|sass)).*}) { |m| "/stylesheets/all.css" }
end
|
class Trigger < ActiveRecord::Base
attr_accessible :item_id, :date_trigger, :subchildren
belongs_to :item
has_many :trigger_emails, :dependent => :destroy
has_many :emails, :through => :trigger_emails
validates :item_id, :date_trigger, presence: true
after_initialize :init #set defaults
def... |
require 'rails_helper'
describe AgencyIdentity do
it { is_expected.to belong_to(:user) }
it { is_expected.to belong_to(:agency) }
describe 'validations' do
let(:agency_identity) { build_stubbed(:agency_identity) }
it { is_expected.to validate_presence_of(:uuid) }
end
describe '#agency_enabled?' do... |
module FacilitiesManagement::Supplier::ContractsHelper
include FacilitiesManagement::ProcurementsHelper
def warning_message
warning_messages = { sent: "This contract offer expires on #{format_date_time(@contract.contract_expiry_date)}. <br/> The buyer is waiting for a response before the offer expiry deadline ... |
class Loadout < ActiveRecord::Base
attr_accessible :player_id, :loadout, :name
serialize :loadout, JSON
belongs_to :player
def store_items(top_level)
top_level.map do |item|
jsonify(item)
end
end
def jsonify(item)
hash = item.as_json
hash[:items] = item.items.map {|it| jsonify(it)}... |
require 'test_helper'
class DtParamsTest < Minitest::Test
def test_empty_params
dt_params = TrkDatatables::DtParams.new({})
assert_equal [], dt_params.dt_columns
end
def test_raise_exception_if_additional_is_not_hash
dt_params = TrkDatatables::DtParams.new({})
e = assert_raises TrkDatatables::Er... |
class LoginPage < GenericBasePage
include DataHelper
element(:username) {|b| b.text_field(id: "username")}
element(:password) {|b| b.text_field(id: "password")}
element(:login) {|b| b.button(id: "login-submit")}
def login_yml(options={})
options = options.with_indifferent_access
options.to_hash.reve... |
Factory.define(:pool) do |f|
f.name {(rand(1_000_000) + 100).to_s}
f.creator {|x| x.association(:user)}
f.description {Faker::Lorem.sentences}
end
|
require 'byebug/command'
module Byebug
#
# Show byebug settings.
#
class ShowCommand < Command
self.allow_in_control = true
def regexp
/^\s* show (?:\s+(?<setting>\w+))? \s*$/x
end
def execute
key = @match[:setting]
return puts(help) unless key
setting = Setting.find(... |
class Team
attr_reader :team_name, :players, :points
attr_accessor :coach
def initialize(team_name, players, coach)
@team_name = team_name
@players = players
@coach = coach
@points = 0
end
def new_player(name)
@players << name
end
def update_points(result)
@points += 3 if result... |
ENV['MONGOID_ENV'] = 'test'
if Mongoid::Compatibility::Version.mongoid2?
Mongoid.load! 'spec/config/mongoid2.yml'
elsif Mongoid::Compatibility::Version.mongoid3?
Mongoid.load! 'spec/config/mongoid3.yml'
elsif Mongoid::Compatibility::Version.mongoid4?
Mongoid.load! 'spec/config/mongoid4.yml'
elsif Mongoid::Compat... |
require 'colorize'
module TodoApp
PRE_TODO = '[TODO] '.cyan
PRE_INFO = '[Info] '.cyan
PRE_SUCCESS = '[Info] '.green
PRE_ERROR = '[Ooops] '.red
class Log
def self.todo( text )
puts PRE_TODO << text
end
def self.info( text )
puts PRE_INFO << text
end
... |
class Settings < SitePrism::Page
set_url '/settings'
element :name_field, '#user_name'
element :submit_button, 'input.button'
def update_name(name)
name_field.set name
submit_button.click
end
end
|
# frozen_string_literal: true
require "spec_helper"
module Decidim
module Opinions
describe PublishCollaborativeDraft do
let(:component) { create(:opinion_component) }
let(:state) { :open }
let!(:collaborative_draft) { create(:collaborative_draft, component: component, state: state) }
le... |
# == Schema Information
# Schema version: 57
#
# Table name: assets
#
# id :integer(11) not null, primary key
# parent_id :integer(11)
# size :integer(11)
# width :integer(11)
# height :integer(11)
# attachable_id :integer(11)
# cont... |
# frozen_string_literal: true
class ChangeLoginToUsers < ActiveRecord::Migration[6.0]
def up
change_column :users, :login, :string, null: false, default: '', limit: 100
end
def down
change_column :users, :login, :string, null: false, limit: 100
end
end
|
require "test_helper"
describe CategoriesController do
let(:category) {categories(:africa)}
describe "all users" do
describe "index" do
it "suceeds when there are categories" do
get categories_path
must_respond_with :success
end
it "suceeds when there are no categories" do
... |
class UserSerializer < ActiveModel::Serializer
attributes :id, :username, :favorites
# has_many :favorites, each_serializer: FavoriteSerializer
def favorites
ActiveModel::SerializableResource.new(object.favorites, each_serializer: FavoriteSerializer)
end
end
|
require "spec_helper"
describe User do
it "gets the params properly" do
vinoth = User.create!(name: "Vinoth", email: "visitvinoth@gmail.com")
expect(vinoth.name).to eq('Vinoth')
end
it "should require a username" do
User.new(name: "", email: "sam@ram.com" ).should_not be_valid
User.new(name: "b... |
# == Schema Information
#
# Table name: corpus_word_grammars
#
# id :bigint not null, primary key
# position :integer
# text :string
# type :string
# created_at :datetime not null
# updated_at :datetime not null
# word_id :bigint
#
# Indexes
#
# index_corpus_wo... |
class CreateCorrentista < ActiveRecord::Migration
def change
create_table "correntista" do |t|
t.string "cpf", limit: 11
t.string "nome", limit: 50
t.date "datanascimento"
t.string "endereco", limit: 255
t.integer "numero"
t.string "bairr... |
class Student < User
after_create :create_membership, :deliver_activation_instructions!
before_validation(:on => :create) do
self.active = false
self.role_code = User::ROLES[:student]
self.require_agreement_acceptance!
end
def create_membership
group = Group.find_by_code(group_code)
gr... |
module Issues
class QueryBatchIssues
prepend SimpleCommand
attr_reader :batch_id, :filter_status
def initialize(batch_id, filter_status = %w(open resolved))
@batch_id = batch_id
@filter_status = filter_status
end
def call
Issues::Issue.where(cultivation_batch_id: batch_id, is_... |
class TasksController < ApplicationController
before_action :authenticate_user!, except: [:index] # removed :show 4 accept_task options
before_action :set_task, only: [:show, :edit, :update, :destroy] # Task (params[:id])
before_action :current_user_is_task_user_id, only: [:edit, :update, :destroy] # restrict non... |
require 'spec_helper'
describe API::TasksController, :type => :api do
before(:each) do
@user1 = create(:user, email: "userNew@user.com")
@user2 = create(:user)
@secret = "secret"
create(:task, user: @user2)
end
it "displays incorrect token" do
get '/api/tasks'
expect(response.body).to include('Incorre... |
require_relative "car"
class Race
def initialize
@car1 = Car.new
@car1.speed += rand(10)
@car2= Car.new
@car2.speed += rand(10)
end
def cars
[@car1, @car2]
end
def winner
@car1.speed > @car2.speed ? @car1 : @car2
end
def loser
@car2.speed > @car1.speed ? @car1 : @car2
end
end
|
class RemoveDeparmentFromSupportRequests < ActiveRecord::Migration
def change
remove_column :support_requests, :deparment, :string
end
end
|
class RootController < ApplicationController
require 'barby'
require 'barby/barcode/ean_13'
require 'barby/barcode/code_39'
# require 'barby/outputter/png_outputter'
require 'barby/outputter/svg_outputter'
helper_method :qr_code_image64
def index
end
def qr_code
respond_to do |... |
require "./lib/Lesson 10 Prime And Composite Numbers/MinPerimeterRectangle/min_perimeter_rectangle"
describe 'MinPerimeterRectangle' do
describe 'Example Tests' do
it 'Example: 30 to 22' do
expect(min_perimeter_rectangle(30)).to eq 22
end
end
describe 'Correctness Tests' do
context 'Extreme_m... |
class DocumentIdentity < ActiveRecord::Base
belongs_to :document, touch: true
belongs_to :identity
belongs_to :identity_type
end
|
java_import "android.content.pm.ActivityInfo"
#ruby script that handles the behavior of the launcher
class Main < Activity
portrait_mode_only
no_action_bar
def on_create
if _P.has_key?(:app_url)
V('#app_url').text= _P.get(:app_url)
end
@start_console_btn = V('#start_conso... |
module Task
class Base < Core
include Persistable
include RelationMethods
has_relation :composition, supers: :projects, subs: :subtasks
has_relation :dependency, supers: :blocking, subs: :dependent
include Attributes::EditableMethods
has_editable_attribute :state, revision_class: Attrib... |
#!/usr/local/bin/ruby
require 'pp'
require_relative 'generators/gen_neato_topology.rb'
require_relative 'generators/gen_dot_topology.rb'
require_relative 'generators/gen_switch_graph.rb'
require_relative 'rlib/switch.rb'
require_relative 'rlib/configuration.rb'
require_relative 'rlib/upload.rb'
#Debugging check to see... |
require 'rails_helper'
RSpec.describe 'Delete Discount' do
before :each do
@merchant = create(:merchant)
@discount_1 = @merchant.bulk_discounts.create(name: '50% Discount', percentage: 50, quantity: 75)
@discount_2 = @merchant.bulk_discounts.create(name: '25% Discount', percentage: 25, quantity: 40)
... |
Given(/^You are in the Underwriting page$/) do
visit AutomationHomePage
on(LoginPage).login_yml
on(LandingPage).menus.when_present(10).click
sleep(1)
on(LandingPage).underwriting.when_present(10).click
end
And (/^I see Underwriter$/) do
sleep(5)
expect(on(UnderwritingPage).underwriter.present?).to be_tru... |
module Tolaria
# Tolaria’s configuration is a class so that an exception is raised
# if you try to configure a key that doesn't exist.
# Refer to the comments in the initializer that Tolaria generated for
# you when you ran `rails generate tolaria:install`.
class Configuration
# The cost factor for bcryp... |
class Picture < ActiveRecord::Base
attr_accessible :artist, :title, :url, :category
belongs_to :user
has_many :comments
has_many :users, :through => :comments
validates :artist, :title, :presence => :true
end
|
PivotalPlanningPoker::Application.routes.draw do
root :to => 'home#index'
resources :user_sessions, :only => [:create, :new, :destroy]
resources :projects, :only => [:index, :show] do
resources :stories, :only => [ :show, :update ] do
resources :estimates, :only => [ :create, :index ] do
put :... |
# Encoding: UTF-8
class Player < Chingu::GameObject
attr_reader :score, :x, :y, :direction
# traits :collision_detection, :bounding_box
def get_coordinates
@prev_x = @x
@prev_y = @y
end
def go_left
@vel_x -= 1
@x -= 5
@direction = -1
collision_x
end
def go_right
@vel_x += 1... |
Rails.application.routes.draw do
resources :schools
resources :courses
resources :users
resources :course_users
root 'static_pages#home'
get '/home', to: 'static_pages#home'
get '/help', to: 'static_pages#help'
get '/about', to: 'static_pages#about'
get '/contact', to: 'static_pages#contact'
get ... |
FactoryBot.define do
factory :purchase_address do
postal_code { '111-2222' }
house_number { '青山1-1-1' }
city { '横浜市緑区' }
building { '柳ビル' }
tel { '09012345678' }
state_id { 2 }
token { 'tok_abcdefghijk0000000... |
namespace :migrate do
desc 'Make all users plebs'
task admins: :environment do
users = User.all
ActiveRecord::Base.transaction do
puts "Updating #{users.size} users..."
users.each do |user|
user.update_attribute(:admin, false)
end
end
puts "Done."
end
end
|
require 'securerandom'
class Card < ApplicationRecord
before_create :set_auth_token
belongs_to :user
has_many :subscriptions
validates_presence_of :number
validates_length_of :number, is: 13, message: 'Le numéro d\'une carte est de 13 caractères'
def set_auth_token
return if auth_token.present?
... |
# Question Parameters:
# http://coursera.cs.princeton.edu/algs4/assignments/percolation.html
# Percolation. Given a composite systems comprised of randomly distributed
# insulating and metallic materials: what fraction of the materials need to
# be metallic so that the composite system is an electrical conductor? Give... |
class PostGrid
include Datagrid
scope do
Post.getList
end
filter(:id, :string)
filter(:user_id, :string)
filter(:title, :string){ |value| where("title ILIKE ?", "%#{value}%") }
filter(:author, :string) do |value|
self.joins(:user).where("users.name ILIKE '%#{value}%'")
end
end
|
#
# Fluentd
#
# 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, so... |
class RenameMission < ActiveRecord::Migration
def change
rename_column :missions, :strucure, :structure
end
end
|
class ContactsController < ApplicationController
before_filter :login_required, :only => :index
def new; end
def create
@contact = Contact.create params[:contact]
ContactsMailer.deliver_signup @contact
# ContactsMailer.deliver_notify_admin @contact
flash[:notice] = 'Thank you for signing up!'
... |
require 'pry'
class Doctor
=begin
Variables
name : String.new
appointments : Array.new
patients : Array.new
Functions
add_appointment( appt_object )
* add appointment to list
* appointment belongs to this doctor
* add patient to list of patients via appointments
=end
attr_accesso... |
require_relative 'abstract/standardised_search'
require_relative '../../../_cucumber/lib/helpers/driver_helper'
# this is the page class that contains all elements and common methods related to the Search page.
class SearchPage < StandardisedSearch
element(:search_box) { |b| b.text_field(id: 'search_list_... |
module CommonIndexers
class Collection < Base
def generate
multi_merge(
model,
fields,
values(:description, :visibility, :keyword)
)
end
def fields
{
id: id,
title: { primary: title },
thumbnail_iiif_url: thumbnail_iiif_url,
collec... |
# frozen_string_literal: true
module Vedeu
module Output
module Compressors
# The empty compressor removes all empty cells.
#
# @api private
#
class Empty
# @param (see #initialize)
# @return (see #compress)
def self.with(content)
new(content).c... |
# typed: false
# frozen_string_literal: true
# This file was generated by GoReleaser. DO NOT EDIT.
class ExoscaleCli < Formula
desc "Manage easily your Exoscale infrastructure from the command-line."
homepage "https://exoscale.github.io/cli/"
version "1.72.1"
on_macos do
url "https://github.com/exoscale/c... |
require_relative('./input')
class SolarSystem
# Takes a list of planet definitions as inputs and creates the system from it.
def initialize(planets)
@system = {}
planets.each { |planet| add(planet)}
end
# Adds a planet, updating both the parent and child planets as necessary.
def add(designation)
... |
class Bears
attr_reader :name, :hunger
def initialize(name, hunger)
@name = name
@hunger = hunger
end
end
|
class Api::V1::NappyPottiesController < ApplicationController
def create
day = Day.find(params[:day_id])
nappy_potty = NappyPotty.create(day: day)
render json: {
id: day.id,
date: day.date,
start_time: day.start_t,
end_time: day.end_t,
... |
require 'rails_helper'
RSpec.describe "AuthenticationPages", type: :request do
subject { page }
describe "GET /authentication_pages" do
before { visit signin_path }
it { should have_selector('h1', text: 'Homework Helper Login') }
it { should have_title("Sign in") }
end
describe "signin" do
b... |
Rails.application.routes.draw do
# For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html
resources :customers, only: [:show, :create, :update]
resources :carts, only: [:show, :create, :update] do
member do
put 'update_line_item'
post 'create_line_item'
... |
describe Statement do
it 'instansiates on new' do
expect(Statement).to respond_to(:new)
end
describe '#statement_formatter' do
it 'provides format for users statement' do
account_statement = [{ date: '30/07/2020', credit: 20, debit: '', account_balance: 20 }]
expect { subject.statement_format... |
require 'active_record'
ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: 'db/bot.db')
class Player < ActiveRecord::Base
belongs_to :village
has_many :animals
def get_select_animal
self.animals.find_by(id: self.select_animal)
end
end |
class Post < ActiveRecord::Base
has_many :comments
belongs_to :category
belongs_to :user
def position
Post.where('rank <= ?', self.rank).count
end
end
|
require 'rails_helper'
RSpec.describe User, type: :model do
describe "validations" do
it { should validate_presence_of(:email) }
it { should validate_presence_of(:password_digest) }
it { should validate_presence_of(:email) }
it { should validate_length_of(:password). is_at_least(8). on(:create) }
e... |
require "helper"
require File.join 'adapters', 'acronym.com'
describe "Finding acronyms" do
it "returns a well-known one" do
result = AcronymDotCom.new.search :query => "API"
expected = "Application Programming Interface"
expect(result.any?{|it| it.title == expected}).to be(true), "Expected to find mea... |
class Api::V1::EstimatesController < ApplicationController
before_action :set_customer, only: [:index, :create]
before_action :set_estimate, only: [:show, :update, :destroy]
def index
render json: @customer.estimates
end
def show
render json: @estimate
end
def create
estimate = @customer.estimat... |
module PublicDocumentRoutesHelper
include ActionDispatch::Routing::UrlFor
def public_host
if defined?(request) && request
Whitehall.public_host_for(request.host)
else
Whitehall.public_host
end
end
def document_path(edition, options = {})
defaults = { id: edition.document }
defa... |
#Ugly numbers are numbers whose only prime factors are 2, 3 or 5. The sequence
#1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 15, …
#shows the first 11 ugly numbers. By convention, 1 is included.
#Write a program to find and print the 150’th ugly number.
#DP approach
#because every number can only be divided by 2, 3, 5, one way to ... |
require 'rails_helper'
describe Career, type: :model do
it 'has a properly formatted title' do
career = create(:career)
expect(career.formatted_title).to eq "Software Developer"
end
end
|
require 'active_support/core_ext'
require 'curtain/version'
require 'curtain/templating'
require 'curtain/rendering'
require 'curtain/variable_support'
require 'curtain/output_buffer'
require 'curtain/html_helpers'
require 'curtain/form_helpers'
require 'curtain/form_builder'
require 'curtain/caching'
module Curtain
... |
require 'test_helper'
class ClipsControllerTest < ActionDispatch::IntegrationTest
setup do
@clip = clips(:one)
end
test "should get index" do
get clips_url
assert_response :success
end
test "should get new" do
get new_clip_url
assert_response :success
end
test "should create clip" ... |
class CreateQuestions < ActiveRecord::Migration[5.0]
def change
create_table :questions do |t|
t.string :question_text, null: false
t.string :answers, array: true, default: []
t.timestamps
end
add_index(:questions, :question_text, unique: true)
end
end
|
# frozen_string_literal: true
RSpec.describe ActiveEncryption::EncryptionSetting::YamlStore do
before do
allow(File).to receive(:read).with(file_path)
.and_return(content)
end
let(:file_path) { '/path/file.yml' }
let(:id) { :default }
let(:content) do
'default:
... |
require 'rails_helper'
feature "User visits profile page" do
let!(:users) { FactoryGirl.create_list(:user, 2) }
before { login_as(users[0], scope: :user) }
context "As a user" do
scenario "I can click on the My Profile link to view my profile." do
visit user_path(users[0])
expect(page).to have_l... |
class CreateBlockedMerchants < ActiveRecord::Migration
def change
create_table 'charities_merchants', :id => false do |t|
t.integer :charity_id, :null => false
t.integer :merchant_id, :null => false
end
add_index :charities_merchants, ["charity_id", "merchant_id"], :name => "fk_charity_merchan... |
class Dealership < ActiveRecord::Base
has_many :dealership_contacts
has_many :cars
has_many :dealership_messages
end |
class CreateReports < ActiveRecord::Migration
def change
create_table :reports do |t|
t.text :title
t.references :conference, index: true, null: false
t.string :creator_login
t.text :creator_data
t.timestamps
end
reversible do |dir|
dir.up do
'ALTER TABLE reports A... |
require File.dirname(__FILE__) + '/spec_helper'
require 'ostruct'
describe "rails_warden controller mixin" do
before(:each) do
@app = lambda{|e| [200, {"Content-Type" => "text/plain"}, ["resonse"]]}
class FooFailure
end
class User
end
class MockController
include RailsWar... |
class Eventt < ActiveRecord::Base
has_many :invitations
has_many :events,through: :invitations
end
|
# frozen_string_literal: true
# Loads the log into memory
def load_log(filename)
logs = []
File.open(filename, 'r') do |file_handle|
file_handle.each do |line|
logs.push(line.split(','))
end
end
logs
end
# Gets the attributes (columns) of the log
def get_attributes(logs)
logs[0][-1].delete!... |
class Subject < ActiveRecord::Base
belongs_to :user
has_many :memories
validates :user_id, presence: true
validates :group_tag, presence: true
validates :name, presence: true
validates :email, presence:true, format: { with: /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i }
before_save do
used_numbers =... |
#!/usr/bin/env ruby
#
#
# Copyright 2013 Cerner Corporation.
#
# 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... |
class ChangeColumnUser < ActiveRecord::Migration
def change
change_column_null :users, :provider, true
change_column_null :users, :uid, true
change_column_null :users, :nickname, true
change_column_null :users, :image_url, true
end
end
|
module Tolaria
# Wraps an ActiveRecord::Base descendant and stores information that Tolaria needs to track about it
class ManagedClass
# The ActiveRecord::Base model we’re managing
attr_accessor :klass
# The navigation category and order to use for this resource
attr_accessor :category
# Ite... |
class ApplicationController < ActionController::Base
# Add theme folder to view path
self.view_paths.unshift(*Rails.root.join('app', 'views', PPRN_THEME_NAME))
def forem_user
current_user
end
helper_method :forem_user
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.