text stringlengths 10 2.61M |
|---|
class RegistrationsController < Devise::RegistrationsController
def create
build_resource
if resource.save
if resource.active_for_authentication?
set_flash_message :notice, :signed_up if is_navigational_format?
sign_in(resource_name, resource)
respond_with resource, :location => after_sign_up_pa... |
require 'active_model'
class BaaniCreate
include ActiveModel::FormObject
attr_reader :baani
validates :baani, nested: true
before_validation :create_baani
strong_parameters baani: [:name, :slug, :version]
private
def create_baani
@baani = Baani.new(baani_params)
end
def persist!
baani.... |
require File.join(File.expand_path('../../', __FILE__), 'test_helper.rb')
class SessionsControllerTest < Test::Unit::TestCase
context "A user session" do
setup do
DatabaseCleaner.clean
Factory.create(:user)
@user = User.first
end
should "successfully login and logout" do
login @u... |
# frozen_string_literal:true
require 'webmock/rspec'
require_relative '../app/services/recruiterbox'
require 'spec_helper'
RSpec.configure do |config|
config.before(:each) do
stub_request(
:get, 'https://api.recruiterbox.com/v2/openings?tags=Tiene%20Examen'
).with(headers: { 'Accept' => '*/*' }).to_re... |
require 'bundler/whatsup/version'
require 'bundler'
require 'bundler/whatsup/gemfile'
module Bundler
module Whatsup
class Command
Plugin::API.command('whatsup', self)
def exec(command, args)
puts "You have next gems versions installed:\n"
gemfile = Bundler::Whatsup::Gemfile.new
... |
# Read about factories at https://github.com/thoughtbot/factory_girl
FactoryGirl.define do
factory :slog do
description "MyString"
poster "MyString"
departure_date "2014-12-30"
user nil
end
end
|
def element_count(arr)
hash = Hash.new(0)
arr.each { |ele| hash[ele] += 1 }
hash
end
def char_replace!(str, hash)
str.each_char.with_index { |char, i| str[i] = hash[char] if hash.has_key?(char) }
end
def product_inject(arr)
arr.inject(&:*)
end
|
class AddShopToShopRequest < ActiveRecord::Migration
def change
change_table :shop_requests do |t|
t.belongs_to :shop, index: true
end
end
end
|
require_relative '../automated_init'
context "Run" do
context "Abort On Error" do
context "Enabled" do
run = Run.build(abort_on_error: true)
error_policy = run.error_policy
test "Error policy is abort" do
assert(error_policy.instance_of?(Fixture::ErrorPolicy::Abort))
end
... |
# notes: slicehost finds records by id - need to check if others do the same (for zones & records)
# linode uses IDs
#
# array won't work because ID will change when delete items
# hash - but need to generate a unique number - counter
class DnsManager
def initialize
@zones = {}
@zone_id_counter... |
#!/usr/bin/env ruby
require 'date'
def read_file(file, type)
names_hash = {}
f = File.open(file, type)
f.readlines.each do |row|
names_hash[row.to_s.split(' ')[1]] = row.to_s.split(' ')[0]
end
f.close
names_hash
end
def current_year_date
date = Time.new
[date.strftime('%Y'), date.strftime('%Y.%m.%... |
ActiveAdmin.register Article do
permit_params :title, :text, :admin_user_id
end
|
class TrackedObject
def initialize(window, x, y)
@window, @x, @y = window, x, y
end
def draw
image.draw(@x, @y, 0)
end
def update
end
private
def image
@image ||= begin
height = 200
width = 300
stroke_width = 6
rimg = Magick::Image.new(width, height) { self.backg... |
class CreateProject < Mutations::Command
required do
model :user
hash :project do
string :name
optional do
boolean :public, :default => false
boolean :grant_invites, :default => false
string :thumbnail_content
end
end
end
def execute
p = {name: project["... |
class Employee
attr_reader :name #:salary
@@all = []
def self.all
@@all
end
def initialize(name) #salary)
@name = name
#@salary = salary
@@all << self
end
def new_account(account_name)
account = Accounts.find_or_create(account_name)
EmpAcc.new(self, account)
account
end
def accounts
emp_acc = E... |
class SchedulesController < ApplicationController
before_action :authenticate_teacher!
before_action :set_schedule, only: [:show, :edit, :update, :destroy]
# GET /schedules
# GET /schedules.json
def index
@events = Schedule.events(
month: Time.now.year,
year: Time.now.month,
curre... |
class AddLogToTrait < ActiveRecord::Migration[4.2]
def change
add_column :traits, :log_data, :boolean
end
end
|
# Exercise 4
#
# Define a method that accepts a string as an argument and returns false if the word is less than 8 characters long (or true otherwise).
def word(input_word)
if input_word.length < 8
return "false"
else
return"true"
end
end
puts "give me a word"
input =gets.chomp
puts word(input)
|
class Api::V1::UsersController < ApplicationController
def create
user = User.new(user_params.merge(api_key: SecureRandom.hex(13)))
# creates user adding api key, which is radomized with ^
if user.save
render json: UserSerializer.new(user), status: 201
else
render json: error_message(user)... |
#!/usr/bin/ruby
# encoding: utf-8
require 'minitest/autorun'
require './base'
require 'dyned'
class TestDyned < Minitest::Test
def test_compile_single_schema
xml = <<EOF
<schema name="root" >
<attribute name="id" type="int32" />
<attribute name="num" type="uint32" />
</schem... |
# Read about factories at http://github.com/thoughtbot/factory_girl
FactoryGirl.define do
factory :todouser do
sequence(:email) {"Person#{n}@example.com"}
password "foobar"
password_confirmation "foobar"
end
end
|
class ObserverMailerPreview < ActionMailer::Preview
include MailerPreviewHelpers
def observer_added_notification
ObserverMailer.observer_added_notification(observation, reason)
end
def observer_removed_notification
ObserverMailer.observer_removed_notification(proposal, user)
end
def proposal_comp... |
class AddImportTypeToOjsImports < ActiveRecord::Migration
def change
add_column :ojs_imports, :import_type, :string
end
end
|
require 'rails_helper'
RSpec.describe Document, type: :model do
it { should have_many(:reviews).dependent(:destroy)}
it { should validate_presence_of(:title) }
it { should validate_presence_of(:content) }
it { should validate_presence_of(:created_by) }
end
|
control "M-5.15" do
title "5.15 Ensure the host's process namespace is not shared (Scored)"
desc "
Process ID (PID) namespaces isolate the process ID number space, meaning
that processes
in different PID namespaces can have the same PID. This is process level
isolation between
containers and the host.
... |
class Api::SpacesController < ApplicationController
def index
@spaces = Space.all
render json: { spaces: @spaces.map { |space| SpacePresenter.new(space) } }
end
end
|
require './lib/tic_tac_toe'
RSpec.describe TicTacToe do
context "That the pay_again? returns true or false" do
xit "it returns false if try again equals No" do
game = TicTacToe.new
expect(game.play_again?).to eql(false)
end
xit "returns false if try again equals Yes" do
game = TicTacTo... |
class AddStartDateAndEndDateToBirthdayParty < ActiveRecord::Migration
def change
rename_column :birthday_parties, :date, :start_date
add_column :birthday_parties, :end_date, :date, null: false, index: true, default: (Date.today + BirthdayParty::PARTY_VALID_FOR)
end
end
|
# -*- encoding : utf-8 -*-
class User < ActiveRecord::Base
authenticates_with_sorcery!
ROLES=%w(Пользователь Лаборант Преподаватель Модератор Администратор)
STATUSES=["Не утвержден", "Утвержден", "Удален"]
validates :name, :presence => true
validates :surname, :presence => true
validates :role, :presence =... |
# #Title: Guess The Number
#
# ###Activity:
# - You are to generate a basic "guess my number" game. The computer will pick a random number between 0 and 10. The user will guess the number until they guess correctly.
#
# ###Specification:
# - The user should be asked to guess a number
# - If the user's guess is correc... |
class UserDependentProductsController < ApplicationController
before_filter :require_user
def index
@user_dependent_products = UserDependentProduct.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @user_dependent_products }
end
end
def show
@user... |
class User < ApplicationRecord
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
validates_presence_of :name
def admin?
self.role... |
class UserInstitution < ActiveRecord::Base
belongs_to :user
belongs_to :institution
validates :institution_type, inclusion: { in: %w(school work),
message: "%{value} is not a valid user_institution type. Please select 'school' or 'work'." }, allow_blank: true
end
|
# frozen_string_literal: true
class Course::Survey::Answer < ActiveRecord::Base
belongs_to :response, inverse_of: :answers
belongs_to :question, inverse_of: :answers
has_many :options, class_name: Course::Survey::AnswerOption.name,
inverse_of: :answer, dependent: :destroy
accepts_nested_at... |
class User < ApplicationRecord
# has_many :tasks
has_many :owned_tasks, class_name: "Task", foreign_key: "owner_id"
has_many :assigned_tasks, class_name: "Task", foreign_key: "assignee_id"
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
dev... |
class RemoveEquippedFromItems < ActiveRecord::Migration[6.0]
def change
remove_column :items, :equipped, :boolean
end
end
|
require_relative "../test_helper"
class ItemQuantityCanBeUpdatedFromOrderTest < Capybara::Rails::TestCase
test "an item's quantity being changed another number causes the quantity to be updated" do
restaurant = FactoryGirl.create(:restaurant)
restaurant.items.create(title: "Beans", price: 5, description: "B... |
# typed: true
# frozen_string_literal: true
require 'test_helper'
module Ffprober
module Parsers
class FileParserTest < Minitest::Test
class FakeExec
def initialize
@json_output = nil
end
def json_output(_file_to_parse)
@json_output || '{}'
end
en... |
class UserDecorator < Choshi::Decorator
auto_decorate :books
def name
"#{first_name} #{last_name}".strip
end
def full_name
helper.user_name(self)
end
end
|
class MusicLibraryController
attr_accessor :path
def initialize(path="./db/mp3s")
@path = path
music = MusicImporter.new(path)
music.import
end
def call
input = ""
while input != "exit"
puts "What do you want to do?"
input = gets.chomp
case input
when "list songs"
... |
# String --> [String] --> String
# take input of word/phrase
# downcase
# split word into array of letters, ignore spaces
# to_sym
# map array of letters with appropriate phonetic word
# create hash of phonetics
def to_phonetic(phrase) {
:a => "alpha",
:b => "bravo",
:c => "charlie",
:d => "delta",
:e => "... |
#
# Author:: Matt Eldridge (<matt.eldridge@us.ibm.com>)
# © Copyright IBM Corporation 2014.
#
# LICENSE: MIT (http://opensource.org/licenses/MIT)
#
module Fog
module Network
class Softlayer
class Mock
def get_datacenter_routers(id)
response = Excon::Response.new
response.statu... |
class DropJoinTable < ActiveRecord::Migration[6.1]
def change
drop_join_table :users, :books
end
end
|
class CreateNotes < ActiveRecord::Migration
def change
create_table :notes do |t|
t.text :note_detail
t.integer :floor, default: 0
t.integer :zone_id, default: 0
t.references :topic, index: true, foreign_key: true
t.references :user, index: true, foreign_key: true
t.timestamps ... |
class MapIconUploader < BaseImageUploader
def store_dir
'images/map-icons'
end
def default_url
ActionController::Base.helpers.asset_path([version_name, 'gray-icon.png'].compact.join('_'))
end
version :thumb do
process resize_to_fit: [30, 40]
end
end
|
# Implement your object-oriented solution here!
class Prime
def initialize(value)
@value = value
end
def number
arr = []
counter = 2
until arr.size == @value
arr << counter if is_prime?(counter)
counter += 1
end
arr[-1]
end
def is_prime?(value)
(2..(value-1)).to_a.ea... |
class BeersController < ApplicationController
before_action :logged_in_user, only: [:create, :edit, :update, :new]
before_action :admin_user, only: :destroy
def index
@beers = Beer.paginate(page: params[:page], :per_page => 10)
end
def show
@beer = Beer.find(params[:id])
@reviews = @beer.re... |
require 'spec_helper'
describe SessionsHelper do
let(:user) { create(:user) }
describe "#current_user" do
it "stores a user if signed_in?" do
session[:user_id] = user.id
expect(current_user).to eq user
end
it "returns nil if not signed_in?" do
expect(current_user).to be_nil
end... |
# frozen_string_literal: true
Sequel.migration do
change do
create_table(:title_basics) do
String :tconst, size: 16, null: false, primary_key: true
String :titleType, null: false
String :primaryTitle, null: true
String :originalTitle, null: true
Integer :startYear, null: false
... |
module Projects
module Interactors
class CheckStatus
include Interactor
# context:
# project
attr_reader :service
before do
context.fail!(error: 'missing project') unless context.project
context.fail!(error: 'project is not processing') unless context.project.proce... |
[PHYSICAL_FRONT, READ_AND_REACT, BLANKET_COVERAGE, TOUGHNESS].each do |chemistry|
jason_taylor = PlayerCard.create do |card|
card.first_name = 'Jason'
card.last_name = 'Taylor'
card.overall = 97
card.team_chemistry_id = Chemistry.by_team_city(:miami).fi... |
require 'spec_helper'
module RCI
RSpec.describe Instrumentation do
let(:redis) { Redis.new }
before do
RCI.attach_instrumentation_to(redis)
end
describe '#call(command, &block)' do
it 'must emit an ActiveSupport::Notification event with the name ending in "redis"' do
event_recei... |
class AddColumnVimeoToMember < ActiveRecord::Migration
def change
add_column :members, :vimeo, :text
end
end
|
class InstanceDisplay
def self.display_collection_for_role(role, instances)
headers = instances.first.display.headers
service_title = instances.first.service.to_s.downcase
info "\n\n**** " + role.upcase + " * #{service_title} ****************"
# separate by zone
previous_zone = instances.zones.fi... |
# == Schema Information
#
# Table name: proposals_assets
#
# created_at :datetime not null
# id :integer not null, primary key
# asset_id :integer
# proposal_id :integer
# updated_at :datetime not null
#
class ProposalAsset < ApplicationRecord
### Model Config ###
self.tab... |
# frozen_string_literal: true
class Subscriber < ApplicationRecord
has_many :votes, dependent: :destroy
scope :active, -> { where(active: true) }
scope :inactive, -> { where(active: false) }
validates :email, presence: true, uniqueness: { case_sensitive: false }, format: { with: URI::MailTo::EMAIL_REGEXP }
... |
require 'rails_helper'
feature "Apply for an exam successfully" do
scenario "when there is not previous qualification history" do
create_college_and_examination
sign_in_as_student
first_exam = all('.examinations').first
within first_exam do click_link "apply" end
click_on "Add qualification"
... |
class Accessor
attr_accessor :version
def initialize
@version = 0
end
include ObjectHistory
track_history_of :version=
end
|
class AccountsController < ApplicationController
before_action :find_account, only: [:show, :edit, :update, :destroy]
def index
@accounts= Account.all
end
def new
@account = Account.new
end
def show
end
def transfer
puts "******************"
if params[:account]
@sender = Account.find params... |
class EstimatedTime < ActiveRecord::Base
unloadable
include EstimatedTimesHelper
belongs_to :user
belongs_to :project
belongs_to :issue
before_save :add_info
# before_destroy :validate_before_destroy
validates_presence_of :issue_id, :hours, :plan_on, :comments
validates_numericality_of :hours, allow... |
class MomentumCms::Admin::DocumentsController < MomentumCms::Admin::BaseController
before_action :load_moment_cms_document, only: [:edit, :update, :destroy]
before_action :build_moment_cms_document, only: [:new, :create]
def index
@momentum_cms_documents = @current_momentum_cms_site.documents.all
end
d... |
# frozen_string_literal: true
class QuestionnairesController < ApplicationController
skip_before_action :set_questionnaire, only: :index
def index
@questionnaires = Questionnaire.all
end
def show
redirect_to_first_step
end
def completed; end
end
|
require 'rails_helper'
describe "User can only view their own links" do
let!(:user_1) { create(:user) }
let!(:user_2) { create(:user) }
let!(:link_11) { create(:link, user: user_1) }
let!(:link_12) { create(:link, user: user_1) }
let!(:link_21) { create(:link, user: user_2) }
let!(:link_22) { create(:link,... |
class CreateProjectTaskReasons < ActiveRecord::Migration
def change
create_table :project_task_reasons do |t|
t.integer :project_task_id
t.text :date_reason
t.text :hour_reason
t.integer :created_by
t.timestamps null: false
end
end
end
|
require File.dirname(__FILE__) + '/../../spec_helper'
describe "/enlaces/index.html.erb" do
include EnlacesHelper
before(:each) do
enlace_98 = mock_model(Enlace)
enlace_98.should_receive(:titulo).and_return("MyString")
enlace_98.should_receive(:enlace).and_return("MyString")
enlace_98.should_rec... |
require File.expand_path('lib/presenters/directory', Rails.root)
require File.expand_path('lib/response/link', Rails.root)
module Private
class DirectoryController < AuthorizedController
def index_options
respond_to do |format|
format.json do
response.headers['Allow'] = 'GET,HEAD'
... |
class CreateItems < ActiveRecord::Migration[5.2]
def change
create_table :items do |t|
t.string :image_id, :null => false
t.string :name, :null => false
t.integer :artist_id, :null => false
t.integer :price, :null => false
t.string :release_date, :null => false
t.integer :label... |
require "rails_helper"
describe List do
it { should validate_presence_of(:name) }
it { should ensure_length_of(:name).is_at_most(50) }
end
|
module Validation
def self.included(base)
base.extend ClassMethods
base.include Valid
base.include Validator
end
module ClassMethods
attr_reader :validate_arr
def validate(name, type, *args)
@validate_arr = []
@validate_arr.push([name, type, args])
end
end
module Vali... |
class RedmineCmissAttachmentsStateController < ApplicationController
unloadable
menu_item :redmine_cmis_attachments
before_filter :find_project
def user_pref_save
RedmineCmisAttachmentsSettings::config_params.each do |param|
RedmineCmisAttachmentsSettings::set_project_param_value(@project, param, p... |
# encoding: utf-8
require File.expand_path('../../start', __FILE__)
describe "Ensure::Encoding, concerning guess_encoding" do
it "should guess the first encoding from the list in which the data is valid" do
[
['UTF-8', ['ASCII-8BIT', 'UTF-8'], Encoding::ASCII_8BIT],
['UTF-8', ['US-ASCII'... |
require 'net/http'
class Nlp::Interpret
JSON_HEADERS = {"Content-Type" => "application/json", "Accept" => "application/json"}
include ActiveModel::Model
include ActiveModel::Validations
include ActiveModel::Validations::Callbacks
attr_accessor :agents, :format, :sentence, :language, :spellchecking,
... |
require 'test_helper'
class CompanyContactsControllerTest < ActionController::TestCase
setup do
@company_contact = company_contacts(:one)
end
test "should get index" do
get :index
assert_response :success
assert_not_nil assigns(:company_contacts)
end
test "should get new" do
get :new
... |
class FontLiberation < Formula
version "2.1.1,4743886"
sha256 "8ee2c16fe0f055e60dd8375449aff72d25dd623b9cc6f24790ce9d2e91446fca"
url "https://github.com/liberationfonts/liberation-fonts/files/#{version.to_s.sub(/.*,/, "")}/liberation-fonts-ttf-#{version.to_s.sub(/,.*/, "")}.tar.gz"
desc "Liberation"
homepage ... |
class AddViewbyguestToTrails < ActiveRecord::Migration
def change
add_column :trails, :viewbyguest, :boolean
end
end
|
# frozen_string_literal: true
class Like < ApplicationRecord
validates :user, :topic, presence: true
belongs_to :user
belongs_to :topic
end
|
class CreateCountries < ActiveRecord::Migration
def change
create_table :countries do |t|
t.string :name
t.timestamps null: false
end
Country.create([
{ name: 'AFEGANISTÃO' },
{ name: 'ACROTÍRI E DECELIA' },
{ name: 'ÁFRICA DO SUL' },
{ name: 'ALBÂNIA' },
{ name: 'ALEMANHA' },
{ name: 'A... |
require 'sqlite3'
require_relative 'cure_muno.rb'
require_relative 'db.rb'
module CureMuno
module_function
# dumps all tweets made while precure is on air, plus some time before and after it
def dump_nitiasa
# ex. query => ["precure", "プリキュア", ...]
query = File.open(File.dirname(__FILE__) + "/../query/... |
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe Api::UrlsController, type: :controller do
describe 'GET #index' do
let!(:url) { create(:url) }
before do
allow(FetchUrls).to receive(:call).and_return(double(:result, urls: [url]))
get :index
end
it { expect(response).... |
class CreateMeasurements < ActiveRecord::Migration[5.2]
def change
create_table :measurements do |t|
t.integer :user_id
t.integer :upper_arm, default: 0
t.integer :chest, default: 0
t.integer :waist, default: 0
t.integer :hip, default: 0
t.integer :thigh, default: 0
t.int... |
class UserStocksController < ApplicationController
before_action :set_current_user_as_user_var, only: [:create, :destroy]
def create
@ticker = params[:ticker]
@user = current_user
# don't let user add stock if already has in portfolio
if user_does_not_track_stock? && current_user.under_stock_lim... |
require 'timeout'
require 'open-uri'
require 'watir-webdriver'
require 'nokogiri'
require 'byebug'
require 'google-search'
module Page
def self.url_has_job?(url)
# lowers the chance of getting any recruiting websites, like jobs2careers.com
host = URI(url).host
host_split = host.split(".")
if host_spl... |
# frozen_string_literal: true
module NPI
VERSION = '1.0.0'
end
|
# == Schema Information
#
# Table name: events
#
# id :integer not null, primary key
# eventable_id :integer
# eventable_type :string(255) default(""), not null
# event_type :string(255) default(""), not null
# message :string(255) default(""), not null
# data ... |
# quiz_q5.rb
# A.
def string_lengths(sentence)
strings = sentence.split
strings.map { |chars| chars.length }
end
p string_lengths("hello") # => [5] (Correct)
p string_lengths("How are you today?") # => [3, 3, 3, 6] (Correct, although included '?' as part of last word)
# B.
def string_length... |
module Shouter
class Guard
class << self
def call(guard)
return true unless guard
guard.call
end
end
end
end
|
class CreateInvoice < GraphQL::Schema::RelayClassicMutation
null true
argument :fee_in_cents, Integer, required: true
field :invoice, InvoiceType, null: true
field :errors, [String], null: true
def resolve(fee_in_cents:)
{
invoice: OpenStruct.new(
id: 1231,
fee_in_cents: fee_in_ce... |
# The MIT License (MIT)
# Copyright (c) 2019 Wolfgang Wohanka
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, mo... |
class CreateLineFragments < ActiveRecord::Migration[5.2]
def change
create_table :line_fragments do |t|
t.references :working_article, foreign_key: true
t.references :paragraph, foreign_key: true
t.integer :order
t.integer :column
t.string :line_type
t.float :x
t.float :y... |
class Game < ApplicationRecord
belongs_to :league, optional: true
belongs_to :assignor, optional: true
has_many :referees, through: :assignments
has_one :assignment
end
|
class AddDepartmentRefToProjects < ActiveRecord::Migration
def change
add_reference :projects, :department, index: true, foreign_key: true
end
end
|
require 'colored'
require 'logger'
class EventLogger
attr_accessor :enabled
#needs optionaly write to logfile
def initialize(thread_string)
@thread_string = thread_string.sub(' ', '_').downcase
@enabled = true
log_file_path = "./log/#{thread_string}.log"
@logger = Logger.new(log_file_path... |
require 'rails_helper'
RSpec.describe RequestType, type: :model do
allowed_types = %w[general enroll_payment financial_assistance proficiency deadline_extension qualification credits_transfer graduation_enrollment general_enrollment]
it "is seeded array matching expected types" do
found_types = []
a = Requ... |
# Teskal
class UserCustomField < CustomField
def type_name
:label_user_plural
end
end
|
# frozen_string_literal: true
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
gem 'activesupport', '~> 7.0'
gem 'assembly-image', '~> 2.0' # ruby-vips is used by 2.0.0 for improved image processing
gem 'assembly-objectfile', '~> 2.1'
gem 'config', '~> 2.2'
gem 'dor-servic... |
# -*- encoding : utf-8 -*-
class SystemMailer < ActionMailer::Base
default to: "info@stoffiplayer.com"
def contact(options)
reply_with_name = "#{options[:name]} <#{options[:from]}>"
from_with_name = "#{options[:name]} <noreply@stoffiplayer.com>"
@message = options[:message]
mail(from: from_with_name, reply_... |
require 'gsl'
class TermDocumentMatrix
attr_reader :matrix, :labels, :number_of_terms, :number_of_documents, :non_zeros
def initialize(corpus)
@matrix = GSL::Matrix.alloc(corpus.terms.size, corpus.document_count)
@non_zeros = 0
@number_of_terms = corpus.terms.size
@number_of_documents = corpus.doc... |
class Publish::SalesController < PublishController
belongs_to :publisher
actions :index, :show
def index
@retail_sales = current_publisher.retail_sales
@whole_sales = current_publisher.whole_sales
@get_stocks = current_publisher.get_stocks
@payments = current_publisher.payments
if par... |
require 'test_helper'
class CharactersControllerTest < ActionDispatch::IntegrationTest
include Devise::Test::IntegrationHelpers
test "should show a character" do
get character_url(characters(:one))
assert_response :success
end
test "should activate" do
commissioner = users(:commissioner)
sign... |
class User < ActiveRecord::Base
# create relationship to posts corresponding posts delete when user destroyed
has_many :posts, dependent: :destroy
# turns all email inputs to lowercase format for save
before_save { email.downcase! }
# prevents name larger than 20 characters and requires name
validates :name... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.