text stringlengths 10 2.61M |
|---|
class Shop < Describable
include Taggable
belongs_to :user, inverse_of: :owned_shops
belongs_to :location
has_many :items
has_many :bookings, through: :items
has_many :carts, through: :bookings
has_many :taggings, as: :taggable, dependent: :destroy
has_many :photos, as: :photoable, dependent: :destroy
... |
class HomeController < ApplicationController
skip_before_filter :authenticate_user!
def index
@featured_trail = Trail.featured.first
end
def destroy
sign_out :user
redirect_to root_path
end
end
|
class User < ActiveRecord::Base
validates :user_name, presence: true, uniqueness: true
validates :password_digest, presence: true
validates :password, length: { minimum: 6 }, allow_nil: true
has_many :cat_rental_requests,
primary_key: :id,
foreign_key: :user_id,
class_name: :user
has_many :cats,... |
namespace :db do
desc "Erase and fill database"
task :populate => :environment do
require 'populator'
require 'faker'
[Category, Product, Person].each(&:delete_all)
Product.populate 10..100 do |product|
product.title = Populator.words(1..5).titleize
product.descripti... |
require 'rails_helper'
RSpec.describe RecipeIngredient, type: :model do
subject { build_stubbed(:recipe_ingredient) }
it 'has a correct factor' do
expect(subject).to be_valid
end
# associations
describe 'associations' do
it { should belong_to(:ingredient) }
it { should belong_to(:recipe) }
en... |
module Asaas
module Entity
class Notification
include Virtus.model
attribute :id, String
attribute :customer, String
attribute :event, String
attribute :scheduleOffset, Integer
attribute :emailEnabledForProvider, Axiom::Types::Boolean
attribute :smsEnabledForProvider, Ax... |
require 'rails_helper'
RSpec.describe Order, type: :model do
describe "validations" do
subject(:order) { build(:order) }
it { is_expected.to validate_presence_of(:customer_name) }
end
describe "callbacks" do
describe "before_validation" do
describe "#assign_uuid" do
it "assigns a rand... |
require 'rails_helper'
RSpec.describe 'Products API' do
let(:default_params) { { format: :json } }
describe 'GET index' do
before(:each) do
create(:product)
sign_in_as create :staff
@products = Product.all
end
it 'returns a collection of all of the products', :show_in_doc do
g... |
##
#
class Shitty
def initialize(app)
@app = app
end
def call(env)
# env represents the request - mutate it here
puts 'Shitty: improving request'
# call the next thing in the chain
status, headers, body = @app.call(env)
# do stuff with the response
puts 'Shitty: improving the respon... |
module AuditlogHelper
def render_auditlog_changes(changes)
content_tag :ul do
content_tag_for(:li, changes) do |change|
change.readable_message
end
end
end
end |
class IncomesController < ApplicationController
def index
@start_date = params[:start_date]
@end_date = params[:end_date]
if @start_date || @end_date
@incomes = Income.search(@start_date, @end_date)
else
@incomes = Income.this_month
end
@sum = @incomes.sum(:amounts)
end
def... |
class Api::CharactersController < ApplicationController
def index
if (params[:opponents])
@characters = Character.where.not(user_id: current_user.id)
else
@characters = Character.where(user_id: current_user.id)
end
render :index
end
def create
@character = Character.new(charac... |
# Countdown
# Our countdown to launch isn't behaving as expected. Why? Change the code so that our program successfully counts down from 10 to 1.
# counter = 10
# def decrease(counter)
# counter -= 1
# end
# 10.times do
# puts counter
# counter = decrease(counter)
# end
# puts 'LAUNCH!'
=begin
[not necess... |
class Worker < ApplicationRecord
has_and_belongs_to_many :shifts
end
|
# -*- encoding : utf-8 -*-
# The model of the event resource.
#
# This code is part of the Stoffi Music Player Project.
# Visit our website at: stoffiplayer.com
#
# Author:: Christoffer Brodd-Reijer (christoffer@stoffiplayer.com)
# Copyright:: Copyright (c) 2014 Simplare
# License:: GNU General Public License (stoffi... |
#Common structure, open curlies
#the part is key value pais
#keys are strings, values can be anything
car = {
"model" => "s-class",
"color" => "blue",
"speed" => 200,
"fourDoor" => true
}
#Sometimes you may see the keys with simbols
# car = {
# :model => "s-class",
# :color => "blue",
# :speed => 200,
# ... |
class AddEmployeesPerPageToUsers < ActiveRecord::Migration[5.0]
def change
add_column :users, :employees_per_page, :integer, default: 25
add_column :users, :order_employees_by, :string, default: 'first_name ASC'
end
end
|
include_recipe 'directory_helper'
home_dir = DirectoryHelper.home(node)
home_path = "#{home_dir}/" + node[:user]
# rbenv
RBENV_PATH = home_path + "/.rbenv"
DEFAULT_GEM_PATH = RBENV_PATH + "/default-gems"
RBENV_EXE = RBENV_PATH + "/bin/rbenv"
execute "Create rbenv-default-gems file" do
user node[:user]
command "t... |
class IdeasController < ApplicationController
def new
@user = User.find(params[:user_id])
@idea = @user.ideas.new
@image = Image.all
redirect_to root_path unless @user == current_user
end
def create
@user = User.find(params[:user_id])
@idea = @user.ideas.create(idea_params)
@idea.ima... |
class AnalyzerJob < Struct.new(:executing_id)
def perform
executing = Executing.find(executing_id)
executing.deliver
raise "analyzer job failed!"
end
end |
require 'test_helper'
class EmailSignup::FeedUrlValidatorTest < ActiveSupport::TestCase
def klass
EmailSignup::FeedUrlValidator
end
test 'handles badly formatted feed urls' do
refute klass.new('https://www.glue=latvia').valid?
refute klass.new('https://www.gov.uk/government]').valid?
end
test '... |
class NotifierMailer < ApplicationMailer
def visit_alert(message, to_email)
@content = message
mail(to:to_email, subject:"Visit Alert", body: @content, content_type: "text/html")
end
end |
# This file is copied to ~/spec when you run 'ruby script/generate rspec'
# from the project root directory.
ENV["RAILS_ENV"] ||= "test"
require File.expand_path("../../config/environment", __FILE__)
require "rspec/rails"
require "factory_girl_rails"
require "devise/test_helpers"
include Devise::TestHelpers
# Requir... |
module Expirable
extend ActiveSupport::Concern
if ENV['TEST_EMAILS']
TRANSITION_STATE_AFTER = {
should_verify: 0.minutes,
should_need_review: 10.minutes,
should_need_urgent_review: 19.minutes,
should_expire: 28.minutes,
should_archive: 37.minutes,
}.freeze
else
TRANSITI... |
module ApplicationHelper
def title(page_title)
content_for(:title) { page_title.to_s }
end
def yield_or_default(section, default = '')
content_for?(section) ? content_for(section) : default
end
def send_status(message)
case message
when "send_on_application" then 'submited'
when "send... |
require 'test_helper'
class CommentsHelperTest < ActionView::TestCase
test "approve_allowed? should return true" do
# Create inactive comment
comment = Comment.new
comment.summary = "Comment Summary"
comment.rating = 5
comment.product_id = products(:whiskey).id
comment.user_id = users(:user)... |
class AddForeignKey < ActiveRecord::Migration
def self.up
add_foreign_key :books, :authors, column: :aid, primary_key: :author_id
end
end
end
|
class FontSansForgetica < Formula
head "https://sansforgetica.rmit.edu.au/Common/Zips/Sans%20Forgetica.zip"
desc "Sans Forgetica"
homepage "https://sansforgetica.rmit.edu.au/"
def install
parent = File.dirname(Dir.pwd) != (ENV['HOMEBREW_TEMP'] || '/tmp') ? '../' : ''
(share/"fonts").install "#{parent}S... |
class UpsParser
require 'net/http'
require 'net/https'
def self.quotes(params,extra)
quote = Quote.new()
quote.company_name = 'UPS'
quote.price, quote.days= [200,2]#UpsParser.definePriceAndTime(params,extra)
quote
end
private
def self.definePriceAndTime(params,extra)
#forming a request to UPS server
... |
class RelationshipsController < ApplicationController
before_action :logged_in_user
def create
@outlet = Outlet.find(params[:followed_id])
current_user.follow(@outlet)
respond_to do |format|
format.html {redirect_to @outlet}
format.js
end
end
def destroy
@outlet = Relationship.... |
# encoding: utf-8
# Copyright (c) HongKong Stock Exchange and Clearing, Ltd.
# All rights reserved.
# Filename : browser.rb
# Project : Wabi
# Description: class browser file
# Class browser is the object encapsulating the Selenium web driver operations
class Browser
# browserName chrome|fi... |
require 'auctioneer'
describe Auctioneer do
let(:auctioneer) { Auctioneer.new }
let(:participant) { Participant.new(name: 'Foo') }
let(:item) { Item.new(name: 'Test', reserved_price: 20) }
let(:auction) { Auction.new(item) }
let(:library) { Library.new() }
describe 'performing actions' do
it 'a... |
class UserMailer < ApplicationMailer
def forget_my_password(user, password)
@user = user
@password = password
mail to: @user.email, subject: "Recuperacao de Senha"
end
end
|
class BookingsController < AuthorizationController
before_action :set_prof, only: [:show, :edit, :create, :new, :destroy]
def index
@bookings = Booking.all
end
def show
end
def new
@booking = Booking.new()
@booking.user_id = @current_user.id
end
def create
@booking = Booking.... |
class Novel < ActiveRecord::Base
belongs_to :author
has_many :ratings
validates :title, presence: true
end
|
class RepliesController < ApplicationController
def new
@post = Post.find(params[:post_id])
@reply = @post.replies.new
end
def create
@post = Post.find(params[:post_id])
@reply = @post.replies.new(reply_params)
@reply.user = current_user
if @reply.save
redirect_to post_path(@reply.p... |
module KnuckleCluster
module Scp
def initiate_scp(source:, destination:)
if source.start_with?('agent') || destination.start_with?('agent')
agent = select_agent
if source.start_with?('agent')
source = generate_agent_scp_string(source, agent)
elsif destination.sta... |
require "./lib/Lesson 4 Counting Elements/MissingInteger/missing_integer"
describe 'MissingInteger' do
describe 'Example Tests' do
it 'example (without minus) - [1, 3, 6, 4, 1, 2] to 5' do
expect(missing_integer([1, 3, 6, 4, 1, 2])).to eq 5
end
end
describe 'Correctness Tests' do
context 'extr... |
class AddRatesCountToPosts < ActiveRecord::Migration
def self.up
add_column :posts, :rates_count, :integer, :default=>0
end
def self.down
remove_column :posts, :rates_count
end
end
|
FactoryGirl.define do
factory :author do
name 'Ivan Ivanov'
end
end
|
module Boxes
# append the boxes views path to the cells view paths
Cell::Base.append_view_path([File.dirname(__FILE__), '..', '..', 'app', 'cells'].join('/'))
class << self
attr_writer :allows_creation
def allows_creation?
@allows_creation = true if @allows_creation.nil?
@allows_creation
... |
# 用于上传文件操作,获取文件目录,解压目录
class Common::FileManager
# root_folder_path:public目录,file_exts:允许的文件格式,file_max_size:文件最大的size,file_name:返回文件名,file_chinese_name:文件中文名
attr_accessor :root_folder_path,:file_exts, :file_max_size, :file_name,:file_chinese_name
def initialize(args={})
self.root_folder_path = args[:root_f... |
# frozen_string_literal: true
require 'common/models/base'
module Preneeds
class BurialForm < Preneeds::Base
attribute :application_status, String
attribute :preneed_attachments, Array[PreneedAttachmentHash]
attribute :has_currently_buried, String
attribute :sending_application, String, default: 've... |
require "shellwords"
require "open3"
module Sidekiq
module Ffmpeg
module Encoder
class Base
attr_reader :size, :video_bitrate, :audio_bitrate, :audio_sample_rate, :other_options
attr_reader :input_filename, :output_filename
attr_reader :on_progress, :on_complete
def initial... |
class Chef
class Resource
class CollectdPlugin < Chef::Resource
identity_attr :name
attr_reader :previous_options
attr_reader :resource_name
def initialize(name, run_context = nil)
super
@resource_name = :collectd_plugin
@previous_options = []
@options = ... |
class Author < ActiveRecord::Base
include Rules::HasRules
has_many :books
has_one :pen_name
has_rule_attributes({
last_name: {
name: 'author last name'
},
titles: {
name: 'titles of books associated with this author',
association: :books
},
pen_name: {
name: 'pen na... |
class MailPiecesController < ApplicationController
# GET /mail_pieces
# GET /mail_pieces.xml
def index
if is_logged_in?
@mail_pieces = MailPiece.all :joins => :mail_client, :order => "last_name ASC, usps_drop_date ASC"
respond_to do |format|
format.html # index.html.erb
format.xm... |
class AddIndexToLinks < ActiveRecord::Migration
def change
add_index :links, [:user_id, :store_id]
end
end
|
require_relative "./resource"
# Wrapper for {https://m2x.att.com/developer/documentation/v2/device M2X Data Streams} API.
class M2X::Client::Stream < M2X::Client::Resource
class << self
#
# Method for {https://m2x.att.com/developer/documentation/v2/device#View-Data-Stream View Data Streams} endpoint.
#
... |
# frozen_string_literal: true
module Oraykurt
VERSION = "0.1.1"
end
|
Quando("acessar o filtro de facilidades") do
@category.filters.greenify
@filters = @category.filters
end
Quando("selecionar facilidades {string}") do |facilidades|
@filters.selecionar_facilidades(facilidades)
@units_cells = @category.units
@units_cells.each do |unit|
facilidades.split(',').each do |facil... |
task :s3_old_data => :environment do
require 'logger'
start_time = Time.now
log = Logger.new('log/s3_old_data.log')
log.info('====================================================================')
log.info("Starting at #{start_time}")
log.info('===============================================================... |
#
# Cookbook Name:: init
# Recipe:: default
#
# yumの追加リポジトリ
bash "add remi epel" do
user "root"
not_if { ::File.exists?("/etc/yum.repos.d/remi.repo") }
code <<-EOS
rpm -ivh http://ftp.riken.jp/Linux/fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm
rpm -ivh http://rpms.famillecollet.com/enterprise/remi-re... |
FactoryGirl.define do
factory :role do |f|
f.name { Faker::Lorem.word }
f.description { Faker::Lorem.paragraph(2, false, 0) }
end
factory :invalid_role, parent: :role do |f|
f.name nil
end
factory :invalid_about_role, parent: :role do |f|
f.description { Faker::Lorem.paragraph(70, true, 30) ... |
class Model::Section::Footer < SitePrism::Section
element :legal_text, "#bc-footer-lower-left-bar"
elements :social_links, "#bc-social-media li a"
end |
class ImportLogDetail < ActiveRecord::Base
default_scope :order => "cast(model as signed) asc"
belongs_to :import
def self.make_order(collection)
collection.sort_by{ |element| [element.model.to_i] }
end
end
|
require 'formula'
# Use a mirror because of:
# http://lists.cairographics.org/archives/cairo/2012-September/023454.html
class Cairo < Formula
homepage 'http://cairographics.org/'
url 'http://cairographics.org/releases/cairo-1.12.6.tar.xz'
mirror 'http://ftp-nyc.osuosl.org/pub/gentoo/distfiles/cairo-1.12.6.tar.x... |
require 'test_helper'
class ValidatesAgainstStopforumspamTest < ActiveSupport::TestCase
setup do
Rails.env = 'production'
end
test "ham email" do
assert Comment.new(:email => 'surely@not-spam-but-ham.com').valid?
end
test "ham ip" do
assert Comment.new(:ip => '127.0.0.1').valid?
end
test "ham ... |
# == Schema Information
#
# Table name: file_objects
#
# id :bigint not null, primary key
# content_digest :string(255)
# disabled_at :datetime
# ext :string(255)
# file :string(255)
# fileable_type :string(255)
# filename :string(255)
# ... |
class SongSearch
SEARCH_URI = 'http://api.genius.com/search'
API_KEY = ENV['GENIUS_TOKEN']
def self.find_songs(terms)
uri = URI.parse("#{SEARCH_URI}?q=#{terms}&access_token=#{API_KEY}")
prepare_result(Net::HTTP.get_response(uri).body)
end
private
def self.parse_response(response)
JSON.parse(... |
#
# Ruby For Kids Projects 5: Simple Adventure
# Programmed By: Chris Haupt
# A random text adventure game
#
number_of_rooms_explored = 1
treasure_count = 0
damage_points = 5
escaped = false
monster = false
current_room = ""
puts "You are... |
class User < ApplicationRecord
rolify
after_create :assign_role
def assign_role
add_role(:user)
end
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable,... |
FactoryGirl.define do
factory :udp_packet, class: Communications::UDPPacket do
protocol_id { [Zlib.adler32('yugioh'.encode('ASCII-8BIT'))].pack('N') }
sequence_no 83
ack 67
previous_acks [53, 52, 50, 49, 48, 47, 46, 41, 39, 37, 35]
content_bytesize 13
content { 'payload data'.encode('ASCII-8BI... |
# frozen_string_literal: true
require 'bundler/setup'
require 'irb'
require 'dry-validation'
Dry::Validation.register_macro(:email_format) do
email_reg = /\A[\w+\-.]+@[a-z\d\-]+(\.[a-z\d\-]+)*\.[a-z]+\z/i
key.failure('not a valid email format') unless email_reg.match?(value)
end
class HanamiMasterySubscriptionCo... |
class LoaiSanPhamsController < ApplicationController
before_action :set_loai_san_pham, only: [:show]
# GET /loai_san_phams
# GET /loai_san_phams.json
def index
@san_phams = SanPham.all.paginate(page: params[:page], per_page: 3)
end
# GET /loai_san_phams/1
# GET /loai_san_phams/1.json
def show
en... |
module ProposalSteps
extend ActiveSupport::Concern
def delegate?(user)
delegates.include?(user)
end
def existing_step_for(user)
steps.find_by(user: user)
end
def existing_or_delegated_step_for(user)
where_clause = ProposalServices.new(self).sql_for_step_user_or_delegate
steps.find_by(wher... |
class MyMailer < ApplicationMailer
# Subject can be set in your I18n file at config/locales/en.yml
# with the following lookup:
# en.my_mailer.send.subject
#
def contact_me(message)
@greeting = "Hi"
@body = message.body
@email = message.email
@from = message.from
mail to: ENV['RECEIVER_E... |
class Answer < ActiveRecord::Base
has_many :attachments, as: :attachable, dependent: :destroy
belongs_to :question
belongs_to :user
validates :body, :user, presence: true
before_save :ensure_no_best_answers_left, if: ->() { best_changed? }
accepts_nested_attributes_for :attachments, allow_destroy: true
... |
class AddApprovalSubmissionNameToPosts < ActiveRecord::Migration[6.0]
def change
add_column :posts, :approved, :boolean, default: false
add_column :posts, :submitted_by_name, :string, default: ""
end
end
|
=begin
#===============================================================================
Title: Battle Use Limits
Author: Hime
Date: May 6, 2015
--------------------------------------------------------------------------------
** Change log
May 6, 2015
- improved error-checking to avoid cases where commands are s... |
class RemoveColumnDateOnlyFromEvents < ActiveRecord::Migration
def change
remove_column :events, :date_only
end
end
|
module CDI
module V1
module ServiceConcerns
module GameQuestionsAnswersParams
extend ActiveSupport::Concern
WHITELIST_ATTRIBUTES = [
:option_id,
:answer_body
]
VALID_GAMES = [
::GameQuiz,
::GamePoll,
::GameOpenQuestion,
... |
class ChangeDateToString < ActiveRecord::Migration[6.0]
def change
change_column :games, :release_date, :string
end
end
|
require 'spec_helper'
describe RunPal::CreateJoinReq do
before :each do
RunPal.db.clear_everything
end
it 'creates a new join request for a circle' do
user1 = RunPal.db.create_user({first_name:"Isaac", gender: 2, email: "isaac@smarty.com"})
user2 = RunPal.db.create_user({first_name:"Newton", gender... |
class AddEventColumnsToTables < ActiveRecord::Migration[6.1]
def change
add_column :evtcategories, :private, :boolean, default: false
add_column :events, :evt_link, :string
end
end
|
class AddTotalYellowsToMatch < ActiveRecord::Migration[5.1]
def change
add_column :matches, :home_team_total_yellows, :integer
add_column :matches, :home_team_total_reds, :integer
add_column :matches, :away_team_total_yellows, :integer
add_column :matches, :away_team_total_reds, :integer
remove_co... |
class AddPerletivoToTurmas < ActiveRecord::Migration
def self.up
add_column :turmas, :perletivo, :integer
end
def self.down
remove_column :turmas, :perletivo
end
end
|
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe OTWMailer do
describe 'requested' do
let(:otw) { create(:otw_training_user) }
let(:mail) { described_class.requested(otw) }
it 'renders the headers' do
expect(mail).to contain_mail_headers(
subject: 'On-the-Water training... |
=begin
#===============================================================================
Title: Synchronization Effects
Author: Hime
Date: Nov 13, 2013
URL: http://himeworks.com/2013/11/12/synchronization-effects/
--------------------------------------------------------------------------------
** Change log
Nov 13... |
class User < ApplicationRecord
has_many :sessions
has_many :grids, through: :sessions
end
|
class UsersController < ApplicationController
before_filter :authenticate_user!
def index
unless can? :manage, User
return redirect_to current_user, alert: "You aren't allowed to list users."
end
@superset = User.includes(:organizations).where.not(role: "Retired").order(last_name: :asc)
@unapproved, @u... |
# frozen_string_literal: true
module EVSS
module IntentToFile
class Configuration < EVSS::Configuration
def base_path
"#{Settings.evss.url}/wss-intenttofile-services-web/rest/intenttofile/v1"
end
def service_name
'EVSS/IntentToFile'
end
def mock_enabled?
Se... |
#!/usr/bin/env ruby
unless ARGV.all? { |arg| File.exist?(arg) } && !ARGV.empty?
$stderr.puts "usage: mated path1 [path2] [path3] ..."
exit(1)
end
require 'rubygems'
require 'sinatra'
require File.dirname(__FILE__) + '/../lib/vmware'
require File.dirname(__FILE__) + '/../lib/sinatra_hacks/localhost_only'
def mach... |
require 'logger'
module Modbuild
class Base
attr_accessor :package_name, :package_version, :package_summary, :package_description, :package_license, :package_license_uri
def initialize(module_directory)
@logger = Logger.new(STDERR)
@logger.level = Logger::FATAL
@module_location = module_d... |
class UpdateShoppingCart
class Result < Struct.new(:success, :shopping_cart)
def success?
success == true
end
end
def initialize(attributes:, shopping_cart:)
@attributes = attributes
@shopping_cart = shopping_cart
end
def call
@shopping_cart.attributes = @attributes
@shopping_... |
class ModifyEvents < ActiveRecord::Migration
def change
add_column :events, :recorded, :boolean,default:0
end
end
|
class Hero < ActiveRecord::Base
belongs_to :power
belongs_to :planet
end
# Hero >- Power
#A superhero can only have one power but a power can be utilized by many heroes
#Hero has_one power
#Hero: name, age, motto (A hero has one power, and therefor the power MUST belong to the hero)
#Power: hero_id, description (... |
class Magazine < ActiveRecord::Base
has_many :subscriptions
has_many :readers, through: :subscriptions
has_many :semiannual_subscribers, through: :subscriptions,
source: :reader,
conditions: ['lenght_in_issues = 6']
end
|
module SharedWorkforce
class EndPoint
def initialize(app = nil)
@app = app
end
def call(env)
if env["PATH_INFO"] =~ %r{^/#{callback_path}}
request = Rack::Request.new(env)
request.body.rewind
process_response(request.body.read)
else
@app.call(env) if @ap... |
class CreateReceivers < ActiveRecord::Migration
def change
create_table :receivers do |t|
t.string :name
t.string :bloodtype
t.string :donationtype
t.integer :units
t.string :timestart
t.string :timeend
t.string :timestart2
t.string :timeend2
t.string :days, a... |
require_relative './player.rb'
require_relative './board.rb'
class Game
WIN_CONDITIONS = [[1,2,3],[4,5,6],[7,8,9],[1,4,7],[2,5,8],[3,6,9],[1,5,9],[3,5,7]]
def initialize(name1, name2)
@player_1 = Player.new('X', name1)
@player_2 = Player.new('O', name2)
@board = Board.new
end
def start_game
f... |
# frozen_string_literal: true
require 'google/apis/gmail_v1'
require 'nkf'
class NippoSender
include Virtus.model
include ActiveModel::Validations
attribute :user, User
attribute :nippo, Nippo
validates :user, :nippo, presence: true
validates_each(:user) do |record, attr, value|
record.errors[attr] ... |
class AddColumnLinearBackgroundToSports < ActiveRecord::Migration[5.0]
def change
add_column :sports, :linear_background, :string
rename_column :users, :medical_certifate, :medical_certificate
rename_column :users, :medical_certifate_date, :medical_certificate_date
end
end
|
class UserMailer < ApplicationMailer
def welcome(user)
@user = user
mail(to: @user.email, subject: 'Hey')
end
def new_friend(user, friend)
@user = user
@friend = friend
@restaurant = Restaurant.find(@friend.recommendations.first.restaurant_id)
@picture = @restaurant.restaurant_pictures.f... |
require 'spec_helper'
describe Item do
it "returns number of available items on a specific date" do
@i1 = create(:complete_item, max_adults: 3, quantity: 2)
@booking = create(:booking, item: @i1, cart: create(:cart), adults: 1)
@line_item = create(:line_item, booking: @booking, booking_at: Date.today)
... |
class Pdm < Formula
desc "Modern Python package manager with PEP 582 support"
homepage "https://pdm.fming.dev"
url "https://files.pythonhosted.org/packages/74/4f/dcbbd585bb43a7210e97ee83b514c25060b4537022b082a3ce661def8bad/pdm-0.10.0.tar.gz"
sha256 "34300685359501666eb28862e6cee4197d1ccff909edd34b6670136dbb4609... |
# frozen_string_literal: true
class Location::Connection::Step < ApplicationRecord
belongs_to :step, class_name: '::Step'
belongs_to :location, class_name: '::Location'
end
|
class CommentsController < ApplicationController
before_action :ensure_signed_in
def all
render json: { comments: Comment.order("created_at").all }
end
def create
@post = Post.find(params[:post_id])
comment = current_user.comments.create!(comment_params)
render json: { comment: comment }
end... |
module CDI
module V1
module ServiceConcerns
module StudentClassParams
extend ActiveSupport::Concern
WHITELIST_ATTRIBUTES = [
:name
]
included do
def student_class_params
@student_class_params ||= filter_hash(attributes_hash, WHITELIST_ATTRIB... |
require_relative '../../../../../../libs/android/android_page_structure/common_parser/common_data/Element'
require_relative '../../../../../../libs/helpers/device/device'
class Button < Element
def initialize(*args)
super
@xpath = args.first[:xpath]
@parant = args.first[:parant]
@ip = @parant.ip
en... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.