text stringlengths 10 2.61M |
|---|
FactoryBot.define do
factory :book do
name { Faker::Book.title }
isbn { Faker::Code.isbn }
authors { Faker::Book.author }
info { Faker::Lorem.paragraph }
cover_image do
Rack::Test::UploadedFile.new(
Rails.root.join('spec', 'support', 'books', 'calculus.jpg'),
'image/jpeg'
... |
# frozen_string_literal: true
# rubocop:todo all
# Copyright (C) 2015-2020 MongoDB Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# U... |
# ==============================================================================
# SETUP
# ==============================================================================
cmd_prefix = "GEM_HOME=#{status.gem_home} RAILS_ENV=#{node.environment.framework_env}"
pid_dir = '/data/ahwaa/shared/tmp/pids'
pid_file = 'tmp/pi... |
class RemoveUserIdFromEntities < ActiveRecord::Migration
def change
remove_columns :entities, :user_id
end
end
|
class RemoveUnusedFieldsFromStep < ActiveRecord::Migration[5.0]
def change
remove_columns(:steps, :yaml_template, :operates_on_artifact)
end
end
|
Gem::Specification.new do |s|
s.name = "golia"
s.rubyforge_project = "golia"
s.authors = ["DAddYE"]
s.email = "d.dagostino@lipsiasoft.com"
s.summary = "Dead Links Checker and Speed Analyzer"
s.homepage = "http://www.padrinorb.com"
s.description ... |
require 'date'
module Types
class OrderType < Types::BaseObject
field :id, ID, null: false
field :user, Types::UserType, null: false
field :pickup_location, Types::PickupLocationType, null: false
field :items, [Types::OrderItemType], null: false
def items
OrderItem.where('order_id = ?', o... |
# frozen_string_literal: true
require 'stannum/constraints/types'
module Stannum::Constraints::Types
# A Nil type constraint asserts that the object is nil.
class NilType < Stannum::Constraints::Type
# The :type of the error generated for a matching object.
NEGATED_TYPE = 'stannum.constraints.types.is_nil... |
class ResultsAddDescJson < ActiveRecord::Migration[7.0]
def change
add_column(:results, :desc_json, :string)
add_column(:results, :core_link, :string)
end
end
|
module JanusGateway::Plugin
class Audioroom < JanusGateway::Resource::Plugin
# @param [JanusGateway::Client] client
# @param [JanusGateway::Resource::Session] session
def initialize(client, session)
super(client, session, 'janus.plugin.cm.audioroom')
end
# @return [Concurrent::Promise]
... |
class EasyVersionQuery < EasyQuery
include ProjectsHelper
def available_filters
return @available_filters unless @available_filters.blank?
group = l("label_filter_group_#{self.class.name.underscore}")
@available_filters = {
'status' => { :type => :list, :values => Version::VERSION_STATUSES.coll... |
namespace :react_meetup do
desc 'Expire accreditations over 90 days'
task :generate => :environment do
tmp = []
tables = ActiveRecord::Base.connection.tables
tables.each do |table|
next if ['tmp_investment_term', 'version', 'msd_profile'].include?(table.singularize.to_s)
tmp_result = [table.... |
class CreateTopLists < ActiveRecord::Migration
def change
create_table :top_lists do |t|
t.integer :top_list_id
t.string :name
t.timestamps
end
end
end
|
module Api
class PropertiesController < ApplicationController
def index
@properties = Property.order(created_at: :desc).page(params[:page]).per(6)
return render json: { error: 'not_found' }, status: :not_found if !@properties
render 'api/properties/index', status: :ok
end
def ... |
require 'ankusa'
require 'ankusa/memory_storage'
class Cschat::MessageClassifier
def initialize data
@storage = Ankusa::MemoryStorage.new
@classifier = Ankusa::NaiveBayesClassifier.new @storage
@listeners = {}
data.each { |action, text| @classifier.train action.to_sym, text } if data
end
def... |
module SeedMigrator
# Machinery to load the actual data update classes
module UpdateClassLoader
# Loads the class corresponding to the given update name from the given
# file system path.
#
# @param [String|Pathname|Symbol] root_path
# @param [String|Symbol] update_name
#
# @return [:... |
require 'github/markup'
class PostsController < ApplicationController
before_action :login_check
before_action :set_post, only: [:show, :edit, :update, :destroy]
# GET /posts
# GET /posts.json
def index
@posts = Post.where(user_id: session[:user_id]).order(:updated_at)
end
# GET /posts/1
# GET /pos... |
require 'rails_helper'
feature "user deletes account" do
before(:each) do
@bob = FactoryBot.create(:user, name: "bob", email: "bob@example.com")
@frank = FactoryBot.create(:user, name: "frank", email: "frank@example.com")
sign_in @bob
visit root_path
click_on "edit account"
click_on "Cance... |
class AddDirectorRatingWriterStudioGenreToMovies < ActiveRecord::Migration[5.0]
def change
add_column :movies, :director_id, :integer
add_column :movies, :writer, :string
add_column :movies, :studio, :string
add_column :movies, :genre_id, :integer
add_column :movies, :rating, :string
end
end
|
require "rubygems"
require "gosu"
class Rect
attr_accessor :x, :y, :width, :height, :color, :z_order
def initialize(params = Hash.new)
@x = params[:x] || 0
@y = params[:y] || 0
@width = params[:width] || 0
@height = params[:height] || 0
@color = params[:color] || 0xff000000
@z_order = para... |
require 'fileutils'
namespace :caching_funtime do
#good to overwrite this in order to load the correct fragment_trackerfiles
task :cache_environment => :environment do
require 'action_controller'
begin
require 'caching_config'
rescue LoadError => le
end
CachingFuntime::TheCacher.perform_c... |
require "spec_helper"
describe Paperclip::Validators::AttachmentContentTypeValidator do
before do
rebuild_model
@dummy = Dummy.new
end
def build_validator(options)
@validator = Paperclip::Validators::AttachmentContentTypeValidator.new(options.merge(
... |
require 'pry'
class Triangle
attr_accessor :side_a, :side_b, :side_c, :triangle
@@triangle = []
def initialize(side_a ,side_b ,side_c)
@side_a = side_a
@side_b = side_b
@side_c = side_c
@triangle = [side_a, side_b, side_c]
end
def kind
sum = 0
triangle = []
triangle= @triangle.sort
s... |
require 'rails/generators/active_record'
module Merit
module Generators::ActiveRecord
class MeritGenerator < ::ActiveRecord::Generators::Base
include Rails::Generators::Migration
source_root File.expand_path('../templates', __FILE__)
desc 'add active_record merit migrations'
def self.ne... |
module GithubTwitterServer
# these modules extend Feed instances for custom parsing
module Events
module GenericEvent
def project
end
def content
@content ||= parsed_content
end
end
module IssuesEvent
include GenericEvent
def issue_number
@issue_num... |
class UserItemsController < ApplicationController
def cart
cartItem = UserItem.find{|userItem| userItem.item_id === params[:item_id] && userItem.user_id === params[:user_id]}
if(cartItem)
if(params[:step] == "add")
cartItem.update(quantity: cartItem.quantity += 1)
... |
class CreateQueryHistories < ActiveRecord::Migration
def change
create_table :query_histories do |t|
t.references :custom, index: true
t.string :company_code
t.string :company_name
t.string :num
t.datetime :queried_at
t.timestamps
end
end
end
|
# frozen_string_literal: true
require_relative 'display'
# require_relative 'player'
# require 'colorize'
class Board
attr_accessor :board
def initialize
@board = Array.new(7) { Array.new(6) }
end
# push disc into first nil slot on a given column
def push_disc(column, player)
board[column].each_ind... |
# GOOGLE_CHROME_SHIM is an environment variable set within the Heroku CI pipeline environment.
# GOOGLE_CHROME_SHIM contains the path to chrome-related assets on the Heroku CI ephemeral VM.
chrome_bin = ENV.fetch('GOOGLE_CHROME_SHIM', nil)
binary_options = chrome_bin ? {binary: chrome_bin} : {}
headless_options = {ar... |
require 'rake'
require 'rake/gempackagetask'
require 'plugems_deploy/manifest'
require 'fileutils'
module PlugemsDeployBuild
include FileUtils
def gem_version
version_specified? ? plugem_version : get_gem_version
end
def version_specified?
! (plugem_version.empty? || (plugem_version == '> 0.0'))
... |
module Environment
def environment
ENV["RACK_ENV"] || ENV["RAILS_ENV"]
end
def development?
environment == "development"
end
def production?
environment == "production"
end
def staging?
environment == "staging"
end
def test?
environment == "test"
end
module ClassMethods
... |
class MessagingErrorMailer < ApplicationMailer
def ranking_error_message(object, error_messsage)
@object = object
@error_messsage = error_messsage
mail(subject: "Error processing ranking object")
end
end
|
require_relative 'feature_spec_helper'
describe 'an order', type: :feature do
let(:current_order) { Order.create! }
let(:user) { FactoryGirl.create :user }
let(:item) { FactoryGirl.create :item, user_id: user.id }
def book_an_item
item.availabilities.create(date: "10/04/2014")
item.availabilities.crea... |
require 'rails_helper'
describe 'User auth on request' do
let(:request_path) { '/tasks' }
context 'no token provided' do
it 'gets 401' do
get request_path, {}, {}
expect(response.code).to eq('401')
end
end
context 'when invalid token provided' do
it 'gets 401' do
get request_pat... |
# frozen_string_literal: true
RSpec.configure do |config|
config.before(:each) do
Uploadcare.config.public_key = 'demopublickey'
Uploadcare.config.secret_key = 'demoprivatekey'
Uploadcare.config.auth_type = 'Uploadcare'
Uploadcare.config.multipart_size_threshold = 100 * 1024 * 1024
end
end
|
module ActiveRecord
class Base
def self.to_qry(*args)
DirectiveRecord::Query.new(self, extract_connection(args)).to_sql(*args)
end
def self.qry(*args)
extract_connection(args).select_rows to_qry(*args)
end
def self.qry_value(*args)
extract_connection(args).select_value to_qry(... |
class Person
def initialize(name, surname)
@name = name
@surname = surname
end
end
|
class AddDataModuleIdToTreatmentModules < ActiveRecord::Migration
def change
add_column :treatment_modules, :data_module_id, :integer
end
end
|
require_relative '../test_helper'
class ProjectMedia2Test < ActiveSupport::TestCase
def setup
require 'sidekiq/testing'
Sidekiq::Testing.fake!
super
create_team_bot login: 'keep', name: 'Keep'
create_verification_status_stuff
end
test "should cache number of linked items" do
RequestStore... |
# encoding: utf-8
require "rails_helper"
describe RestaurantsAPI, :type => :request do
# ============================================================================
context "Get restaurant reviews" do
before :each do
@user = create(:user)
@restaurant_1 = create(:restaurant)
@user.ensure_aut... |
require 'will_paginate/array'
class Api::V1::PostsController < ApplicationController
def index
local_posts = Post.all.order(created_at: :desc).paginate(page: params[:page], per_page: 2)
posts = local_posts.to_a
posts << ::Gnews::GetPosts.new.call(query: 'watches').to_a.flatten.paginate(page: params[:page]... |
# frozen_string_literal: true
# rubocop:todo all
# Copyright (C) 2019-2020 MongoDB Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# U... |
# encoding: BINARY
require 'rubygems'
require 'hexdump'
require 'zlib'
require 'digest'
Encoding.default_external = 'BINARY'
STATIC_HEADER = "gpak\x00\x0d\x0a\xa5"
VERSION_NUMBER = "\x00\x00\x00\x01"
EMPTY_TIMESTAMP = "\xff" * 8
EMPTY_CHECKSUM = "\x00" * 32
TYPE_DELTA = 0x08
TYPE_COMPRESSED = 0x10
TYPE_INVALID_MASK = ... |
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe 'Workers - SQL Injection Report Producer', type: :feature do
subject(:archive_api) { Departments::Archive::Api.instance }
let(:legal_name) { 'Demo_1' }
let(:legal_ip_address) { '79.181.31.4' }
let(:friendly_resource) {
archive_api.new_fri... |
require 'spec_helper'
describe Configuration do
context "with all environment variables present" do
before :each do
ENV.stub(:[]).with("WEBEX_SITE_NAME").and_return("bakeryevents")
ENV.stub(:[]).with("WEBEX_USERNAME").and_return("bakery")
ENV.stub(:[]).with("WEBEX_PASSWORD").and_return("secret"... |
ReleaseNotes::Engine.routes.draw do
get '/' => 'release_notes#index'
get '/:version' => 'release_notes#show', as: 'version'
end
|
Factory.define :note do |note|
note.sequence(:content) {|i| "Content #{i}"}
end |
class SnakesField
def initialize(n)
@number_of_snakes = n
@snakes = []
(0..n).each do |i|
pos_y = ((i*20)+i*20)
s = SnakeSquare.new(x:0,y:pos_y,size:20,color:'red', dir:'right')
@snakes << SnakeController.new([s])
end
end
def moveSnakes(key)
@snakes.each {|s| s.nextMove(key)... |
class ConditionsController < ApplicationController
#->Prelang (scaffolding:rails/scope_to_user)
before_filter :require_user_signed_in, only: [:new, :edit, :create, :update, :destroy]
before_action :set_condition, only: [:show, :edit, :update, :destroy, :vote]
# GET /conditions
# GET /conditions.json
def ... |
require 'rspec'
require './lib/invoice_repository'
require './lib/sales_engine'
require 'simplecov'
SimpleCov.start
RSpec.describe InvoiceRepository do
before(:each) do
@se = SalesEngine.from_csv({
:items => './spec/fixtures/item_mock.csv',
:merchants => './spec/fixtures/merchant_mock.csv',
:in... |
# frozen_string_literal: true
class AddRegionToPokemons < ActiveRecord::Migration[5.2]
def change
add_reference :pokemons, :region, foreign_key: true
end
end
|
class Topic < ApplicationRecord
#
# => Validation
# => Column Value Validation
#
validates_presence_of :title
# => Entity relationship
has_many :blogs
end
|
class SophityMailer < ApplicationMailer
default from: "info@sophity.com"
def sample_email(user)
@user = user
mail(to: @user.email, subject: 'Sophity HealthCheck Report')
end
end
|
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe CoberturasController do
def mock_cobertura(stubs={})
@mock_cobertura ||= mock_model(Cobertura, stubs)
end
describe "GET index" do
it "assigns all coberturas as @coberturas" do
Cobertura.stub!(:find).with(:all).and_retur... |
a = (1930...1951).to_a
puts a[rand(a.size)]
*The numbers that will not be displayed are 1951 and 1952.
They will not be displayed because (1930...1951) is an exclusive range, meaning the top end number that defines the range is not included in the range. The low end number is.
In this case, 1930 - 1950 ... |
module ApplicationHelper
#here we'll have our master-list of answers, and the user's guess will be checked against that list.
def check_answer(answer, quiztype)
citylist = ["Atlanta","Asheville","Charlotte","Raleigh"]
statelist = ["Alaska", "Hawaii", "Washington", "Oregon", "California", "Arizona", "Nevada", "Idah... |
require_relative "lib/caesar_cipher"
describe CaesarCipher do # ~> NoMethodError: undefined method `describe' for main:Object
describe '#total_shift' do
# a = 97, z = 122, A = 65, Z = 90
it 'shifts "a" correctly with a small shift factor' do
caesar = CaesarCipher.new
test = caesar.total_shift(97,... |
require 'digest/sha1'
# Clase encargada de llevar un control de integridad sobre
# el último archivo de copia de seguridad generado.
class Backup < ActiveRecord::Base
# Método que genera un nuevo Digest para una cadena,
# que en éste caso corresponde al archivo de copia de
# seguridad más reciente.
def sel... |
class Snapshot < ActiveRecord::Base
attr_accessible :category, :count, :item, :snapshot_date
validates_presence_of :category, :count, :item, :snapshot_date
def self.take_snapshot
Member::MEMBER_TYPES.collect do |member_type|
Snapshot.create(:category => "member type",
:item => member_type,
... |
class AddStateFieldToTask < ActiveRecord::Migration
def change
add_column :tasks, :state, :string, null: false, default: 'inactive'
end
end
|
class Ability
include Scholar::Ability::CollectionAbility
include Hydra::Ability
include Hyrax::Ability
self.ability_logic += [:everyone_can_create_curation_concerns, :collection_abilities]
self.admin_group_name = 'admin'
def custom_permissions
if admin?
can [:destroy], ActiveFedora::Base
c... |
class User < ApplicationRecord
has_many :offers
has_secure_password
end
|
PlanSource::Application.routes.draw do
get "signup_links/edit"
authenticated :user do
root :to => 'home#index'
end
root :to => "home#index"
devise_for :users, skip: [:registrations]
# We have to add the edit and update actions directly
devise_scope :user do
get '/users/edit' => 'devise/regist... |
class PostsController < ApplicationController
before_action :require_user_logged_in
before_action :correct_user, only: [:destroy]
def create
@post = Post.new(post_params)
if @post.save
flash[:success] = '書き込み成功しました。'
#@post.order(@post.topic)
redirect_to topic_path(@post.topi... |
class AddBackgroundColumnsToUspages < ActiveRecord::Migration
def self.up
add_column :us_pages, :us_background_file_name, :string
add_column :us_pages, :us_background_content_type, :string
add_column :us_pages, :us_background_file_size, :integer
add_column :us_pages, :us_background_updated_at, ... |
module ChatGPT
module_function
def last_ask = @last_ask
def last_response = @last_response
def last_chat_data = @last_chat_data
def client
@client ||= OpenAI::Client.new
end
def ask(str)
@last_ask = str
response = client.chat(
parameters: {
model: "gpt-3.5-turbo", # Required.
... |
class ShoppingCart
#attr_accessor :products
def initialize
@products = []
@my_items = {
"apple" => 10,
"orange" => 5,
"grape" => 15,
"banana" => 20,
"watermelon" => 50
}
end
def add (item)
@products << item
end
def getprice(item)
@my_items[item]
puts @my_items[item]
end
def cost... |
#! /usr/bin/env ruby -S rspec
require 'spec_helper'
describe 'the dns_lookup function' do
let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
it 'should exist' do
expect(Puppet::Parser::Functions.function('dns_lookup')).to eq('function_dns_lookup')
end
it 'should raise a ArgumentError if there is less... |
class CreateCourseInvites < ActiveRecord::Migration
def change
create_table :course_invites do |t|
t.string :token, null: false
t.references :course
t.timestamps null: false
end
add_index :course_invites, :token, unique: true
end
end
|
# This lecture covers having a zoo (an array of all our animals)
class Animal
attr_accessor :color, :name
def initialize( name, color )
@color = color
@name = name
end
def identify
return "I am a #{self.class}"
end
def speak
return "hello my name is #{@name}"
end
end
class Tig... |
# -*- coding: utf-8 -*-
#
# EpisoDASデータをもとに単一HTMLを生成
#
# % ruby expand.rb Amazon_masui {seed} > Amazon.html
#
require 'erb'
require 'uri'
require "base64"
def get_file(file)
File.read "/home/masui/EpisoPass/public#{file}"
end
def expand_js(js)
'<script type="text/javascript">' + js + '</script>'
end
def expand
... |
module Super
module Codecs
class TimeCodec
def decode(value)
return unless value
value.is_a?(Time) ? value : Time.iso8601(value)
rescue ArgumentError
raise Super::Errors::DecodeError, "#{value} as #{value.class}"
end
def encode(entity)
return unless entity... |
class RpgsController < ApplicationController
def index
set_session_defaults
end
def gamble
building = params[:building]
gold = calculate_gold building
activity = build_activity building, gold
update_session gold, activity
redirect_to :back
end
private
def calculate_gold building
amounts ... |
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
require File.expand_path('../config/application', __FILE__)
Rails.application.load_tasks
def variant
ENV['RAILS_ENV'] || 'development'
end
desc "prepares db... |
module Steppable
extend ActiveSupport::Concern
included do
has_many :steps, -> {where(:deleted => false).order(step_no: :asc)}, :as => :steppable, :inverse_of => 'steppable'
accepts_nested_attributes_for :steps
end
def step_at(step_no)
steps.find{|s| s.step_no.to_i == step_no.to_i}
end
end
|
# Application template recipe for the rails_apps_composer. Change the recipe here:
# https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/tests4.rb
after_bundler do
say_wizard "recipe running after 'bundle install'"
### RSPEC ###
if prefer :tests, 'rspec'
say_wizard "recipe installing RSpec"
... |
class ChangeTypeNameToKind < ActiveRecord::Migration
def change
rename_column :marks, :type, :kind
end
end
|
class AddOptionsToOrders < ActiveRecord::Migration
def change
remove_column :orders, :options
add_column :orders, :options, :hstore
end
end
|
class Product
attr_reader :title, :price, :barcode, :manufacturer, :code, :generate_control
attr_writer :barcode, :code
def initialize(hash)
self.title = hash["title"].to_s
if(hash["price"].nil?)
fail SimpleStore::Error, "O preço do produto de... |
class HighScore < ActiveRecord::Base
validates :user, presence: true
validates :game, presence: true
validates :score, presence: true, numericality: {greater_than_or_equal_to: 0}
end
|
class HangpersonGame
# add the necessary class methods, attributes, etc. here
# to make the tests in spec/hangperson_game_spec.rb pass.
# Get a word from remote "random word" service
# def initialize()
# end
attr_accessor :word
attr_accessor :guesses
attr_accessor :wrong_guesses
def initializ... |
class ApplicationController < ActionController::Base
include PagesHelper
protect_from_forgery with: :exception
# def render_404
# render file: "#{Rails.root}/public/404", layout: false, status: 404
# end
unless Rails.application.config.consider_all_requests_local
rescue_from Exception, with: -> (ex... |
require_relative 'game'
require_relative 'piece'
require_relative 'cursor'
require_relative 'chars_array'
require_relative 'plane_like'
require_relative 'chess_clock'
require_relative 'checkers_errors'
require_relative 'symbol'
require 'colorize'
class Board
include PlaneLike
include CheckersErrors
COLORS = [:... |
class BlogsTagsController < ApplicationController
# GET /blogs_tags
# GET /blogs_tags.xml
before_filter :check_login_status
def index
@blogs_tags = BlogsTag.all
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @blogs_tags }
end
end
# GET /blo... |
class CreateFeeds < ActiveRecord::Migration
def change
create_table :feeds do |t|
t.string :provider
t.datetime :date
t.boolean :unread, :default => true
t.string :image
t.string :title
t.string :url
t.text :description
t.integer :subscription_id
t.timestamps... |
require 'test_helper'
class PlaceTest < ActiveSupport::TestCase
fixtures :users
test 'each place can return the weather' do
place = Place.new(
favorite_memory: 'going to the beach',
image_url: 'http://www.example.com/res.png',
location: 'philly',
visit_length: '1 week',
user_id: u... |
require_relative "Board.rb"
class Game
attr_accessor :board
def initialize
@board = Board.new
turn
end
def turn
@board.view_current_grid
while !won?
get_guesses
end
end
def get_guesses
count = 0
guess1 = []
guess2... |
module TrackingNumberValidator
class Service
VALIDATORS = [
DHLValidator,
FedExGroundValidator
]
def self.detect(tracking_number)
tracking_number ||= ""
tracking_number = sanitize(tracking_number)
VALIDATORS.each do |validator|
validator = validator.new(tracking_num... |
class JobOrder < ActiveRecord::Base
belongs_to :company
has_and_belongs_to_many :employees, :join_table => "employee_job_orders"
validates :name, presence: true, length: {in: 1..25}
end
|
module Api
class WorkingSetController < ApplicationApiController
def create
@working_set = WorkingSet.new working_set_params
if @working_set.valid?
@working_set.save!
end
end
def working_set_params
params.require(:working_set).permit(:real_reps, :predicted_reps, :real_weight, :predicted_w... |
class HiringCompany < ActiveRecord::Base
has_many :job_listings
accepts_nested_attributes_for :job_listings, :allow_destroy => true
acts_as_list
has_attached_file :logo, :styles => {:thumb => '200x200'}
validates_attachment_content_type :logo, :content_type => /image/
default_scope { order('position ASC'... |
class Cpufetch < Formula
desc "CPU architecture fetching tool"
homepage "https://github.com/Dr-Noob/cpufetch"
url "https://github.com/Dr-Noob/cpufetch/archive/v1.00.tar.gz"
sha256 "2254c2578435cc35c4d325b25fdff4c4b681de92cbce9a7a36e58ad58a3d9173"
license "MIT"
head "https://github.com/Dr-Noob/cpufetch.git",... |
# encoding: utf-8
# copyright: 2016, you
# license: All rights reserved
# date: 2016-09-16
# description: The Microsoft Internet Explorer 11 Security Technical Implementation Guide (STIG) is published as a tool to improve the security of Department of Defense (DoD) information systems. Comments or proposed revisions to... |
class Item < ActiveRecord::Base
scope :with_tag, ->(tag){ Item.all.select{|i| i.tags.include?(tag)}}
end
|
class ChangeCommentToRestaurants < ActiveRecord::Migration
def up
change_column :Restaurants, :comment, :text
end
#変更前の型
def down
change_column :Restaurants, :comment, :string
end
end
|
class AddFinishedToResolutions < ActiveRecord::Migration
def change
add_column :resolutions, :finished, :boolean
end
end
|
#
# 1. Use the "each" method of Array to iterate over [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], and print out each value.
#
arr = [1,2,3,4,5,6,7,8,9,10]
arr.each do |element|
puts element
end
# Convention for Rubyist (does the same as above)
arr.each { |element| puts element }
# Alternative way
[1,2,3,4,5,6,7,8,9,10].each {... |
module Sluggable
extend ActiveSupport::Concern
included do
before_create :set_slug
validates :slug, uniqueness: { case_sensitive: false }
scope :from_param, -> param { find_by(slug: param) }
end
def to_param
self.slug
end
private
def set_slug
number = 1
begin
self... |
require 'rails_helper'
include SessionTimeoutWarningHelper
include ActionView::Helpers::DateHelper
feature 'Sign in' do
scenario 'user cannot sign in if not registered' do
signin('test@example.com', 'Please123!')
expect(page).to have_content t('devise.failure.not_found_in_database')
end
scenario 'user ... |
require 'digest/md5'
class User < ActiveRecord::Base
# Validation for the password
has_secure_password
before_validation :prep_email #prepara el correo antes de validarlo
before_save :create_avatar_url #crea el hash md5 antes de guardarlo ya que se puede dar el caso de que actualizan algun dato del correo.
#val... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.