text stringlengths 10 2.61M |
|---|
#mac_battery_cycles.rb
Facter.add(:mac_battery_cycles) do
confine :kernel => "Darwin"
setcode do
Facter::Util::Resolution.exec("/usr/sbin/ioreg -r -c 'AppleSmartBattery' | grep -w 'CycleCount' | awk '{print $3}'")
end
end |
require 'rails_helper'
RSpec.describe User, type: :model do
let(:user) {FactoryGirl.build :user}
it{ expect(user).to validate_presence_of(:email) }
it{ expect(user).to validate_presence_of(:password)}
it{ expect(user).to validate_uniqueness_of(:email)}
it{ expect(user).to validate_confirmation_of(:password... |
class AddColumnToUser < ActiveRecord::Migration[5.0]
def change
add_column :users, :corporate_id, :bigint
end
end
|
class NewDealAgency < ActiveRecord::Base
extend FriendlyId
friendly_id :name, use: [:slugged, :finders]
has_many :nda_relationships
has_many :records, through: :nda_relationships, source: :nda_relatable,
source_type: 'Record'
validates :name, presence: true, uniqueness: { case_sensitive: false }
vali... |
# A triangle is classified as follows:
# equilateral All 3 sides are of equal length
# isosceles 2 sides are of equal length, while the 3rd is different
# scalene All 3 sides are of different length
# To be a valid triangle, the sum of the lengths of the two shortest sides must be greater than the length of the longes... |
class RemoveCarabineroFromUcc < ActiveRecord::Migration[6.0]
def change
remove_column :uccs, :carabinero_id
end
end
|
require 'calabash-cucumber/calabash_steps'
def step_pause
sleep STEP_PAUSE
end
def row_exists? (row_name)
!query("tableViewCell marked:'#{row_name}'", :accessibilityIdentifier).empty?
end
def should_see_row (row_name)
unless row_exists? row_name
screenshot_and_raise "i do not see a row named #{row_name}"
... |
require 'magick/crop_resized'
require 'base64'
require 'digest/md5'
class Skeet < Sinatra::Base
configure do
IMGKit.configure do |config|
config.wkhtmltoimage = File.join(File.dirname(__FILE__), 'bin', 'wkhtmltoimage-amd64')
# config.wkhtmltoimage = File.join(File.dirname(__FILE__), 'bin', 'wkhtmltoi... |
$:.unshift File.join(File.dirname(__FILE__), "..", "lib")
require 'appscale_tools'
require 'rubygems'
require 'flexmock/test_unit'
class TestAppScaleRemoveApp < Test::Unit::TestCase
def setup
@key = "appscale"
@options = {"appname" => "boo", "keyname" => @key}
@secret = "booooo"
@fake_yaml = {
... |
class AddComplaintNoToDisciplineComplaints < ActiveRecord::Migration
def self.up
add_column :discipline_complaints, :complaint_no, :string
end
def self.down
remove_column :discipline_complaints, :complaint_no
end
end
|
class EmploymentHistory < ApplicationRecord
belongs_to :applicant
validates :employer, presence: true
validates :position, presence: true
validates :start_date, presence: true
with_options if: :not_current? do |c|
c.validates :end_date, presence: true
end
def not_current?
self.current? != true
... |
require './lib/vending_machine'
describe 'vending_machineテスト' do
let!(:vm) { VendingMachine.new }
describe "インスタンス作成のテスト" do
context "VendingMachineをインスタンス化させた際" do
it "@salesに0が代入されている" do
expect(vm.sales).to eq(0)
end
it "@balanceに0が代入されている" do
expect(vm.balance).to eq(0)
... |
require File.dirname(__FILE__) + '/../test_helper'
require "lib/bookrenter.rb"
class BookRenterTest < Test::Unit::TestCase
def setup
@b = BookRenter::Search
@isbn13 = "9780805371468"
@isbn10 = "080537146X"
@invalid_isbn = '0000'
@unknown_isbn = "0907861598"
end
def test_search_init
e... |
class DrinkingsController < ApplicationController
def show
@drinking = Sake.find(params[:id])
end
def new
@drinking = Drinking.new
@vote = Vote.new
end
def create
@vote = Vote.create(vote_params)
end
private
def vote_params
params.require(:vote).permit(:drinking_id, :score)... |
class Owner < ApplicationRecord
has_many :dogs, dependent: :destroy
has_secure_password
validates :email, presence: true, uniqueness: true
validates :username, presence: true, uniqueness: true
end
|
require_relative '../../lib/topographer/generators/helpers'
class TestClass
include Topographer::Generators::Helpers
end
describe Topographer::Generators::Helpers do
let(:helper) { TestClass.new }
describe '#underscore_name' do
it 'should return the snake case representation of input' do
expect(helpe... |
#encoding: utf-8
class MessageRecord < ActiveRecord::Base
has_many :send_messages
belongs_to :store
STATUS = {:NOMAL => 0, :SENDED => 1} # 0 未发送 1 已发送
end
|
class RemoveNpcShiftsFromCharacterEvents < ActiveRecord::Migration
def up
remove_reference :character_events, :npc_shift, foreign_key: true
end
def down
add_reference :character_events, :npc_shift, foreign_key: true
end
end |
module Sumac
class Objects
# Points to an {ExposedObject} that can be called by either application.
# @note only {#accept}, {#reject} and {#tentative} can be called on a tentative reference
# @api private
class Reference
extend Forwardable
# Create a new {Reference}.
# @param conne... |
FactoryGirl.define do
factory :club_night do
name "DnB Tuesdays"
start_time "7/21/2013 9:00pm"
end_time "7/22/2013 2:00am"
end
end |
# loop_example.rb
# DO NOT RUN THIS PROGRAM BECAUSE IT WILL CRASH THE COMPUTER
loop do
puts "This will keep printing until you hit Ctrl + c"
end
# The puts statement will continue to print out in the terminal until the
# user presses Ctrl + c to interupt the output.
|
class User < ActiveRecord::Base
# user's assocition has many articles
has_many :articles
# turn the email to lowercase (downcase) format before hitting the database
before_save{ self.email = email.downcase}
# ensure that username will be present, unique, and well sized
validates :username, presence: true... |
# Preview at http://;pca;jpst:3000/rails/mailers/user_mailer
class UserMailerPreview < ActionMailer::Preview
def contact_form
UserMailer.contact_form("john@example.com", "John", "123456789", "Hello Word")
end
end
|
require 'rails_helper'
RSpec.describe LiabilityAccount, type: :model do
before(:each) do
@organization = Organization.create(name: "NewOrg")
@organization.liability_accounts.create(name: "Account", number: 123)
@account = @organization.liability_accounts.first
end
context "credits" do
it "can ... |
require 'redis'
require 'pub_sub/base_redis_service'
require 'pub_sub/messages_publisher'
module PubSub
autoload :BaseRedisService, 'pub_sub/base_redis_service'
autoload :MessagesPublisher, 'pub_sub/messages_publisher'
mattr_accessor :redis_host,
:redis_port
end |
module Eshealth
class Alertfactory
def self.build(type,options={})
case type
when 'EmailAlert' then Emailalert.new(options)
when 'FakeAlert' then FakeAlert.new(options)
end
end
def trigger(options={})
raise "Factory must implement a trigger method"
end
def clea... |
class Xz < BuildDependency
desc "General-purpose data compression with high compression ratio"
homepage "http://tukaani.org/xz/"
url "http://tukaani.org/xz/xz-${version}.tar.xz"
release version: '5.2.3', crystax_version: 3
def build_for_platform(platform, release, options, _host_dep_dirs, _target_dep_dirs)... |
FactoryGirl.define do
factory :user do
id 1
email "mama@mail.ru"
password "123456789"
password_confirmation "123456789"
first_name "Василий"
last_name "Иванов"
patronymic "Сергеевич"
phone_number "+375-29-202-03-27"
factory :employee do
after(:create) { |user| user.add_role(... |
require 'rails_helper'
RSpec.feature "UpdateCars", type: :feature do
it "should update a car with a logged in user" do
login_as create( :user ), scope: :user
car = create(:car)
visit '/cars/1/edit'
fill_in "car_name", with: "Toyota"
fill_in "car_description", with: "Lorem Ipsum"
select('B', :... |
require 'spec_helper'
describe GemConfig::Rules do
subject { GemConfig::Rules.new }
describe '#has' do
it 'sets a rule' do
subject.has :foo
expect(subject).to have_key(:foo)
end
it 'sets the parameters of a rule' do
params = { classes: String, values: %w(foo bar), default: 'foo' }
... |
# frozen_string_literal: true
module Hako
VERSION = '0.18.1'
end
|
require 'rails_helper'
RSpec.describe Project, type: :model do
let(:hub) { create(:hub) }
let(:participant) { create(:participant, hub_id: hub.id) }
let(:participant2) { create(:participant, hub_id: hub.id) }
let(:site1) { create(:site, participant_id: participant.id) }
let(:project) { site1.projects.create(... |
class Member < ApplicationRecord
has_many :party_members, dependent: :destroy
has_many :parties, through: :party_members
has_many :role, through: :party_members
validates :name, presence: true
end
|
# frozen_string_literal: true
require 'etc'
require 'logging'
require 'pathname'
require 'bolt/boltdir'
require 'bolt/logger'
require 'bolt/transport/ssh'
require 'bolt/transport/winrm'
require 'bolt/transport/orch'
require 'bolt/transport/local'
require 'bolt/transport/local_windows'
require 'bolt/transport/docker'
r... |
require("minitest/autorun")
require("minitest/rg")
require_relative("../drink")
class DrinkTest < MiniTest::Test
def setup
@cosmo = Drink.new("Cosmopolitan", 10)
end
def test_alcohol_units
assert_equal(2, @cosmo.alcohol_units)
end
end
|
# frozen_string_literal: true
module BPS
module PDF
class Receipt
module TransactionInfo
# This module defines no public methods.
def _; end
private
def transaction_info(payment)
transaction_details(payment)
purchase_subject(payment)
end
... |
# encoding: utf-8
# Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
module MobileCenterApi
module Models
#
# Test Cloud File Hash
# Hash, type, path and byte range of a file that is required in test run... |
require 'test_helper'
class Page < ActiveRecord::Base
nestable :strategy => :path, :scope => :site_id
end
class PathTest < Test::Unit::TestCase
def setup
setup_tables
@root = Page.create!
@root_2 = Page.create!
@child = Page.create! :parent_id => @root.id
@child_2 = Page.create! :parent_id =>... |
class MomentumCms::Document < ActiveRecord::Base
# == MomentumCms ==========================================================
include MomentumCms::BelongsToSite
self.table_name = 'momentum_cms_documents'
# == Constants ============================================================
# == Relationships =========... |
require 'spec_helper'
describe 'numix_gtk_theme' do
on_supported_os.each do |os, facts|
context "on #{os}" do
let :facts do
facts
end
context 'install with defaults' do
let :facts do
facts.merge(
desktop: { type: 'cinnamon' }
)
end
... |
class CreateEventFeeItems < ActiveRecord::Migration
def self.up
create_table :event_fee_items do |t|
t.string :name
t.float :fee1,:default=>0
t.float :fee2,:default=>0
t.float :fee3,:default=>0
t.integer :event_fee_id
t.datetime :created_at
end
end
def self.down
dr... |
class HomeController < BaseController
def index
blog = BloggerService.new
@posts = blog.get_posts
end
end
|
require 'PropertyConstraint.rb'
require 'land_property_constraint'
class LandProperty < ActiveRecord::Base
has_one :address
has_one :property_location
has_many :photos
has_many :interested_people
validates :lease_type, presence: true,
numericality: { only_integer: true, greater_than_or_equal_to: PropertyCon... |
class AddTurnsTable < ActiveRecord::Migration[5.1]
def change
create_table :turns do |t|
t.integer :game_id, null: false
t.integer :player_id, null: false
t.integer :roll_id
t.integer :start_space_id
t.integer :end_space_id
t.boolean :completed, null: false, default: false
... |
class Conversation < ActiveRecord::Base
has_many :conversation_users, dependent: :destroy
has_many :messages, dependent: :destroy
has_many :users, through: :conversation_users
default_scope { order('created_at desc') }
def add_user(user)
ConversationUser.create(conversation_id: self.id, user_id: user.id... |
class UpdateEvents < ActiveRecord::Migration[5.0]
def change
remove_column :events, :start_date, :string
remove_column :events, :end_date, :string
remove_column :events, :start_time, :string
remove_column :events, :end_time, :string
add_column :events, :start, :datetime
add_column :events, :en... |
# == Schema Information
#
# Table name: ivs
#
# id :integer not null, primary key
# hp :integer
# attack :integer
# defense :integer
# sp_attack :integer
# sp_defense :integer
# speed :integer
# pokemon_id :integer
#
# pokemon_id :integer
# hp :integer
# att... |
require_relative '../acceptance_helper'
feature 'OAuth' do
before { OmniAuth.config.test_mode = true }
before { visit root_path }
describe 'Sign_in Twitter' do
before { mock_auth_hash(:twitter) }
scenario 'successfuly' do
click_on 'Sign in with Twitter'
expect(page).to have_content "Для за... |
feature 'Enter Player Names' do
scenario 'players can enter their names and submit them' do
visit('/')
fill_in :player_1_name, with: 'Finn'
fill_in :player_2_name, with: 'Muhammad'
click_button 'Submit'
save_and_open_page
expect(page).to have_content 'Finn vs. Muhammad'
end
end
|
class Api::ContactsController < ApplicationController
before_action :authenticate_user!
def index
@contacts = current_user.contacts.all
render json: @contacts.order(:name)
end
def show
@contact = current_user.contacts.find(params[:id])
render json: @contact
end
... |
class CreateTallyAccounts < ActiveRecord::Migration
def self.up
create_table :tally_accounts do |t|
t.references :school
t.string :account_name
t.timestamps
end
end
def self.down
drop_table :tally_accounts
end
end
|
module FootballProphesier
class Gameday
attr_accessor :games,
:value
def initialize(value)
@value = value
end
end
end |
module Intent
class ActivateAbilitySelf < ActivateSelf
def take_action
super
@entity.broadcast_self Entity::Status.tick(@target, StatusTick::ACTIVATED)
end
end
end
|
class DiscountValidator < ActiveModel::Validator
def validate(record)
if record.price.present? && record.discount_price.present? && (record.price < record.discount_price)
record.errors[:price] << ' must be greator than discount price'
end
end
end |
class MyCar
def initialize(year, model, color)
@year = year
@model = model
@color = color
@current_speed = 0
end
def speed_up(number)
@current_speed += number
puts "You push the gas and accelerate #{number} mph."
end
def brake(number)
@current_speed -= number
puts "You push th... |
class User < ActiveRecord::Base
has_many :teams, through: :members
belongs_to :project
has_many :events
has_many :todos
has_many :comments
end
|
module JSONHelpers
%w(get post delete option).each do |method|
define_method(method) do |url, params={}|
super(url, params.to_json,
{ "CONTENT_TYPE" => "application/json"})
end
end
end
|
# # Input Format
# A single line which contains the input string.
#
# Constraints
# 1≤1≤ length of string ≤105≤105
# Each character of the string is a lowercase English letter.
#
# Output Format
# A single line which contains YES or NO in if the input an anagram that's a palindrome uppercase.
string = gets.chomp
no_do... |
class AddCardIdComplexIndexToCardUser < ActiveRecord::Migration[6.0]
def change
add_index :card_users, [:card_id, :e_no, :result_no, :generate_no, :party], :unique => false, :name => 'cardid_and_eno_and_resultno_and_party'
end
end
|
module Api
class FavoritesController < ApiController
before_action :require_signed_in!
def create
@favorite = Favorite.new(favorite_params)
if @favorite.save
render json: @favorite
else
render json: @favorite.errors.full_messages, status: :unprocessable_entity
end
... |
module SanitizedFilterable
extend ActiveSupport::Concern
included do
# Model.sanitized_filter(name: "toto-le_he&ro^s")
# is equivalent to
# Model.where(
# "lower(regexp_replace(name, '[^[:alnum:]]', '', 'g')) = ?",
# "toto-le_he&ro^s".downcase.gsub(/[^[:alnum:]]/,'')
# )
scope :... |
#!/usr/bin/env ruby
require 'yaml'
require 'workato-connector-sdk'
class Decryptor
attr_reader :key_path, :encrypted_file_path, :encrypted_config
def initialize(path:, options: {})
@encrypted_file_path = path
@key_path = options[:key] || Workato::Connector::Sdk::DEFAULT_MASTER_KEY_PATH
@encrypted_con... |
json.wechat_account
json.partial! "api/v1/wechat_accounts/wechat_account", wechat_account: @wechat_account
end
|
require 'messenger/sse'
class CoreController < ApplicationController
include ActionController::Live
def index
@title = "Home"
end
def about_the_club
@title = "About the Club"
end
def how_to_join
@title = "How to Join"
end
def what_you_need
@title = "What You Need"
end
def progr... |
test_case_one = {
'input': {
"machine": {
"outlets": {
"count_n": 3
},
"total_items_quantity": {
"hot_water": 300,
"hot_milk": 500,
"ginger_syrup": 100,
"sugar_syrup": 100,
"tea_leaves_syrup": 100
},
"beverages": {
"hot_tea": {
... |
# Read about factories at https://github.com/thoughtbot/factory_girl
FactoryGirl.define do
factory :task_item do
name "My Ultimate Test Task Item"
description "A test description for my ultimate task item"
end
end
|
# frozen_string_literal: true
module Decidim
module Opinions
# A command with all the business logic when a user publishes a collaborative_draft.
class PublishCollaborativeDraft < Rectify::Command
# Public: Initializes the command.
#
# collaborative_draft - The collaborative_draft to publis... |
#n=2 eggs and a building with k=36 floors.
#Suppose that we wish to know which stories in a 36-story building are safe to drop eggs from, and which will cause the eggs to break on landing
#An egg that survives a fall can be used again
#A broken egg must be discarded
#The effect of a fall is the same for all eggs
#If an... |
require 'declarative_authorization/maintenance'
class AddRywebInfoToCustomer < ActiveRecord::Migration
def self.up
add_column :customers, :home_page, :string
add_column :customers, :ryweb_active, :integer, :default => 0
end
def self.down
remove_column :customers, :ryweb_active
remove_column :cus... |
# -*- coding: utf-8 -*-
class CarsController < InheritedResources::Base
before_filter :authenticate_user!
before_filter :authenticate_owner, :only => [:show, :edit, :update, :destroy]
# GET /cars
# GET /cars.json
def index
@title += "#{t('activerecord.models.car')}#{t('link.index')}"
if params[:car]
... |
class CreateBackupdormers < ActiveRecord::Migration
def self.up
create_table :backupdormers do |t|
t.string :studentid
t.string :name
t.string :sex
t.string :area
t.string :telphone
t.string :email
t.integer :dorm_no
t.integer :room_no
t.integer :ishead
... |
class DonorsController < ApplicationController
before_action :set_donor, only: [:show, :edit, :update]
def index
@donors = Donor.all
end
def new
@donor = Donor.new
end
def create
@donor = Donor.new(donor_params)
if @donor.save
flash[:success] = "Successfully created donor profile"... |
# frozen_string_literal: true
require 'bolt/puppetdb/client'
require 'bolt/puppetdb/config'
module BoltSpec
module PuppetDB
def pdb_conf
spec_dir = File.join(__dir__, '..', '..')
ssl_dir = File.join(spec_dir, 'fixtures', 'ssl')
{
'cert' => File.join(ssl_dir, "cert.pem"),
'key' ... |
class OnlyAllowMergeIfAllDiscussionsAreResolved < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
def up
add_column_with_default(:projects,
:only_allow_merge_if_all_discussions_are_resolved,
... |
# encoding: UTF-8
module PlaceholderParser
class Parser
class << self
def identify(string)
extract_pieces(string).map { |match| new(match) }
end
def extract(string)
extract_pieces(string).map(&:join)
end
protected
def extract_pieces(string)
string.sc... |
#!/usr/bin/env ruby
$:.unshift File.dirname(__FILE__) + '/../ext'
$:.unshift File.dirname(__FILE__) + '/../lib'
require 'bundler/setup'
require 'sqlite3'
require 'do_sqlite3'
require 'swift-db-sqlite3'
require 'benchmark'
dbs = {
do_sqlite3: DataObjects::Connection.new("sqlite3://:memory:"),
sqlite3: SQLite3:... |
# frozen_string_literal: true
require 'test_helper'
module Vedeu
module Input
describe Raw do
let(:described) { Vedeu::Input::Raw }
let(:instance) { described.new }
describe '#initialize' do
it { instance.must_be_instance_of(described) }
end
describe '.read' do
... |
require "rails_helper"
RSpec.describe Apps::IntegrationsController, type: :routing do
describe "routing" do
let(:app) { create(:app) }
let(:integration) { create(:integration, app: app) }
it "routes to #index" do
expect(:get => "#{api_prefix}/apps/#{app.name}/integrations").to \
route_to("... |
class Listing < ActiveRecord::Base
geocoded_by :where_is
after_validation :geocode
before_save :find_country_code
before_save :get_fullname
belongs_to :company
belongs_to :user
validates_uniqueness_of :user_id
def where_is
if self.state != nil && self.state != ""
[street, state, country].co... |
class UsersController < ApplicationController
before_filter :authenticate_user!
def show
@users=User.find(params[:id])
end
def index
if current_user.Admin?
@users= User.paginate(:page => params[:page], :per_page => 5).order("created_at DESC")
render 'list'
else
@user=User.f... |
#
# hermeneutics/html.rb -- smart HTML generation
#
require "hermeneutics/escape"
require "hermeneutics/contents"
module Hermeneutics
# = Example
#
# require "hermeneutics/color"
# require "hermeneutics/html"
#
# class MyHtml < Hermeneutics::Html
# def build
# html {
# head {
# ... |
class WizardspellSerializer < ActiveModel::Serializer
attributes :wizard_id, :spell_id
end
|
def salesforceable_as (object_name, client_id: '', client_secret: '', fields_mapping: {})
send :define_method, 'is_synced_with_salesforce?' do
# Specific methods to ActiveRecord objects
self.salesforce_id != nil
end
send :define_method, 'save_on_salesforce!' do |refresh_token, instance_url|
co... |
# frozen_string_literal: true
class Material < ApplicationRecord
include Slug
extend ApiHandling
expose_api :id, :name, :url, :event_id, :user_id
validates :name, :url, :event, presence: true
validates_url :url, url: true, message: 'not a valid URL'
belongs_to :user
belongs_to :event
belongs_to :topi... |
require 'socket'
require 'date'
class LinksController < ApplicationController
#If i remove this line even the authentication will work once i have been removed the commented line from routes
before_filter :authenticate_user!, only: [:new,:create]
before_action :get_location
respond_to :html, :js
attr_reader... |
class Category < ActiveRecord::Base
has_many :product_relationship, class_name: "ProductCategory", foreign_key: "category_id", dependent: :destroy
has_many :products, through: :product_relationship, source: :product
end
|
class ProductCompInfoChanged < ApplicationMailer
def changed_email(user, change_hash)
@change_hash = change_hash
mail(to: user.email, subject: "The following information has changed")
end
end
|
class Post < ActiveRecord::Base
belongs_to :user
belongs_to :category
belongs_to :status
has_many :images, dependent: :destroy
has_many :comments, dependent: :destroy
default_scope { order('updated_at DESC') }
end
|
module OAuth
class Google < Base
TOKEN_ENDPOINT = 'https://oauth2.googleapis.com/token'.freeze
PROFILE_ENDPOINT = 'https://www.googleapis.com/oauth2/v1/userinfo'.freeze
AUTHORIZATION_ENDPOINT = 'https://accounts.google.com/o/oauth2/v2/auth'.freeze
class << self
def authorization_u... |
##
# This module requires Metasploit: http://metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
##
require 'msf/core'
class Metasploit4 < Msf::Exploit::Remote
Rank = ExcellentRanking
include Msf::Exploit::Remote::HttpClient
def initialize(info = {})
super(update_inf... |
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
describe "/city_global_locations/index.html.erb" do
include CityGlobalLocationsHelper
before(:each) do
assigns[:city_global_locations] = [
stub_model(CityGlobalLocation,
:country => "value for country",
:city => "v... |
class UsersController < ApplicationController
before_action :authenticate_user!
before_action :set_user, only: [:profile]
def index
@posts = Post.active
@comment = Comment.new
following_id = Follower.where(follower_id: current_user.id).map(&:following_id)
following_id <<... |
class Bot
attr_accessor :name
def initialize name = ''
@name = name.empty? ? ('Bot' + (rand*1e6).to_i.to_s) : name
end
def register say
@say = say
end
def say message
@say.call(message)
end
def hear message
end
end |
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
def current_user
@current_user ||= User.find(session[:user_id]) if session[:user_id]
end
def current_user_latitude
session[:user_latitude]
end
def current_user_longitude
session[:user_longitude]
end
... |
# frozen_string_literal: true
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
Gem::Specification.new do |spec|
spec.name = 'jekyll-prettier'
spec.version = '0.0.0'
spec.summary = 'Jekyll formatting plugin'
spec.description = 'Jekyll (Ru... |
class ScoresController < ApplicationController
def new
@title = "Enter your score"
@score = Score.new
end
def create
@score = Score.new
result = @score.calculate(params[:score][:score_string])
unless params[:score][:score_string] == ''
flash[:success] = "Your score is #{result}"
... |
class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
def index
# Will persist all flash values.
flash.keep
# You can also use a key to keep only some kind of value.
# flash.keep(:notice)
re... |
class RemoveControllerFromControllerAction < ActiveRecord::Migration
def change
remove_column :controller_actions, :controller, :string
end
end
|
class Event < ActiveRecord::Base
belongs_to :user
has_many :participants, dependent: :destroy
has_many :comments, dependent: :destroy
has_many :votes
validates :body, presence: true
validates :title, presence: true
#validates :end_time, presence: true
#validates :start_time, presence: true
default_scop... |
class EmployeesController < ApplicationController
def index
@employee = Employee.all
render :index
end
def new
@employee = Employee.new
render :new
end
def create
@employee = Employee.new(employee_params)
if (@employee.save)
redirect_to "/"
end
end
def edit
@employee = Employee.find(... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.