text stringlengths 10 2.61M |
|---|
class V1::CommentsController < ApplicationController
def create
@comment = current_user.comments.create!(comment_params)
json_response(@comment, :created)
end
private
def comment_params
params.permit(:ticket_id, :comment).merge(user_id: current_user.id)
end
end
|
require 'rails_helper'
RSpec.describe Micropost, type: :model do
before(:each) do
@user = FactoryGirl.create(:user)
@attr = { :content => "Contenu du message" }
end
describe "création d'un message" do
it {@user.microposts.create!(@attr)}
end
describe "associations avec l'utilisateur" do
... |
# frozen_string_literal: true
# this is the model
# that takes care of all actions related to managers table
class Manager < ApplicationRecord
validates :first_name, presence: true
validates :last_name, presence: true
validates :age, presence: true
belongs_to :team
end
|
# frozen_string_literal: true
class BranchOwner < ApplicationRecord
belongs_to :user
belongs_to :branch
end
|
require 'JsonMaker'
class Thinker
# def initialize
# @jsonMaker = JsonMaker.new
# @messageFactory = MessageFactory.new
# end
def think(message)
# 도움말 메세지
helpResult = thinkHelpMessage(message)
unless helpResult.nil?
return helpResult
end
# 이스터 에그
easterEggResult = ... |
Puppet::Functions.create_function(:'profile::loaddata') do
dispatch :getdata do
param 'String', :file
end
def getdata(file)
lf = YAML.load_file(file)
lf
end
end
|
DeviseTest::Application.routes.draw do
devise_for :admins
devise_for :accounts
resources :stores do
resources :accounts
end
root "stores#index"
end
|
module Spark
class Grapher
TICKS = %w{ ▁ ▂ ▃ ▄ ▅ ▆ ▇ █ }.freeze
def self.render(numbers)
Spark::Grapher.new.render(numbers)
end
def render(numbers)
@numbers = numbers
normalize_numbers
numbers_to_bars
end
private
attr_reader :numbers
def normalize_numbers
... |
class StudiosController < ApplicationController
before_action :store_location, :find_studio, only: [ :show, :destroy, :edit, :update]
skip_before_action :authenticate_user!, only: [ :index, :show, :daw, :audio_interface, :micro, :monitor]
def index
@studios = policy_scope(Studio).order(created_at: :desc)
... |
require './storm'
require 'json'
class EventCountBolt < Storm::Bolt
def process tup
event = JSON.parse tup.values[0]
event_name = event['name']
count = count_event event_name
emit [event_name, count]
end
private
def count_event event_name
counter[event_name] = 0 unless counter.has_key? e... |
require 'test_helper'
describe Recipe do
it "Can be instantiated with id, name, image, url, ingredients, servings, and total nutrients" do
id = "id"
name = "name"
image = "image"
url = "url"
ingredients = "ingredients"
servings = "servings"
recipe = Recipe.new(id, name, image, url, ingre... |
namespace :qameha do
# usage : rake --trace qameha:update_docfile_path RAILS_ENV=production/staging
# changes the path of the files from
# /home/spock/shared/docfiles/....
# to
# /home/spock/qameha.net/docfiles/.... for production
# /home/spock/qameha.info/docfiles/.... for staging
task :update_docfi... |
module InstanceFactory
def instance_factory(object_name, class_name = nil)
set_class_name(object_name, class_name)
return defined_var? ? get_var : set_var
end
def instance_factory_clear!
InstanceFactoryVariables.clear!
end
private
def defined_var?
InstanceFactoryVariables.class_variable_... |
class Ability
include CanCan::Ability
def initialize(user)
user ||= User.new # guest user
if user.role? :vip
can :index, :all
else user.role? :normal
end
end
end |
# Project boxing for building vagrant boxes
# Please use http://buildr.apache.org/
require 'time'
# Helpers for project definition
my_version = 'LATEST.' << Time.now.utc.iso8601(3).gsub(/\W/, '')
my_layout = Layout.new
my_layout[:target] = File.expand_path("../../upload",__FILE__)
# Start project and build goals defi... |
class Ct1 < ActiveRecord::Base
self.table_name = "ct1"
self.primary_key = "ct1id"
has_many :ctgxctxs
end
|
class ActivityAssessment < ActiveRecord::Base
belongs_to :assessment_group_batch
belongs_to :assessment_activity_profile
belongs_to :assessment_activity
has_many :assessment_marks, :as => :assessment, :dependent => :destroy
before_save :check_marks
before_save :check_status_change, :if=> Proc.new{|as| as... |
require 'test_helper'
class DamagesControllerTest < ActionDispatch::IntegrationTest
setup do
@damage = damages(:one)
end
test "should get index" do
get damages_url
assert_response :success
end
test "should get new" do
get new_damage_url
assert_response :success
end
test "should cre... |
class AdminAnswerController < ApplicationController
def index
rows = []
@answers = Answer.find(:all, :conditions => ["question_id = ?", params[:question_id]])
@answers.each{|answer|
rows << {
:id => answer.id,
:answer_text => answer.answer_text,
:is_correct_answer => ... |
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup).
#
# Examples:
#
# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
# Ch... |
require 'prime'
# Return the smallest positive number that is evenly divisible by all elements in a given array
def smallest_multiple(values)
max = values.reduce(:*)
min_step = values.select { |v| v.prime? }.reduce(:*)
min = min_step
(min..max).step(min).find { |n|
values.select { |v| n % v != 0 }.empty?
... |
# encoding: utf-8
require_relative "stepping_piece.rb"
class King < SteppingPiece
def steps
[[0,1], [0,-1], [1,0], [-1,0]] +
[[1,1], [1,-1], [-1,1], [-1,-1]]
end
def white_symbol
"♔"
end
def black_symbol
"♚"
end
end |
require 'digest/md5'
require 'active_record'
require 'cxbrank/const'
module CxbRank
class User < ActiveRecord::Base
validates_presence_of :name, :message => ERRORS[ERROR_USERNAME_IS_UNINPUTED]
validates_presence_of :password, :message => ERRORS[ERROR_PASSWORD1_IS_UNINPUTED]
validates_confirmation_of :pas... |
#
# [1, 2, 95, 96, 97] - 95
# [8, 9, 98, 99, 100] - 98
# [3, 4, 5, 6, 7] - 5
# Overall median is 8, but median of medians is 95
# Measure middle of quintiles and pass those up to central
# server. In this case all the numbers would be passed up
# and the overall median would be found. For a larger set of
# n... |
class JournalEntry < ApplicationRecord
POST_TYPES = ["DR", "CR"]
belongs_to :accounting_code
belongs_to :accounting_entry
validates :amount, presence: true, numericality: true
validates :post_type, presence: true, inclusion: { in: POST_TYPES }
def is_debit?
self.post_type == "DR"
end
def is_cre... |
Rails.application.routes.draw do
devise_for :users
get 'articles/index'
get 'profile', to: 'profile#index', as: 'profile'
resources :comments do
resources :articles
end
resources :articles do
resources :categories
end
root 'articles#index'
# For details on the DSL available within this fil... |
Rails.application.routes.draw do
root to: 'user#index'
post '/users/login', to: 'users#login', defaults: { format: :json }
post '/users/setting/update_avatar', to: 'users#update_avatar', defaults: { format: :json }
resources :users, defaults: { format: :json }
post '/posts', to: 'posts#create', defaults: {f... |
class Course < ActiveRecord::Base
belongs_to :college
belongs_to :examination
has_many :examiners
validates :title, presence: true, uniqueness: true
end
|
require "paperclip/matchers"
describe Attachment do
include Paperclip::Shoulda::Matchers
describe "Associations" do
it { should belong_to(:proposal) }
it { should belong_to(:user) }
end
describe "Validations" do
it { should have_attached_file(:file) }
it { should validate_presence_of(:file) }... |
module SqlPostgres
# This is a special connection that is used when there isn't a real
# one. Any attempt to use it causes a NoConnection exception.
class NullConnection
# Raises NoConnection
def method_missing(method, *args)
raise NoConnection
end
end
end
# Local Variables:
# tab-widt... |
# Definition for singly-linked list.
# class ListNode
# attr_accessor :val, :next
# def initialize(val)
# @val = val
# @next = nil
# end
# end
# @param {ListNode} l1
# @param {ListNode} l2
# @return {ListNode}
def add_two_numbers(l1, l2)
str1 = l1.val.to_s
str2 = l2.val.to_s
while l... |
require "test_helper"
class ConcertTest < ActiveSupport::TestCase
test "concert with a published date are published" do
published_concert_1 = create(:concert, published_at: 2.weeks.ago)
published_concert_2 = create(:concert, published_at: 1.week.ago)
unpublished_concert = create(:concert, published_at: ... |
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "genebean/centos-7-nocm"
config.vm.define "pe" do |pe|
pe.vm.hostname = "pe.localdomain"
pe.vm.network "private_network", ip: "172.28.128.22"
pe.vm.network "forwarded_port", guest: 80, host: 8080
pe.vm.ne... |
RSpec.describe Configature::Directory do
context 'can properly enumerate parent directories' do
it 'on a POSIX system' do
path = '/a/very/long/path/to/something'
dirs = Configature::Directory.parents(path).to_a
expect(dirs).to eq(%w[
/a/very/long/path/to/something
/a/very/long/... |
# frozen_string_literal: true
module Concerns
module Chapterable # rubocop:disable Metrics/ModuleLength
extend ActiveSupport::Concern
CHAPTERS = {
al: 'Alabama',
ak: 'Alaska',
ar: 'Arkansas',
az: 'Arizona',
socal: 'Southern California',
norcal: 'Northern California',
... |
require 'rubygems'
require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'
require 'rake/packagetask'
require 'rake/gempackagetask'
require 'rake/contrib/rubyforgepublisher'
require 'lib/rubicus'
PKG_NAME = "rubicus"
PKG_VERSION = Rubicus::VERSION
PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
PKG_FILES = FileL... |
class Page < ActiveRecord::Base
def self.add_page page, mnemo, permanent
page_attributes = { html: page, mnemo: mnemo, permanent: permanent }
last_page = self.last || self.create
if last_page.permanent
self.create page_attributes
else
last_page.update_attributes page_attributes
end
... |
class Species < ActiveRecord::Base
attr_accessible :name
has_many :animals
end
|
require 'rails_helper'
feature 'Identity views protocols', js: true do
scenario 'and sees Protocols for which they are a Fulfillment Provider for' do
given_i_am_a_fulfillment_provider_for_a_protocol
when_i_visit_the_protocols_page
then_i_should_see_protocols_for_which_i_am_a_filfillment_provider
end
... |
class CreateNameValues < ActiveRecord::Migration
def self.up
create_table :name_values, :force => true do |t|
t.string :name,:limit=>500
t.text :value
end
sql = ActiveRecord::Base.connection()
sql.begin_db_transaction
File.open("./db/sql/name_values.sql") do |file|
while l... |
module Spree::Chimpy
module Workers
class Resque
delegate :log, to: Spree::Chimpy
QUEUE = :default
@queue = QUEUE
def self.perform(payload)
Spree::Chimpy.perform(payload.with_indifferent_access)
end
end
end
end
|
class Maicoin < ApplicationRecord
include CalculationConcern
validates_presence_of :kind, :buy, :sell, :avg
end
|
#
# Copyright (c) 2006 The Trustees of Indiana University and Indiana
# University Research and Technology
# Corporation. All rights reserved.
# Copyright (c) 2006-2020 Cisco Systems, Inc. All rights reserved.
# $COPYRIGHT$
#
# Additional copyrights may follow
#
# $HEADER$
#####... |
class CardLabel < ActiveRecord::Base
attr_accessible :card_id, :label_id
belongs_to :card
belongs_to :label
end
|
feature 'posting twits to tweeter' do
let(:content) { 'build the wall, the best walls, the best, trust me' }
scenario 'user is logged in and posts tweet' do
sign_up
visit '/'
click_link 'compose twit'
expect(current_path).to eq '/twit/new'
fill_in :content, with: content
click_button 'twit'... |
Fabricator(:song) do
name { Faker::Lorem.word }
slug { Faker::Lorem.word }
artist { Faker::Name.name }
tempo { Faker::Number.number(3) }
length { Faker::Number.number(3) }
chart { Faker::Internet.url }
mp3 { Faker::Internet.url }
end
|
class Admin::FoldersController < ApplicationController
before_action :disable_turbolinks_cache, only: %i[destroy]
def destroy
@folder = Folder.find(params[:id])
authorize([:admin, @folder])
@folder.destroy
redirect_to folders_path, { flash: { validation_message: true, message: "Le dossier a bien ét... |
class BettingTicketsController < ApplicationController
before_action :authenticate_end_user!, except: [:show]
before_action :correct_end_user, only: [:edit]
def index
end
def show
@betting_ticket = BettingTicket.find(params[:id])
@comment = Comment.new
@comments = @betting_ticket.comments
end
def scan
... |
module BirthdayHelper
def birthdate_priority(birthdate)
days_left = (birthdate - Time.zone.today).to_i
if days_left.between?(2, 3)
'warning'
elsif days_left.between?(1, 2)
'danger'
elsif days_left.between?(0, 1)
'success'
else
'primary'
end
end
def upcoming_birthd... |
class Account < ActiveRecord::Base
belongs_to :user
attr_accessible :age, :first_name, :gender, :last_name
validates :first_name, presence: true, length: {maximum: 30}
validates :last_name, presence: true, length: {maximum: 30}
validates :gender, format: {
with: /^(fe)?male$|^n\/a$/i,
message: 'gende... |
class Website < Obj
def homepage
self.class.default_homepage
end
def homepages
@homepages ||= toclist.select { |obj| obj.is_a?(Homepage) }
end
def website
self
end
end |
require 'rubygems'
require 'open-uri'
require 'nokogiri'
require 'json/pure'
def save_file(url, photo_id, size)
filename = "photos/#{photo_id}_#{size}.jpg"
open(filename, 'wb') do |file|
file.puts Net::HTTP.get_response(URI.parse(url)).body
end
end
def flickr(method)
flickr_key = 'ed699ee8139802047e258655... |
require 'maws/command'
require 'maws/elb_command'
require 'maws/trollop'
class ElbRemove < ElbCommand
def description
"elb-remove - remove specified EC2 instances from specified ELBs"
end
def run!
ec2s = instances.specified.with_service(:ec2)
elbs = instances.specified.with_service(:elb)
elbs.e... |
require 'rails_helper'
RSpec.describe MobileCode, type: :model do
it "is valid" do
expect(create(:mobile_code)).to be_valid
end
end
|
class CreateGames < ActiveRecord::Migration[6.0]
def change
create_table :games do |t|
t.string :title, null: false
t.text :description
t.string :image
t.integer :min_level, null: false
t.integer :max_level, null: false
t.string :game_system
t.integer :max_players, null: ... |
class DomainedDoc < Kb3
hobo_model # Don't put anything above this
fields do
end
set_table_name :documentdomain
belongs_to :doc, :foreign_key => 'id'
belongs_to :domain, :foreign_key => 'domain'
def self.import_from_bell
true
end
# --- Permissions --- #
def create_permitted?
acting_use... |
require 'rails_helper'
RSpec.describe UsersController, type: :controller do
describe "GET #index" do
it "renders the user index" do
get :index
expect(response).to render_template("index")
end
end
describe "GET #show" do
it "renders the show template" do
user = User.create!(usernam... |
class VgasController < ApplicationController
def index
end
def new
@vga = Vga.new
end
def create
@vga = Vga.create(vga_params)
if @vga.save
redirect_to new_vga_path
else
render new_vga_path
end
end
private
def vga_params
params.require(:vga).permit(:brand_id,:compan... |
class Animals
attr_accessor :name, :age, :gender, :species, :toys, :owner
def initialize(name, age, gender, species, toys, owner)
@name = name
@age = age
@gender = gender
@species = species
@toys = toys
@owner = owner
end
end
def to_s
puts "The animal is #{@name}, is #{@age} years... |
class ElementExperimentsController < ApplicationController
# GET /element_experiments
# GET /element_experiments.json
def index
@element_experiments = ElementExperiment.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @element_experiments }
end
end
#... |
require File.expand_path(File.join(File.dirname(__FILE__), 'test_helper'))
require 'mocha/minitest'
require 'datastores/in_column'
class InColumnDatastoreTest < ActiveSupport::TestCase
attr_accessor :data, :original_filename, :content_type
DEFAULT_ATTACHMENT_OPTIONS = {}
def self.attachment_options
@@a... |
class Api::V1::UsersController < Api::V1::ApplicationController
before_action :authenticate_api_user , except: [:sign_up,:login]
def sign_up
begin
raise "Email already present" if User.find_by_email(params[:user][:email].downcase).present?
user = User.create!(user_params)
payload = {user_id: user.id , ... |
class AddDefaultValueToValueAttribute < ActiveRecord::Migration[5.1]
def change
change_column :replies, :value, :integer, default: 0, null: false
end
end
|
# frozen_string_literal: true
class CreateInterviews < ActiveRecord::Migration[5.0]
def change
create_table :interviews do |t|
t.string :name
t.text :contents
t.timestamps
end
end
end
|
# birthDate = "1999-01-19"
# birthDate = Time.mktime(*(birthDate.split("-").map(&:to_i)))
# ((Time.new - birthDate) / 60 / 60 / 24 / 365).floor.times {
# puts "SPANK"
# }
# class Dice
# def initialize
# roll
# end
# def roll
# @numberShowing = 1 + rand(6)
# end
# def cheat number
# if number ... |
require_relative '../libs/android/android_parser'
require_relative '../libs/helpers/adb/adb_helper'
require_relative '../libs/helpers/device/device'
require_relative '../libs/helpers/device/device_helper'
require_relative '../libs/helpers/FileHelper'
require_relative '../libs/helpers/LoggerHelper'
require_relative 'por... |
require 'rails_helper'
RSpec.describe User, type: :model do
it 'a valid user is created with valid inputs' do
user = User.new
user.name = 'John Smith'
user.email = 'smith@test.com'
user.password = 'password'
user.save
expect(user).to be_valid
end
it 'it is not valid without an email' do
... |
# Read about factories at https://github.com/thoughtbot/factory_girl
FactoryGirl.define do
factory :section do
sequence(:title) { |n| "Section #{n}" }
default{ false }
issue
end
trait :default do
default{ true }
title { nil }
end
end
|
class Node
attr_accessor :data
attr_accessor :left
attr_accessor :right
def initialize(data)
@data = data
@left = nil
@right = nil
end
end
class BinarySearchTree
attr_accessor :root
def initialize(root=nil)
@root = root
end
def insert(node)
if root
insert_into_subtree_ro... |
# -*- mode: ruby -*-
# vi: set ft=ruby :
VAGRANTFILE_API_VERSION = "2"
domain = "rapidphp.com"
machinetype = "openswan"
fullmachine_name = machinetype + "." + domain
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "puppetlabs/centos-7.0-64-nocm"
config.vm.define "testmachin... |
class ClientAppController < ApplicationController
def show
render file: 'public/index.html'
end
end
|
require_relative "api"
require "glutton_ratelimit"
require "colored"
# Define variables
@hs_client = HelpScout::Client.new
@zd_client = Zendesk::Client.new
@hs_collections = @hs_client.collections
@rate_limit = GluttonRatelimit::AveragedThrottle.new 200, 60
# Maximum 200 requests every 60 seconds
number = 0
# Define ... |
class AddDealTotalCentsToCertificate < ActiveRecord::Migration
def change
add_column :certificates, :deal_total_cents, :integer
end
end
|
# Класс ClothesItem, который все знает про одну шмотку. Хранит всю информацию
# о ней, знает, для какой температуры она подходит, для какой нет.
class ClothesItem
# Напишем геттеры для удобства использования класса, чтобы мы могли достать
# любую переменную экземпляра просто вызвав clothes_item.title
attr_reader ... |
# encoding: UTF-8
class QuestionUserAnswer < ActiveRecord::Base
belongs_to :question
belongs_to :user
has_one :origin, as: :originable
validates :question_id, :user_id, :answer_text, presence: true
validate :answer_index_presence
private
def answer_index_presence
if self.question.with_choice?
... |
class HomeController < ApplicationController
def index
@movies = Movie.order(:year).reverse
end
end |
require 'id3lib'
module Rhouse::Helpers
class Audio
# Retrieves media information by parsing ID tag
def self.media_info( file, shallow=true )
return nil unless File.exists?( file )
tag = ID3Lib::Tag.new( file )
{
:uri => file,
:artist => tag.artist,
:alb... |
class LoginScreen < BaseClass
element(:login_trait) { 'action_bar_title' }
element(:username_field) { 'loginActivityUsername' }
element(:password_field) { 'loginActivityPassword' }
element(:login_button) { 'loginActivityLoginButton' }
element(:login_settings) { 'loginMenuItemSettings' }
element(:ur... |
class AddImprisonedDateToPeople < ActiveRecord::Migration
def change
add_column :people, :imprisoned_date, :date
add_column :people, :release_date, :date
end
end
|
require 'spec/helper'
describe 'User join' do
behaves_like 'mechanize'
def join_with(role, hash)
click_link 'Join'
click_link "Create #{role} account"
form = page.form('/user/join')
if tos = hash.delete(:tos)
form.checkboxes.name('tos').check
end
form.set_fields hash
submit form
... |
#!/usr/bin/env ruby
require 'rubygems'
require 'json'
require 'bunny'
require 'logger'
require_relative './fiatd-server'
require_relative './amqp_queue'
require_relative '../util/fiatd_logger'
#
# === an interface of application and Fiat Server
#
# get request from AMQP and pass it to Fiat Server
# get response from ... |
require 'constants.rb'
include Constants
class BaseScreen
def get_action
# Displays line through yield and adds "Type Here: "
print "Type Here: "
input = gets.chomp.downcase
end
def blank num=1
# Insert num numbers of newline characters
num.times do
puts "\n"
end
end
def line num=1
# Insert nu... |
class PagesController < ApplicationController
def index
end
def show
if template_exists? params[:page], ['pages']
@title = "#{params[:page].titleize} :: #{t("site.title")}"
render params[:page]
else
render file: Rails.root.join("public/404"), status: 404, layout: false
end
end
en... |
require 'spec_helper'
describe Mongoid::History::Tracker do
before :each do
class ModelOne
include Mongoid::Document
include Mongoid::History::Trackable
field :name, type: String
belongs_to :user, inverse_of: :model_ones
embeds_many :emb_ones
track_history
end
class... |
class CreateModifiers < ActiveRecord::Migration[5.2]
def change
create_table :modifiers do |t|
t.text :name
t.text :description
t.integer :percent
t.date :start
t.date :stop
t.timestamps
end
end
end
|
module Permission
module_function
extend RdfApi
def permitted_products(identity_url)
graph = fetch_permissions_graph(:grantee => identity_url)
query = RDF::Query.new({
:permission => {
RDF.type => perms.Permission,
perms.grantee => RDF::URI.new(identity_url),
perms.accessT... |
class User < ApplicationRecord
has_many :check_ins, dependent: :destroy
has_many :packs, -> { order 'created_at desc' }, dependent: :destroy
has_many :blacklisted_effects, class_name: 'Effect', foreign_key: :user_id
validates :email, uniqueness: true, if: 'email.present?'
class << self
def needs_new_pac... |
ActiveAdmin.register ItemType do
config.sort_order = "name_asc"
menu parent: I18n.t('admin.references'), priority: 10
index do
column :name
column :active
column "Item Masters" do |row|
zero_blank row.item_masters.count
end
default_actions
end
show do
attributes_table_for i... |
class CreateLiquidityPreferences < ActiveRecord::Migration
def self.up
create_table :liquidity_preferences do |t|
t.float :multiple
t.timestamps
end
end
def self.down
drop_table :liquidity_preferences
end
end
|
class Review < ApplicationRecord
belongs_to :truck
belongs_to :user
validates :rating, presence: true, inclusion:
{ in: [1, 2, 3, 4, 5] }, numericality:
{ only_integer: true }
end
|
# == Schema Information
#
# Table name: resource_storage_a3_par_arrays
#
# id :integer not null, primary key
# name :string
# model :string
# serial :string
# firmware :string
# space_total :integer
# space_available :integer
# space_used :inte... |
FactoryGirl.define do
sequence(:access_token) { |n| "123ABC#{n}" }
factory :api_token do
access_token
step { create(:approval_step) }
expires_at { Time.current + 7.days }
end
end
|
class AddIsCancelledToBooking < ActiveRecord::Migration[6.0]
def change
add_column :bookings, :is_cancelled, :boolean, default: false
add_column :bookings, :is_no_show, :boolean, default: false
add_reference :bookings, :cancelled_by_user
end
end
|
# Write a method that takes a sentence string as input,
# and returns the same string with any sequence of the words
# 'zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven',
# 'eight', 'nine' converted to a string of digits.
# create a constant hash where the keys are integers, and the value is the string r... |
module Requests
module JsonHelpers
def json
@json ||= JSON.parse(response.body)
end
def auth_params
@auth_user ||= create(:user)
{ authentication_token: @auth_user.authentication_token }
end
end
end
|
class TransactionsController < ApplicationController
before_action :logged_in_user
before_action :set_transaction, only: %i[show edit update destroy]
def index
@transactions = current_user.transactions_with_categories
@transactions = @transactions.search(params[:search]) if params[:search].present?
@... |
require 'srgs'
module JokeGrammar
include Srgs::DSL
extend self
grammar 'topLevel' do
private_rule 'volumeTypes' do
one_of do
item 'up'
item 'down'
end
end
private_rule 'volume' do
item 'turn'
item 'the volume', repeat: '0-1'
reference '#volumeTypes'
... |
#
#= 所属管理用コントローラのアクションを定義するモジュール
#
module Concerns::Susanoo::Admin::SectionsController
extend ActiveSupport::Concern
included do
before_action :admin_required
before_action :set_section, only: %i(edit update destroy)
#
#== 一覧画面表示
#
def index
if request.xhr?
if params[:divisio... |
# variables
# variable_name_with_underscore
# first_name
# age
# score1
# prompt a user for input and store in variable
# print "please enter your age:"
# age = gets.chomp
# puts "you are #{age} years old."
# puts age.inspect
#math with our age -= calculate dog years
# print "Please enter your age: "
# age = gets.to... |
###
# Page options, layouts, aliases and proxies
###
# Per-page layout changes:
#
# With no layout
page '/*.xml', layout: false
page '/*.json', layout: false
page '/*.txt', layout: false
# With alternative layout
# page "/path/to/file.html", layout: :otherlayout
# Proxy pages (http://middlemanapp.com/basics/dynamic-... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.