text stringlengths 10 2.61M |
|---|
class Post < ActiveRecord::Base
belongs_to :user
belongs_to :category
default_scope -> { order(created_at: :desc) }
mount_uploader :picture, PictureUploader
validates :user_id, presence: true
validates :category_id, presence: true
validates :content, presence: true, length: { maximum: 140 }
validates :c... |
# frozen_string_literal: true
class Retailer < ApplicationRecord
has_many :customers
has_many :products
has_many :payments
belongs_to :retailer_type
has_many_attached :avatars
end
|
class Book < ActiveRecord::Base
has_many :favorites
has_many :users, through: :favorites
validates :title, :author, :text, presence: true
def self.get_random
book_array = Book.find_by_sql "SELECT * FROM books ORDER BY RANDOM() LIMIT 1"
book = book_array[0]
book
end
def self.most_favorited
... |
module Foortran
class Token
attr_accessor :name, :value
def self.identifier(value)
token = new(:identifier, value)
token.to_ary
end
def self.keyword(name)
token = new(name, name)
token.to_ary
end
def self.string(value)
token = new(:string, value)
token.to... |
# source: https://github.com/ruby/ruby/blob/1997e10f6caeae49660ceb9342a01a4fd2efc788/test/ruby/test_syntax.rb#L1417
require_relative '../test_unit_to_mspec'
using TestUnitToMspec
eval <<~'RUBY', binding, __FILE__, __LINE__
using TestUnitToMspec
using RubyNext::Language::ClassEval
class TestSyntaxMethodDefEndless < ... |
class CourseSurveyEsRecord < ActiveRecord::Base
belongs_to :course_survey
# --- 模型关联
belongs_to :student,
:class_name => 'User',
:foreign_key => 'student_user_id'
validates :course_survey,
:student,
:attend_class,
:attend_class_reason,
... |
require 'fileutils'
require_relative 'release.rb'
require_relative 'build.rb'
require_relative 'deb.rb'
require_relative 'cmd/build_options.rb'
require_relative 'target_base.rb'
class Package < TargetBase
SRC_DIR_BASENAME = 'src'
DEF_BUILD_OPTIONS = { source_archive_without_top_dir: false,
... |
module MediaMetrics
extend ActiveSupport::Concern
METRICS = []
def get_metrics
METRICS.each { |name| self.send("get_metrics_from_#{name}") }
end
module ClassMethods
def declare_metrics(name)
METRICS << name
end
def notify_webhook_and_update_metrics_cache(url, name, value, key_id)
... |
class BidsController < ApplicationController
before_action :set_bid, only: [:show, :edit, :update, :destroy]
# GET /bids
# GET /bids.json
def index
@bids = Bid.all
end
# GET /bids/1
# GET /bids/1.json
def show
end
# GET /bids/new
def new
@bid = Bid.new
end
# GET /bids/1/edit
def ... |
class ApplicationController < ActionController::Base
helper_method :current_driver
private
def current_driver
@driver ||= Driver.find_by_id(session[:driver_id])
end
end
|
class UsersController < ApplicationController
before_action :authenticate_user!, only: [:update, :edit, :delete]
before_action :find_user, only: [:show, :update, :edit]
before_action :correct_user?, only: [:edit]
def index
@users = User.order('created_at DESC').paginate(page: params[:page], per_page: 30)
... |
class Company < ApplicationRecord
has_many :complaints, dependent: :destroy
validates :name, presence: true
end
|
module Xero
class Contact < ApplicationRecord
DEEP_LINK_URL = "https://go.xero.com/organisationlogin/default.aspx?" \
"shortcode=%<shortcode>s&" \
"redirecturl=%<target_url>s"
scope :active, -> { where status: 'ACTIVE' }
def self.upsert_api_response(results, *args, &block)
transaction ... |
# frozen_string_literal: true
module Jiji::Test
def self.same_position?(a, b)
values_a = extract_position_values_without_id(a)
values_b = extract_position_values_without_id(b)
values_a == values_b
end
def self.extract_position_values_without_id(p)
[
p.pair_name, p.units, p.sell_or_buy, p.s... |
class Van
DEFAULT_CAPACITY = 20
def initialize(bikes = [], options = {})
@capacity = options.fetch(:capacity, DEFAULT_CAPACITY)
@bikes = bikes
end
def bike_count
@bikes.count
end
def collect_broken_bike(station)
raise "Van is full." if full?
@bikes = station.release_bike_to_van
end
def r... |
class ApplicationController < ActionController::Base
protect_from_forgery
helper_method :ui_state_of
def ui_state_of(component)
current_user.ui_states.find_or_create_by_component(component)
end
def current_user
users = User.scoped
user_id = params[:user_id] || session[:user_id]
users = users... |
name 'transmission-debian'
maintainer 'Matt Ray'
maintainer_email 'matt@chef.io'
license 'Apache-2.0'
description 'Installs/configures the Transmission BitTorrent client on Debian'
long_description 'Installs/Configures Transmission on Debian'
version '0.6.0'
chef_version '>= 14'
supports 'debian'
issues_url 'https://... |
class Prediction < ActiveRecord::Base
def predict_by_coordinates(lat, long, period)
location = get_closest_locations(lat, long) #Modify method!, now its returning only one for testing purposes
#seguire trabajando con solo un location por el momento
data = location_data(location, period)
rain_model = find_mode... |
# Copyright (c) 2009-2011 VMware, Inc.
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), "..")
require "util"
require "redis_error"
module VCAP::Services::Redis::Snapshot
include VCAP::Services::Base::AsyncJob::Snapshot
def init_localdb(database_url)
DataMapper.setup(:default, database_url)
end
def i... |
require File.expand_path(File.join(File.dirname(__FILE__), 'helper'))
module Racc
class TestRaccCommand < TestCase
def test_empty_user_code_y
err = assert_compile 'empty_user_code.y'
assert_no_warnings err
end
def test_syntax_y
err = assert_compile 'syntax.y', '-v'
assert_no_warn... |
require 'stringio'
require 'test/unit'
require 'set'
if !defined? assert_contains_path
def assert_contains_path( set, relative_path )
absolute_path = File.expand_path( relative_path )
assert(set.include?(absolute_path), "Does not contain: " + relative_path)
end
end
if !defined? assert_does_not_contain_pat... |
class PaginatedArraySerializer < ActiveModel::ArraySerializer
def initialize(object, options = {})
options[:meta] ||= {}
options[:meta][:pagination] ||= {
total: object.total_count,
per_page: object.limit_value,
page: object.current_page
}
super(object, options)
end
end
|
# frozen_string_literal: true
module Tikkie
module Api
module V1
module Requests
# Users operations at Tikkie.
class Users
def initialize(request)
@request = request
end
def list(platform_token)
response = @request.get("/tikkie/platform... |
class Account < ActiveRecord::Base
attr_accessible :username, :password, :password_salt
attr_accessor :new_password
def hash_new_password
self.password_salt = SecureRandom.base64(9)
self.password = Digest::SHA2.hexdigest(self.password_salt + @new_password)
end
end
|
class LikesController < ApplicationController
before_action :ensure_logged_in
def create
@like = current_user.likes.new(like_params)
if @like.save
redirect_to user_url(like_params[:likee_id])
else
flash.now[:errors] = @like.errors.full_messages
end
end
def index
@likes = User.f... |
# Activate and configure extensions
# https://middlemanapp.com/advanced/configuration/#configuring-extensions
activate :directory_indexes
set :trailing_slash, false
set :lang, :cz
activate :i18n, :langs => [:cz, :en]
activate :autoprefixer do |prefix|
prefix.browsers = "last 2 versions"
end
# Layouts
# https://mid... |
class ChangeRatingInfoDatatypeToStringInSchools < ActiveRecord::Migration[5.2]
def change
change_column :schools, :rating_info, :string
end
end |
class PreferencesController < ApplicationController
before_action :ensure_logged_in
def update
@preference = Preference.find_by_user_id(params[:user_id])
if @preference.update(preference_params)
redirect_to user_url(@preference.user_id)
else
flash.now[:errors] = @preference.errors.full_mess... |
require 'google/apis/calendar_v3'
require 'googleauth'
require 'googleauth/stores/file_token_store'
require 'fileutils'
OOB_URI = 'urn:ietf:wg:oauth:2.0:oob'.freeze
APPLICATION_NAME = 'Google Calendar API'.freeze
CREDENTIALS_PATH = 'credentials.json'.freeze
TOKEN_PATH = 'token.yaml'.freeze
SCOPE = Google::Apis::Calend... |
require_relative '../../config'
class CreateCourses < ActiveRecord::Migration
def up
create_table :courses do |t|
t.belongs_to :student
t.belongs_to :teacher
t.timestamps
end
end
def down
drop_table :courses
end
end |
RSpec.describe Post, type: :model do
let(:post_1) { create :post }
subject { post_1 }
it { is_expected.to respond_to(:title) }
it { is_expected.to respond_to(:text) }
it { is_expected.to respond_to(:author) }
it { is_expected.to be_valid }
context 'when author is not present' do
before { post_1.au... |
json.array!(@success_stories) do |success_story|
json.extract! success_story, :id, :title, :cover_photo, :story, :author
json.url success_story_url(success_story, format: :json)
end
|
class OldExtraFieldValue
include Mongoid::Document
include Mongoid::Timestamps
store_in collection: 'extra_field_values'
belongs_to :extra_field, class_name: "OldExtraField"
belongs_to :contest
belongs_to :detail
field :value
field :original_filename
class << self
def get_value_from(contest_i... |
class ApplicationController < ActionController::API
def encode_token(user_id)
JWT.encode({user_id: user_id}, ENV["JWT_SECRET"])
end
def logged_in_user
User.find(decoded_token["user_id"])
end
private
def get_token
request.headers["Authorization"]
end
def dec... |
# Given an Array of tuples, where tuple[0] represents a package id,
# and tuple[1] represents its dependency, determine the order in which
# the packages should be installed. Only packages that have dependencies
# will be listed, but all packages from 1..max_id exist.
# N.B. this is how `npm` works.
# Import any file... |
require 'serialport'
class Scoreboard
def initialize
port = '/dev/cu.usbmodemfa1261'
@sp = SerialPort.open port, 38400
at_exit do
@sp.close
end
end
def show sym
str =
case sym
when :three then three
when :two then two
when :one then one
when :all then all_... |
class LoggerStub
[:debug, :error, :fatal, :info, :warn].each do |method|
class_eval <<-CODE
def #{method}(message); nil; end
CODE
end
end |
require 'csv'
MERCHANT_FILE = Rails.root.join('db', 'seed_data', 'merchant.csv')
PRODUCT_FILE = Rails.root.join('db', 'seed_data', 'product.csv')
ORDER_FILE = Rails.root.join('db', 'seed_data', 'order.csv')
ORDERITEM_FILE = Rails.root.join('db', 'seed_data', 'orderitem.csv')
CATEGORY_FILE = Rails.root.join('db', 'seed... |
require 'javaclass/adder_tree'
module JavaClass
module Analyse
# Transitive dependency analysis to be mixed into Dsl::LoadingClasspath. For an example see
# {how to get cumulative dependencies of a class}[link:/files/lib/generated/examples/cumulative_dependencies_txt.html].
# For plain dependenci... |
#!/usr/bin/env ruby
# in: URLs of article pages on stdin, one per line
# out: those articles, including subject, time, author, msgid, and body,
# as plain text, encoded in ISO latin1
require 'nokogiri'
class String
def to_text(indent, wordwrap)
lines = self.split("\n", -1)
lines = [""] if lines==[] # ... |
class UsersController < ApplicationController
before_action :set_user, only: [ :show, :destroy ]
def index
users = User.active
json_response(users)
end
def show
json_response(@user)
end
def create
user = User.create!(user_params)
json_response(user, :created)
end
def identi... |
# Filters added to this controller apply to all controllers in the application.
# Likewise, all the methods added will be available for all controllers.
class ApplicationController < ActionController::Base
include Authentication
include AdvancedFlash::ControllerSupport
helper :all, AdvancedFlash::Helper # ... |
class Question < ActiveRecord::Base
belongs_to :quiz
has_many :answers, dependent: :destroy
validates :order_by, :title, presence: true
default_scope {order('order_by DESC')}
def max_points
answers.ordered_by_points.limit(1).pluck(:points).first
end
end
|
class RemoveIndexvisitFromVisits < ActiveRecord::Migration
def change
remove_index :visits, name: 'index_visits_on_idVisit'
end
end
|
Vagrant.configure(2) do |config|
config.vm.box = "debian/jessie64"
config.vm.network "private_network", type: "dhcp"
config.vm.network "forwarded_port", guest: 80, host: 8080
# general provisioning script
config.vm.provision :shell,
:path => "ops/provisioning/base.sh"
config.ssh... |
class Product < ActiveRecord::Base
belongs_to :brand
has_many :review_templates
end
|
class FightAlgorithm
LUCK_COEFF = 200
MONSTER_DAMAGE = 1.75
EXPERIENCE_MUL = 2
EXPERIENCE_DIV = 0.4
INTELI_PRIO = 0.1
STREN_PRIO = 0.2
DEXTER_PRIO = 0.3
DEFENCE_COEFF = 0.0002
# This metod performs a fight of user against a monster
def initialize(player_id, monster_id)
@player = Player.find(... |
class C4 < DebianFormula
url 'git://git.verplant.org/collection4.git'
homepage 'http://octo.it/c4/'
arch 'all'
name 'collection4'
version '4.0.0+git20110827'
description 'web-based front-end for collectd'
build_depends 'libfcgi-dev', 'librrd-dev', 'yajl'
depends 'libfcgi0ldbl', 'yajl', 'spawn-fcgi'
... |
class DeleteColumnToFoodProduct < ActiveRecord::Migration[4.2]
def up
remove_column :food_products, :start, :string
end
def down
add_column :food_products, :start, :string
end
end
|
class AddAnimalIdToNotifications < ActiveRecord::Migration
def change
add_column :notifications, :animal_id, :integer
end
end
|
class AddColorsToFlair < ActiveRecord::Migration
def change
add_column :flairs, :background, :string
add_column :flairs, :foreground, :string
add_column :flairs, :user_id, :integer
end
end
|
class BusStop < ActiveRecord::Base
attr_accessible :on_street, :cross_street, :routes, :boardings, :alightings, :month_beginning, :daytype, :location
has_many :bus_stops_routes
has_many :routes, :through => :bus_stops_routes
def self.longest_route
end
end
|
class Message < ActiveRecord::Base
belongs_to :campaign
validates :text, presence: true, length: 10..300
end
|
require 'factory_girl'
FactoryGirl.define do
factory :user do
sequence(:username) { |n| "user_#{n}" }
agreed_to_terms_of_service true
factory :admin do
roles { [Role.where(name: 'admin').first_or_create] }
end
end
end
|
class MoveFieldsFromCourseToSections < ActiveRecord::Migration
def change
remove_column :courses, :enrollment
remove_column :courses, :capacity
remove_column :courses, :waitlist_capacity
remove_column :courses, :waitlist_count
remove_column :courses, :location
remove_column :courses, :class_nu... |
class CreateWooAcknowledgements < ActiveRecord::Migration[5.0]
def change
create_table :woo_acknowledgements do |t|
t.references :woo_order
t.bigint :barnhardt_order_number
t.string :barnhardt_status
t.text :barnhardt_errors
t.timestamps
end
end
end
|
module RunPal
class LogIn < UseCase
def run(inputs)
user = log_in(inputs[:auth])
return failure(:inputs_required) if user.nil?
success :user => user
end
def log_in(auth)
RunPal.db.from_omniauth(auth)
end
end
end
|
class IndexIssuesOnVolumeNumber < ActiveRecord::Migration
def up
add_index(:issues, :volume_number)
end
def down
remove_index(:issues, :column => :volume_number)
end
end
|
require 'webmock/rspec'
RSpec.describe SEPOMEX::Strategy do
zip_code = '97305'
let(:sepomex_zip_code_response) do
[
{
error: false,
code_error: 0,
error_message: 'null',
response: {
cp: zip_code,
asentamiento: 'Granjas Cholul',
tipo_asentamie... |
# Associations are used in order to specify relationships between model classes
# that reflect relations between tables in the database using foreign keys.
#
# Each kind of association adds a number of methods to the model class which
# are specialized according to the association type and optional parameters
# given i... |
# frozen_string_literal: true
ActiveAdmin.register Location::Connection::Step do
menu parent: 'Locations', label: 'Steps'
permit_params :content,
:elvanto_form_id,
:mail_chimp_user_id,
:mail_chimp_audience_id,
:location_id,
:step_id,
... |
xml.instruct!
xml.Response do
if @message[:error]
xml.Say "#{@message[:error]}", voice: 'alice'
url = hello_options_url(id: params[:id], 'Digits' => '3')
xml.Redirect url, method: 'post'
else
xml.Gather(:action => hello_confirm_path(id: params[:id], time: @chosen_time), :numDigits => 1) do
xml... |
class SendTextForm
include ActiveModel::Model
attr_accessor :number_to_send_to
validates_length_of :number_to_send_to, minimum: 10, message: 'At least 2 letters'
def persisted?
false
end
def send_text_message(current_user)
twilio_sid = ENV["TWILIO_SID"]
twilio_token = ENV["TWILIO_AUTH_TO... |
class PoemSerializer < ActiveModel::Serializer
attributes :id, :url, :likes_count
has_one :user
end
|
shared_examples 'perl_environment' do
describe 'plenv' do
describe file '/home/a-know/.plenv/.git' do
it { should be_directory }
it { should be_owned_by 'a-know' }
it { should be_grouped_into 'a-know' }
it { should be_mode 755 }
end
end
describe 'perl-build' do
describe file '... |
class DocumentGroup < ActiveRecord::Base
belongs_to :department
has_many :documents
validates_presence_of :name, :department_id
def display_name
"#{department.name} | #{name}"
end
end
|
class Order < ApplicationRecord
validates :shoe_id, :seller_id, :size, :sex, :price, :order_type, :active, :sold, presence: true
belongs_to :shoe
belongs_to :seller,
foreign_key: :seller_id,
primary_key: :id,
class_name: :User
end
|
class AddCompletedInitialAllocationColumn < ActiveRecord::Migration
def self.up
add_column :game_players, :completed_initial_allocation, :integer,:size => 1, :default => 0
end
def self.down
remove_column :game_players, :completed_initial_allocation
end
end
|
require 'spec_helper'
describe Mongoid::History::Trackable do
describe 'EmbeddedMethods' do
describe 'relation_class_of' do
before :each do
class ModelOne
include Mongoid::Document
include Mongoid::History::Trackable
if Mongoid::Compatibility::Version.mongoid7_or_newe... |
require 'will_paginate/array'
module CamaleonCms
module Admin
class MediaController < CamaleonCms::AdminController
skip_before_action :admin_logged_actions, except: %i[index download_private_file], raise: false
skip_before_action :verify_authenticity_token, only: :upload, raise: false
before_act... |
class GEOAddress
attr_reader :address, :longitude, :latitude
def initialize address, longitude, latitude
@address = address
@longitude = longitude
@latitude = latitude
end
def to_s
"address:#{@address}, longitude:#{@longitude}, latitude:#{@latitude}"
end
end
|
require 'spec_helper'
# All tests tagged as `ported` are ported from
# testunit tests and are there for backwards compatibility
MiniMagick.processor = :mogrify
describe MiniMagick::CommandBuilder do
before do
@processor = MiniMagick.processor
@processor_path = MiniMagick.processor_path
end
after do
... |
class LinkedListNode
attr_accessor :value, :next, :prev
def initialize(value)
@value = value
@next = nil
@prev = nil
end
def connect(node)
self.next = node
node.prev = self unless node.nil?
end
def remove
if @prev.nil?
@next.prev = nil
else
@prev.connect(@next)
... |
module OpenProject::Revisions
module Patches
module RepositoriesControllerPatch
def self.included(base)
base.class_eval do
unloadable
include InstanceMethods
alias_method_chain :edit, :revisions
alias_method_chain :destroy, :revisions
end
end... |
class TooHatedWellsFargo
attr_accessor :player
def initialize(player)
@player = player
puts "--- Wells Fargo Bank ---\n".colorize(:blue)
puts "Hello #{@player.name.capitalize} We are here to serve you (screw you) and make your money disapear (as always)".colorize(:yellow)
options
end
def optio... |
class UserTag < ActiveRecord::Base
validates_uniqueness_of :user_id, :scope => :tag_id
belongs_to :user
belongs_to :tag
end
|
class AddYcToPosts < ActiveRecord::Migration
def self.up
#发言是否原创
add_column :posts, :yc, :boolean
end
def self.down
remove_column :posts, :yc
end
end
|
require 'json'
require 'faraday'
require 'faraday_middleware'
require 'base64'
require 'openssl'
module ThoughtLeadr
# @private
module Connection
private
def connection(raw, url)
sig = "/v2/" + url
if debug
sig += "?debug=true"
end
auth = OpenSSL::HMAC.hexdigest('sha256', ... |
class FixedCostDatatable
delegate :current_user, :content_tag, :check_box_tag, :params, :link_to, :number_to_currency, to: :@view
delegate :url_helpers, to: 'Rails.application.routes'
delegate :session, to: :@view
include ApplicationHelper
def initialize(view)
@view = view
end
def as_json(options =... |
module CementHorses #:nodoc:
module TimeParseable #:nodoc:
def self.included(base)
base.extend ClassMethods
end
# +time_parseable+ adds attribute accessors for parsing time for specified
# column names or for every timestamp column (less +created_at+ and
# +updated_at+). Invalid parsing yie... |
class UsersController < ApplicationController
skip_before_action :verify_authenticity_token, only: [:create, :destroy]
def user_params
params.require(:user).permit(:name, :email, :user_id )
end
end |
describe "new" do
describe "library" do
before { visit new_library_path }
let(:submit) { "Save" }
describe "with invalid information" do
it "should not create a library" do
expect { click_button submit }.not_to change(Library, :count)
end
end
describe ... |
class AddSectionsToSapApplications < ActiveRecord::Migration
def change
add_column :sap_applications, :section_a_complete, :boolean
add_column :sap_applications, :section_b_complete, :boolean
add_column :sap_applications, :section_c_complete, :boolean
add_column :sap_applications, :section_d_complete,... |
class Client < ActiveRecord::Base
validates_formatting_of :zip_code, using: :us_zip
validates_formatting_of :phone_number, using: :us_phone
validates_formatting_of :email, using: :email
#vneed to validate the presence of other fields when a new client register
has_one :conversation
has_one :user, :through ... |
# == Schema Information
#
# Table name: trash_loggers
#
# id :integer not null, primary key
# describe_trash :text
# describe_location :text
# adjacent_waterway :text
# phone_id :string
# latitude :string
# longitude :string
# created_at :datetime ... |
# 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... |
#
# Sous-classe Thing::Items
#
# Les items de la Thing
#
class Thing
class Items
# -------------------------------------------------------------------
# Classe
# -------------------------------------------------------------------
# ------------------------------------------------------------... |
module Inky
module ComponentFactory
def component_factory(elem)
transform_method = :"_transform_#{component_lookup[elem.name]}"
return unless respond_to?(transform_method)
inner = elem.children.map(&:to_s).join
send(transform_method, elem, inner)
end
tags = %w[class id href size ... |
class User
# attr_accessor :username
attr_reader :username
attr_writer :username
@@all = []
def initialize(username)
@username = username
@@all << self
end
def post_tweet(message)
@tweet = Tweet.new(self, message)
end
def self.all
@@all
end
def tweets
Tweet.all.select do ... |
class Tribe < ActiveRecord::Base
has_many :users
def happenings
User.joins(:tribe).where(tribe: tribe)
end
end
|
class UserSession < ActiveRecord::Base
belongs_to :user
before_create { generate_token }
def self.active
accessed_at_field = UserSession.arel_table[:accessed_at]
where(accessed_at_field.gteq(2.weeks.ago)).where(revoked_at: nil)
end
def self.authenticate(token)
active.where(token: token).first i... |
class AuditProblem::MissingIssue < AuditProblem::Base
field :publication_date, :type => Date
field :mods_available_locally, :type => Boolean
field :bulkdata_available, :type => Boolean
def self.run(options = {})
problems = []
(Date.parse('1994-01-01')..Date.current).each do |date|
if Issue.should... |
#!/usr/bin/env ruby
# :title: PlanR::Query
=begin rdoc
Object representing an index Query.
(c) Copyright 2016 Thoughtgang <http://www.thoughtgang.org>
=end
# WARNING: this code is under active development and highly subject to change
require 'plan-r/util/json'
# TODO: Generic Stats object to be returned by :index p... |
class CreateArms < ActiveRecord::Migration
def change
create_table :arms do |t|
t.integer :sparc_id
t.references :protocol
t.string :name
t.integer :visit_count
t.integer :subject_count
t.timestamps
end
end
end
|
# frozen_string_literal: true
require "yaml"
require "adapter/imap"
require "mover/folder"
module Mover
class Box
attr_reader :config, :conn_from, :conn_to
def initialize(debugger: false)
@debugger = debugger
@config = YAML.load_file(File.expand_path("../config.yml", __dir__))
@conn_from ... |
require 'csv'
require_relative 'invoice'
require_relative 'csv_loader'
require_relative 'search'
class InvoiceRepository
include CsvLoader
include Search
attr_reader :invoices
def initialize(csv_file_path, engine)
@invoices = create_items(csv_file_path, engine)
@engine = engine
return self
end... |
require 'rails/generators'
require 'rails/generators/active_record'
class ArRolloutGenerator < Rails::Generators::Base
include Rails::Generators::Migration
extend ActiveRecord::Generators::Migration
source_root File.expand_path("../templates", __FILE__)
desc "This generator creates the initializer file at co... |
class SessionsController < ApplicationController
def home
end
def new
@user = User.new
redirect_to welcome_path, alert: "Please log out first!" if logged_in?
end
def create
user = User.find_by(name: params[:user][:name]).try(:authenticate, params[:user][:password])
return redirect_to log... |
meta :nginx do
accepts_list_for :source
accepts_list_for :extra_source
def nginx_bin
var(:nginx_prefix) / 'sbin/nginx'
end
def nginx_conf
var(:nginx_prefix) / 'conf/nginx.conf'
end
def nginx_cert_path
var(:nginx_prefix) / 'conf/certs'
end
def nginx_conf_for domain, ext
var(:nginx_prefi... |
require 'test_helper'
class UserwaysControllerTest < ActionController::TestCase
setup do
@userway = userways(:one)
end
test "should get index" do
get :index
assert_response :success
assert_not_nil assigns(:userways)
end
test "should get new" do
get :new
assert_response :success
en... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.