text stringlengths 10 2.61M |
|---|
class Adoption < ApplicationRecord
belongs_to :owner
belongs_to :dog
has_and_belongs_to_many :comments
validates_uniqueness_of :owner, :dog
end
|
require 'fileutils'
require 'securerandom'
class LetterAvatar
# CHANGE these values to support more pixel ratios
FULLSIZE = 120 * 3
class << self
def generate(letter, size, r, g, b, version = 1)
File.read(generate_path(letter, size, r, g, b, version))
end
def generate_path(letter, size, r... |
class PollsController < ApplicationController
before_action :redirect_to_root, :if => :not_signed_in?, only: [:edit, :destroy, :new, :edit]
before_action :require_admins, only: [:crete, :new, :edit, :update, :destroy]
def index
@polls = Poll.all
end
def new
@poll = Poll.new
end
def show
@pol... |
module Helpstation
module Fetchers
NotFoundError = Class.new(StandardError)
class ByKeyFetcher < Processor
def self.build(input_key, output_key, &block)
Class.new(self) do
define_method :input_key do
input_key
end
define_method :output_key do
... |
class Doc8 < Formula
include Language::Python::Virtualenv
desc "Style checker for Sphinx documentation"
homepage "https://github.com/PyCQA/doc8"
url "https://files.pythonhosted.org/packages/bb/fd/a39b9b8ce02f38777a24ce06d886b1dd23cea46f14b0f0c0418a03e5254d/doc8-0.9.1.tar.gz"
sha256 "0e967db31ea10699667dd0779... |
class WentsController < ApplicationController
before_action :set_went, only: [:show, :edit, :update, :destroy]
# GET /wents
# GET /wents.json
def index
@wents = Went.all
if params[:shop_id].present?
went = Went.find_by(user_id: current_user.id, shop_id: params[:shop_id])
render json: {statu... |
class ProductsController < ApplicationController
include AdminHelper
layout "admin"
before_filter :validate_admin
before_filter :set_tab_index
before_filter :load_categories, only: [:index, :new, :edit]
before_filter :save_image, only: [:create, :update]
before_filter :prepare_config
before_filter :m... |
class Import < ActiveRecord::Base
belongs_to :workspace
belongs_to :source_dataset, :class_name => 'Dataset'
belongs_to :user
belongs_to :import_schedule
def self.run(import_id)
Import.find(import_id).run
end
def run
import_attributes = attributes.symbolize_keys
import_attributes.slice!(:wor... |
require 'rails_helper'
require 'spec_helper'
RSpec.describe LocationController do
let(:json) { JSON.parse(response.body) }
let!(:location_attributes) { attributes_for(:location) }
context '#create' do
context 'when given all attributes' do
before do
post :create, params: location_attributes
... |
require 'spec_helper'
describe Boxzooka::ProductListRequest do
let(:instance) {
described_class.new(
customer_access: Boxzooka::CustomerAccess.new(customer_id: 123, customer_key: 'abc')
)
}
describe 'XML serialization' do
let(:xml) { Boxzooka::Xml.serialize(instance) }
it { puts Ox.dump(Ox... |
module Util
class Options
private_class_method :new
DEBUG_1 = 1 # everything
DEBUG_2 = 2 # interpreter only
DEBUG_3 = 3 # debug command only (default level if switch is present)
DEBUG_OFF = 9 # no debug (default)
LANG_EN = 'en'.freeze # en-CA (default)
LANG_JA = 'ja'.freeze # ja-JP... |
class DepartmentsController < ApplicationController
before_action :set_department, :only => [:edit, :destroy, :update]
def index
@departments=Department.all
end
def new
@department=Department.new
end
def edit
end
def update
respond_to do |format|
if @department.update(department_params)
... |
class ProgrammingTestCase < ActiveRecord::Base
attr_accessible :stdin, :stdout
validates :stdin, presence: true
validates :stdout, presence: true
belongs_to :programming_task, inverse_of: :programming_test_cases
end
|
class Deposito < ApplicationRecord
belongs_to :account
before_save :validar_operacao
validates_presence_of :valor, :account_id
def validar_operacao
account = Account.find_by_id(self.account_id)
deposita_conta(account)
end
end
|
class Laser
SPEED = 5
def initialize (x, y, angle)
@x = x
@y = y
@angle = angle
@img = Gosu::Image.new("media/starfighter.bmp")
end
def update
@x += Gosu::offset_x(@angle, SPEED)
@y += Gosu::offset_y(@angle, SPEED)
end
def draw
@img.draw_rot(@x,@y, ZOrder::PLAYER, @angle)
end
end |
QuoteManager::Application.routes.draw do
authenticated :user do
root 'dashboard#index', as: :subdomain_root
end
root 'welcome#index'
namespace :admin do
get '/', action: :index
post '/deactive/:account_id', action: :deactive, as: :deactive
post '/active/:account_id', action: :active, as: :acti... |
class Abcl < Formula
homepage "http://abcl.org"
url "http://abcl.org/releases/1.3.1/abcl-bin-1.3.1.tar.gz"
sha1 "7abb22130acfbca9d01c413da9c98a6aa078c78b"
depends_on :java => "1.5+"
depends_on "rlwrap"
def install
libexec.install "abcl.jar", "abcl-contrib.jar"
(bin+"abcl").write <<-EOS.undent
... |
class Authors < Netzke::Basepack::Grid
def configure(c)
super
c.model = "Author"
end
end
|
class Reservation < ApplicationRecord
after_create_commit { notify }
belongs_to :user
belongs_to :place
#belongs_to :reservation_status
def time_diff(start_time, end_time)
seconds_diff = (start_time - end_time).to_i.abs
hours = seconds_diff / 3600
seconds_diff -= hours * 3600
minutes = second... |
#!/usr/bin/ruby
#
# Create a platform with 3 networks (asia, europe, us) connected together
# via a 'global' network.
# Inspired from the tutorial's example
# To use with: platform_setup_globalinternet.rb <SUBNET>
# e.g.: platform_setup_globalinternet.rb 10.144.0.0/22
require 'distem'
require 'ipaddress'
$cl = Distem... |
require 'rails_helper'
RSpec.describe VoteOpinion, type: :model do
context 'validations' do
let(:vote_opinion) { FactoryBot.build(:vote_opinion) }
subject { vote_opinion }
it { should belong_to(:poll) }
it { should belong_to(:answer) }
it { should belong_to(:user) }
it { should validate_pres... |
class TagValidator < ActiveRecord::EachValidator
TAGS_ALLOWED = ["sports","news","social media"]
def validate_each(record, attribute_name, value)
unless TAGS_ALLOWED.include?(value)
record.errors[attribute_name] << (options[:message] || "Tag not allowed")
end
end
end
class TagTopic < ActiveRecord:... |
class Category < ActiveRecord::Base
belongs_to :user
has_many :sub_categories
validates :name, presence: true, uniqueness: true
end
|
require 'rails_helper'
describe 'users/notifications/index' do
before do
@notifications = []
@notifications << build_stubbed(:user_notification, read: false)
@notifications << build_stubbed(:user_notification, read: true)
end
it 'displays' do
assign(:notifications, @notifications)
render
... |
class Tetherer < ActiveRecord::Base
attr_accessible :data_available, :mac_address
has_many :users
end
|
require 'test_helper'
class ScholarshipStudyFieldsControllerTest < ActionDispatch::IntegrationTest
setup do
@scholarship_study_field = scholarship_study_fields(:one)
end
test "should get index" do
get scholarship_study_fields_url
assert_response :success
end
test "should get new" do
get new... |
require "java"
require 'carrot/util/timeout'
require 'uri'
require 'net/http'
require 'rack'
import java.lang.Runtime
import java.lang.Runnable
import java.io.InputStreamReader
import java.io.BufferedReader
module Carrot
class ExtendServer
attr_accessor :server_process, :shutdown_process
class Shutdown... |
class FeathersController < ApplicationController
if FeatherCms::Config.authentication.kind_of?(Hash)
http_basic_authenticate_with FeatherCms::Config.authentication.merge(except: :published)
else
before_filter FeatherCms::Config.authentication.to_sym, except: :published
end
before_filter :find_page, on... |
module Nagios
class Plugin
VERSION = '3.0.2'
EXIT_CODE =
{ unknown: 3,
critical: 2,
warning: 1,
ok: 0 }
def self.run!(*args)
plugin = new(*args)
plugin.check if plugin.respond_to?(:check)
puts plugin.output
exit EXIT_CODE[plugin.status]
r... |
require 'tb'
require 'test/unit'
require_relative 'util_tbtest'
class TestTbCSV < Test::Unit::TestCase
def parse_csv(csv)
Tb::HeaderCSVReader.new(StringIO.new(csv)).to_a
end
def generate_csv(ary)
writer = Tb::HeaderCSVWriter.new(out = '')
ary.each {|h| writer.put_hash h }
writer.finish
out
... |
# Shortest String
# I worked on this challenge by myself.
# shortest_string is a method that takes an array of strings as its input
# and returns the shortest string
#
# +list_of_words+ is an array of strings
# shortest_string(array) should return the shortest string in the +list_of_words+
#
# If +list_of_words+ is e... |
class ProjectEstimationForm
include ActiveModel::Model
attr_accessor :projects, :estimated_proxy_size, :base, :time
validate :number_of_data_items
validate :number_of_historical_data_items
def self.model_name
ActiveModel::Name.new(self, nil, "Estimation")
end
def submit(params)
@projects... |
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Brcobranca::Remessa::Cnab240::Sicoob do
let(:pagamento) do
Brcobranca::Remessa::Pagamento.new(
valor: 50.0,
data_vencimento: Date.current,
nosso_numero: '429715',
documento: 6969,
documento_sacado: '82136760505',
... |
class RepackagingOrder
FLAT_MARKUP_PERCENTAGE = 0.05
EMPLOYEE_MARKUP_PERCENTAGE = 0.012
FOOD_MARKUP_PERCENTAGE = 0.13
DRUGS_MARKUP_PERCENTAGE = 0.075
ELECTRONICS_MARKUP_PERCENTAGE = 0.02
attr_accessor :base_price, :type, :required_employees_quantity
def initialize(base_price, ... |
require 'test_helper'
class ArtyscisControllerTest < ActionController::TestCase
setup do
@artysci = artyscis(:one)
end
test "should get index" do
get :index
assert_response :success
assert_not_nil assigns(:artyscis)
end
test "should get new" do
get :new
assert_response :success
en... |
class Relationthemeship < ActiveRecord::Base
belongs_to :theme
belongs_to :reltheme, :class_name => "Theme"
end
|
class AddAdditionalInformationToServiceItems < ActiveRecord::Migration[5.2]
def change
add_column :service_items, :additional_information, :text
end
end
|
# == Schema Information
#
# Table name: interests
#
# id :integer not null, primary key
# category :string(255)
# category_desc :string(255)
# active :boolean
# created_at :datetime not null
# updated_at :datetime not null
# reserved :boolean defaul... |
require 'spec_helper'
require 'world'
describe "Address" do
include World
describe "normally" do
let(:address) { FactoryGirl.build( :address ) }
it { address.address.should == '1 Main Street' }
it { address.zip.should == '90000' }
it { address.isactive.should be_true}
end
end
|
require 'spec_helper'
require_relative '../lesson3/station'
RSpec.describe Station do
subject {described_class.new('A')}
let(:trains) {build_list(:train, 2, type: :freight)}
describe '#return_trains_on_type' do
before { subject.add_train(trains.first); station1.add_train(trains.last)}
it 'Return sorted ... |
class PrcolorsController < ApplicationController
before_filter :admin_required
# GET /prcolors
# GET /prcolors.xml
def index
@prcolors = Prsize.all
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @prcolors }
end
end
# ... |
class HomeController < ApplicationController
before_filter :setup_session_user
before_filter :setup_mygov_client
before_filter :setup_mygov_access_token
def oauth_callback
auth = request.env["omniauth.auth"]
session[:user] = auth.extra.raw_info.to_hash
session[:token] = auth.credentials.token
r... |
require 'fs/xfs/superblock'
module XFSProbe
def self.probe(dobj)
unless dobj.kind_of?(MiqDisk)
$log&.debug("XFSProbe << FALSE because Disk Object class is not MiqDisk, but is '#{dobj.class}'")
return false
end
# The first Allocation Group's Superblock is at block zero.
dobj.seek(0, IO::S... |
module ESearchy
module SocialEngines
class LinkedIn < ESearchy::BasePlugin
include ESearchy::Helpers::Search
include ESearchy::Parsers::People
ESearchy::PLUGINS[self.name.split("::")[-1].downcase] = self
def initialize(options={}, &block)
@info = {
#This name s... |
class User < ApplicationRecord
has_secure_password
validates_presence_of :email
validates_uniqueness_of :email
end
|
# ==========================================================================
# Project: Lebowski Framework - The SproutCore Test Automation Framework
# License: Licensed under MIT license (see License.txt)
# ==========================================================================
module Lebowski
module Foundat... |
require "spec_helper"
describe JwtRest::AuthHeader do
jwt_token_boilerplate
basic_token_boilerplate
let(:basic_header) { described_class.new("basic #{basic_token}") }
let(:jwt_header) { described_class.new("bearer #{jwt_token}") }
let(:ugly_header) { described_class.new("8923ihwefbmndsfnbdg") }
before :e... |
class ProjectsController < ApplicationController
def index
@time_sheets = TimeSheet.includes(:project).all
end
def new
@project = Project.new
@projects = Project.all.pluck(:name, :id)
end
def create
time_sheet = Project.new(time_sheet_params)
time_sheet.save
end
private
def time_sheet_para... |
require 'test_helper'
class PostTest < ActiveSupport::TestCase
test "last_commenter" do
post = Post.create! :name => "testpost"
post.comments.create! :commenter => "the commenter"
assert_equal "the commenter", post.reload.last_commenter
end
end
|
class Player < ActiveRecord::Base
has_many :participations
has_many :games, through: :participations
end
|
module TheCityAdmin
# This class is the base class for all TheCity objects and is meant to be inherited.
#
class ApiList
attr_reader :total_entries, :total_pages, :per_page, :current_page
def self.load(options = {})
self.new(options)
end
# Checks if there is a next page.
#
... |
require 'rails_helper'
describe 'user can see all tags' do
describe 'they visit /tags' do
it 'should show a list of all tags' do
article = Article.create!(title: "New Title", body: "New Body")
article.tags.create(name: "ruby")
article.tags.create(name: "programming")
visit tags_path
... |
Rails.application.routes.draw do
get '/' => 'sites#home'
post '/' => 'sites#index'
resources :concerts do
resources :comments
end
get '/popular_concerts' => 'concerts#show_most_popular'
end
|
module Frivol
# == Frivol::Config
# Sets the Frivol configuration (currently only the Redis config), allows access to the configured Redis instance,
# and has a helper method to include Frivol in a class with an optional storage expiry parameter
module Config
# Set the Backend.
#
# Expects one of Fr... |
require "task"
RSpec.describe Task do
describe "#project" do
it "detects ::shop" do
task = Task.new("Get milk ::shop")
expect(task.project).to eq("shop")
end
it "detects :shop" do
task = Task.new("Get milk :shop")
expect(task.project).to eq("shop")
end
it "detects :sho... |
require "application_system_test_case"
class FileSentsTest < ApplicationSystemTestCase
setup do
@file_sent = file_sents(:one)
end
test "visiting the index" do
visit file_sents_url
assert_selector "h1", text: "File Sents"
end
test "creating a File sent" do
visit file_sents_url
click_on "... |
class JobsController < ApplicationController
before_action :authenticate_user!, only: [:new, :create]
before_action :authenticate_worker!, only: [:update]
def index
@jobs = Job.all
end
def show
@job = Job.find(params[:id])
end
def new
@job = Job.new
render :new
end
def create
@job = J... |
require 'helper'
describe Esendex::Users do
let(:credentials) { Esendex::Credentials.new('user', 'pass', 'ref') }
subject { Esendex::Users.new(credentials) }
end
|
require 'rails_helper'
describe 'forums/topics/edit' do
let(:topic) { create(:forums_topic) }
it 'displays' do
assign(:topic, topic)
render
end
end
|
require 'rails_helper'
describe Types::CommentType do
types = GraphQL::Define::TypeDefiner.instance
it 'defines a field id of type ID!' do
expect(subject).to have_field(:id).that_returns(!types.ID)
end
it 'defines a field provider of type String!' do
expect(subject).to have_field(:body).that_returns(... |
class Article < ApplicationRecord
include Voteable
belongs_to :user
has_many :comments, dependent: :destroy
has_many :reports, as: :reportable, dependent: :destroy
validates :user, :title, presence: true
validates :uid, uniqueness: true
validates :url, uniqueness: true, allow_blank: true
validates :u... |
FactoryGirl.define do
factory :category do
sequence :name do |i|
"Category #{i}"
end
end
end
|
require 'factory_bot'
require 'faker'
namespace :check_list_engine do
desc 'Seed data for an audit'
task seed_audit_data: :environment do
def create_available_component_types
available_component_types = [
{title: 'Title', has_photo: false},
{title: 'Choices', has_photo: false},
... |
@counter = 0
@account_number = 0
private
def pin
@pin = 1234
end
class Account
attr_reader :name, :balance, :number
def initialize(name, balance=100)
@name = name
@balance = balance
end
def display_balance()
puts "Balance: $#{@balance}."
end
def withdraw(amount)
... |
class Subscription < ActiveRecord::Base
belongs_to :channel, counter_cache: true
belongs_to :user, counter_cache: true
validates :channel_id, presence: true, uniqueness: { scope: :user_id }
validates :user_id, presence: true
def to_h
SubscriptionSerializer.new(self).attributes
end
end
|
require 'spec_helper'
describe ::ServiceBinding::ConjurV5AppBinding do
let(:service_id) { "service_id" }
let(:binding_id) { "binding_id" }
let(:org_guid) { nil }
let(:space_guid) { nil }
let(:service_binding) do
::ServiceBinding::ConjurV5AppBinding.new(
service_id,
binding_id,
org_guid... |
# Execute Choria Playbook Tasks
#
# Any task supported by Choria Playbooks is supported and
# can be used from within a plan, though there is probably
# not much sense in using the Bolt task type as you can just
# use `run_task` or `run_command` directly in the plan.
#
# The options to Playbook tasks like `pre_book`, `... |
class Product < ApplicationRecord
has_and_belongs_to_many :categories
belongs_to :merchant
has_many :order_items
has_many :reviews
validates :name, presence: true, uniqueness: true
validates :price, presence: true, numericality: {greater_than: 0}
def average_rating
return self.reviews.average(:ratin... |
class SessionsController < ApplicationController
def new
end
def create
user = User.find_by(:email => params[:login][:email].downcase)
if user && user.authenticate(params[:login][:password])
session[:user_id] = user.id
render :json => { success: true }
else
render :json => { succes... |
#
# Cookbook:: asf
# Recipe:: service
#
# Copyright:: 2017, Tyler Wong, All Rights Reserved.
poise_service_user 'asf' do
action :create
end
%W(#{node['asf']['install']['path']} #{node['asf']['config']['path']}).each do |dir|
directory dir do
owner 'asf'
group 'asf'
mode '0755'
recursive true
a... |
require 'spec_helper'
describe FraudModel do
let(:user) { FactoryGirl.create(:merchant) }
let!(:good_transaction) { FactoryGirl.create(:good_transaction, user: user, amount: 50) }
let!(:bad_transaction) { FactoryGirl.create(:bad_transaction, user: user, amount: 200) }
let!(:extreme_transaction) { FactoryGirl.... |
require 'rails_helper'
RSpec.describe "Users::Sessions", type: :request do
describe "GET /users/auth/:provide" do
let(:auth_info) {
OmniAuth::AuthHash.new({
provider: 'github',
info: {
email: 'github@rubyconf.tw'
}
})
}
it "copy data from provider session" d... |
class Project < ActiveRecord::Base
has_many :project_users, dependent: :destroy
has_many :users, through: :project_users
has_one :work_branch_collection
accepts_nested_attributes_for :work_branch_collection, allow_destroy: true
serialize :actions, Array
def github_access_token
authenticating_user.git... |
# frozen_string_literal: true
RSpec.describe ErrorHandler do
describe '.error_json' do
context 'when error' do
it 'should return an error status' do
error_message = 'some arbitrary app error'
error = StandardError.new error_message
code, content_type, status = described_class.new(ap... |
require 'rails_helper'
RSpec.describe ContentsController, type: :controller do
describe 'GET #index' do
let(:contents) { create_list(:content, 2) }
before { get :index }
it 'array all contents' do
expect(assigns(:contents)).to match_array(contents)
end
it 'render index view' do
e... |
require 'spec_helper'
describe AdventurersHelper do
let(:user) { FactoryGirl.create(:user) }
let(:story) { FactoryGirl.create(:story) }
let(:chapter) { FactoryGirl.create(:chapter, story: story) }
let(:item) { FactoryGirl.create(:item) }
let(:modifier_shop) { FactoryGirl.create(:modifier_shop, chapter: chapt... |
class Evil::Client::Operation
class UnexpectedResponseError < RuntimeError
attr_reader :status, :data
private
def initialize(schema, status, data)
@status = status
@data = data
message = "Response to operation '#{schema[:key]}'" \
" with http status #{status} and bod... |
class Feed < ActiveRecord::Base
attr_accessible :name, :url, :user_id
#has_many :readlater
before_save do |record|
unless self.unique then
raise "Feed name or url already exists."
end
unless self.user_feed_quota(record.user_id) then
raise "You cannot agregate more than 40 feeds."
... |
Rails.application.routes.draw do
get 'thanks' => 'pages#thanks'
resources :signups, only: [:new, :create]
get 'signups' => 'signups#new'
post 'signups' => 'signups#create'
root 'pages#home'
get 'about' => 'pages#about'
end
|
# -*- encoding : utf-8 -*-
class Cms::FeedbacksController < Cms::BaseController
def index
@feedbacks = Feedback.latest.page(params[:page])
end
def show
@feedback = Feedback.find(params[:id])
end
def new
@feedback = Feedback.new
end
def edit
@feedback = Feedback.find(params[:id]... |
class CreatePosts < ActiveRecord::Migration
def change
create_table :posts do |t|
t.references :post_category, index: true, null:false
t.string :name, null:false
t.string :title
t.string :heading
t.text :keywords
t.text :description
t.text :content
t.timestamps
... |
require "./lib/node.rb"
class LinkedList
attr_reader :head
def initialize
@head = nil
end
def append(data)
if @head.nil?
@head = Node.new(data)
else
current_node = @head
until current_node.next_node == nil
current_node = current_node.next_node
end
curre... |
class Event < ActiveRecord::Base
BASE_ROLE_NAME = 'participant'
validates :name, :start_date, :end_date, :owner_id, presence: true
validates :capacity, presence: true, numericality: { only_integer: true, greater_than: 0 }
belongs_to :owner, class_name: 'User'
has_many :days
has_many :participants
has_ma... |
require "rails_helper"
describe DirectionService do
context "#direction" do
it "returns directions to the closest chipotle" do
VCR.use_cassette("directions") do
lat = 39.7511873
lng = -105.0031571
destination = PlaceService.new.get_chipotle(lat, lng, 500)
directions = Direct... |
################################################################################
# Model Test For Album
################################################################################
require 'spec_helper'
require 'rails_helper'
describe Song, :type => :model do
include_context 'song_setup'
let(:album_search_te... |
module Jekyll
module Tags
class PermalinkTag < Liquid::Tag
def initialize(tag_name, markup, tokens)
super
@post_permalink = "#{markup.strip}/"
end
def render(context)
possible_posts = context['site']['posts'].select do |post|
post.permalink == @post_permalink
... |
class ContactGathering < ActiveRecord::Base
belongs_to :gathering
belongs_to :contact
end
|
class CreateItemTmplViews < ActiveRecord::Migration
def change
create_table :item_tmpl_views do |t|
t.integer :item_tmpl_id
t.string :name
t.text :tmpl
t.string :tmpl_type
t.timestamps
end
end
end
|
class CreateStudents < ActiveRecord::Migration
def change
create_table :students do |t|
t.column :student_id, :string, :primary_key => true
t.string :student_name
t.string :major
t.string :minor
t.text :other_information
t.integer :class_year_st
t.integer :hours_st
... |
class Index::History < ApplicationRecord
belongs_to :user,
class_name: 'Index::User',
foreign_key: :user_id,
optional: true
belongs_to :product, -> { with_del },
class_name: 'Index::Product',
foreign_key: :p_id
default_scope { order('index_histories.updated_at DESC') }
# 浏览记录
... |
class ToolsController < ApplicationController
before_action :find_tool, only: [:show, :edit, :update]
def index
@tools = Tool.all
end
def show
# find_tool
end
def new
@users = User.all
@tool = Tool.new
end
def create
@tool = Tool.new(tool_params)
if @tool.save
redirect... |
require 'test_helper'
class ChromeLoggerTest < Minitest::Test
def test_env_name_is_configurable
assert_respond_to \
ChromeLogger,
:env_name=
end
def test_env_name_has_default
assert_equal \
ChromeLogger::DEFAULT_ENV_NAME,
ChromeLogger.env_name
end
def test_accepts_an_app_on_... |
class AddServicioIdToComponents < ActiveRecord::Migration[5.0]
def change
add_column :components, :servicio_id, :integer
end
end
|
#!/usr/bin/env ruby
#
# csv_to_vhdl.rb
#
# Quick script to convert Logic Analyzer output to a VHDL testbench.
# Should also support oscilloscope output in the future.
#
require 'csv'
require 'trollop'
#
# Read in options fro the command line.
#
options = Trollop::options do
version "CSV to VHDL (c) 2013 Kyle J. Te... |
class User < ApplicationRecord
has_many :send_messages, foreign_key: "sender_id", class_name: "Message"
has_many :receive_messages, foreign_key: "receiver_id", class_name: "Message"
def self.is_authenticated(email,password)
user = User.find_by_email(email)
if ( user.present? )
return user.passw... |
class CreateKptEntries < ActiveRecord::Migration
def change
create_table :kpt_entries do |t|
t.integer :kpt_board_id
t.integer :user_id
t.integer :kind, :null => false, :default => 0
t.string :description, :null => false, :default => "", :limit => 150
t.datetime :created_... |
require_relative './11.skills'
require_relative './13.diets'
class Animal
# Con el método include podemos agregar los
# módulos como si fueran método de instancia.
# Si tenemos varios módulos dentro de un módulo
# podemos acceder a ellos con el operador de alcance '::' (scope opertor)
include Skills::Walk
... |
module ReportsHelper
def list_id(list)
"list_#{list['id']}"
end
def list_member_id(list)
"listMember_#{list['id']}"
end
def report_params(additional_params = {})
new_params = {}
[:from, :to, :period, :time_group, :campaign].each do |param|
new_params[param] = params[param] if para... |
class ApplicationController < ActionController::Base
protect_from_forgery
def login_required
if session[:client_id]
@current_client = Client.find(session[:client_id])
Time.zone = @current_client.time_zone
return true
end
flash[:warning]='Please login to continue.'
session[:return_... |
class Role < Sequel::Model
many_to_many :users, left_key: :role_id, right_key: :user_id, join_table: :users_roles
end
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.