text
stringlengths
10
2.61M
lib = File.expand_path('../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'cryptcheck/engine/version' Gem::Specification.new do |spec| spec.name = 'cryptcheck-engine' spec.version = Cryptcheck::Engine::VERSION spec.authors = %w[aeris] spec.email = %w[aeris@imirhil.fr] spec.li...
class FlightSerializer < ActiveModel::Serializer attributes :id, :points, :destination, :img has_many :user_flights has_many :users, through: :user_flights end
class PSpaceLet < ApplicationRecord belongs_to :p_space def includes?(date) return date_from <= date && date <= date_to end end
class WorkshopDocumentAsset < Kb3 hobo_model # Don't put anything above this fields do label :string end set_table_name :documentasset belongs_to :doc, :foreign_key => :document belongs_to :workshop_wfinode, :foreign_key => :id def self.import_from_bell true end # --- Permissions --- # ...
require "dartt/milestone" RSpec.describe Dartt::Milestone do it "can create a milestone" do milestone = Dartt::Milestone.new("My Milestone", Date.new(2020, 12, 28)) expect(milestone.name).to eq("My Milestone") expect(milestone.date).to eq(Date.new(2020, 12, 28)) end it "moves the date to the weekda...
Vagrant.configure("2") do |config| # NOTE: Each interface needs an IP address defined even # with `auto_config: false`. # CentOS 8 config.vm.define "centos8" do |centos8| centos8.vm.box = "centos/8" centos8.vm.hostname = "bond-centos8" centos8.vm.provider "virtualbox" do |v| v.name = "b...
require 'spec_helper' require 'pathname' describe Libv8 do include Libv8 it "can find the static library components" do Pathname(libv8_base).should exist Pathname(libv8_snapshot).should exist end it "has a valid include path" do Pathname(libv8_include_path).should be_exist end it "can retrie...
class SessionsController < ApplicationController # curl -XPOST -v -H 'Content-Type: application/json' -H 'Accept:application/json' http://localhost:3000/login -d '{"session": { "email": "asdf@example.com", "password": "asdfasdf" } } ' -c cookie.txt # this line will let you log in from curl: # skip_before_action :...
class SessionsController < ApplicationController # omniauth handles the facebook login from the AA dashboard, # needed to make sure that we have a valid token in order to post articles to facebook # the app controller current_user is the devise based AA login def create user = User.from_omniauth(auth_hash)...
class Admin::UsersController < Admin::BaseController active_scaffold :users do |config| non_editable = [:current_login_at, :current_login_ip, :last_login_at, :last_login_ip, :last_request_at, :token_expires_at,:fasta_files,:job_logs,:jobs] config.list.columns = [:avatar,:full_name, :email,:curre...
# ['fish', 'fiiish', 'fiiiiish', 'fiiiish', 'fffish', 'ffiiiiisshh', 'fsh', 'fiiiissshhhhhh'] # => "fiiiissshhhhhh" def sluggish_octopus(fishes) fishes.each_with_index do |fish1, idx1| max_fish = true fishes.each_with_index do |fish2, idx2| next if idx1 == idx2 max_fish = false if fish2.length > ...
class EventsController < ApplicationController before_filter :set_current_tab before_filter :login_required, :only => [:new, :create, :update] before_filter :load_top_events before_filter :load_newest_events def index @current_sub_tab = 'Browse Events' @events = Event.newest end def new @cur...
class Patient < ActiveRecord::Base belongs_to :location validates :first_name, presence: true, length: { maximum: 30 } validates :middle_name, length: { maximum: 10 } validates :last_name, presence: true, length: { maximum: 30 } validates :status, :location, presence: true extend Enumerize enumerize :gender, in:...
module MarkdownMetrics class LowElementsParser attr_reader :elements def initialize(value:) @value = value @elements = [] end def parse @value.each_character_with_index do |chr, index| element = initialize_element(chr, index) @elements << { name: element.n...
module API class BooksController < BaseController def index @books = Book.all render json: @books end def create @book = Book.new(book_params) if @book.save render json: @book else render json: { errors: @book.errors } end end protected d...
class Questions def initialize ## First integer random number @first_num = rand(20) ## Second integer random number @second_num = rand(20) ## Answer to be compared @answer = @first_num + @second_num ## Question to be displayed to the player @question = "What is the sum of #{@first_num}...
class AddNumber1ToUsers < ActiveRecord::Migration[5.1] def change add_column :users, :number1, :string end end
# == Schema Information # # Table name: the_models # # id :integer not null, primary key # name :string(255) not null # description :string(255) default(""), not null # lock_version :integer default(0), not null # created_at :datetime not null # updated_at ...
Pod::Spec.new do |s| s.name = "SwiftFlags" s.version = "1.2.0" s.summary = "Simple Swift library to get emoji flag from a country name or country code (ISO 3166-1)." s.homepage = "https://github.com/BubiDevs/SwiftFlags.git" s.license ...
require 'rails_helper' include Warden::Test::Helpers RSpec.describe "Sessions" do it "signs user in and out" do user = FactoryGirl.create(:user) sign_in user get root_path expect(controller.current_user).to eq(user) sign_out user get root_path expect(controller.current_user_i...
class SeriesResource < Webmachine::Resource def allowed_methods ['GET', 'POST'] end def content_types_provided [['application/json', :to_json], ['text/html', :to_html]] end def to_json json = [] Minifigure.all.each {|m| json << {name: m.name}} json.to_json end def to_html tem...
class Shop < ApplicationRecord belongs_to :manager, class_name: "User" belongs_to :city has_many :boat_for_sales, dependent: :destroy has_many :shop_products, dependent: :delete_all def products(product_type_id=nil) if product_type_id.nil? shop_products.joins(:product).order("products.name ASC"...
# -*- encoding: utf-8 -*- lib = File.expand_path('../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'censys/version' Gem::Specification.new do |gem| gem.name = "censys" gem.version = CenSys::VERSION gem.summary = %q{API client for censys.io} gem.descriptio...
require "spec_helper" # Fake Rails class Rails def self.env; end end RSpec.describe HerokuJobGovernator::Governor do let(:subject) { HerokuJobGovernator::Governor.instance } describe "#scale_up" do context "not in production" do before do allow(Rails.env).to receive(:production?).and_return(f...
class ScheduledReportPolicy include ExceptionPolicy def initialize(user, record) super(user, record) @scheduled_report = record end def can_show! check(can_show?, I18n.t("errors.policies.scheduled_report.show_permission")) end def can_update! check(owner?, I18n.t("errors.policies.schedule...
require_relative 'demo_app_page' class SignUpPage < DemoAppPage path '/users/sign_up' validate :title, /\ADemo web application - Sign Up\z/ element :user_name_input, :fillable_field, 'user_name' element :email_input, :fillable_field, 'user_email' element :password_input, :fillable_field, 'user_password' el...
require 'rails_helper' describe Competency do before do @jane = Provider.create!(name: "Jane Johnston", profile_url: Faker::Internet.url, phone_number: Faker::PhoneNumber.phone_number) @assessment = Assessment.create!(word: "depression") @competency = Competency.create!(provider: @jane, assessment: @asse...
module Bsale class Reference < Base def attributes %i( number referenceDate reason codeSii ) end end end
# frozen_string_literal: true module GraphQL module Types class Float < GraphQL::Schema::Scalar description "Represents signed double-precision fractional values as specified by [IEEE 754](https://en.wikipedia.org/wiki/IEEE_floating_point)." def self.coerce_input(value, _ctx) value.is_a?(Num...
require 'securerandom' class User < ActiveRecord::Base # Include default devise modules. Others available are: # :confirmable, :lockable, :timeoutable and :omniauthable #devise :database_authenticatable, :registerable, # :recoverable, :rememberable, :trackable, :validatable #before_create :set_auth_to...
describe FeedPostFetcher do subject { described_class.new(current_user: user) } let!(:user_1) { create(:user) } let!(:user_2) { create(:user) } let!(:user_3) { create(:user) } let!(:profile_1) { create(:profile, user: user_1, first_name: "ben") } let!(:profile_2) { create(:profile, user: user_2, fi...
# Automatically rotate the Rails asset version on code deploy. # This solution is appropriate for most Threespot # clients, but probably not sustainable for millions of unique visors per day # Changing a single file inside /app/assets will invalidate ALL frontend assets Rails.configuration.assets.version = begin fil...
class Server < ActiveRecord::Base belongs_to :environment attr_accessible :datacenter, :environment_id, :description, :fqdn, :name, :priv_ip, :pub_ip, :role validates_presence_of :name, :role validate :network_access_path HUMANIZED_ATTRIBUTES = { :pub_ip => "Public IP Address", :fqdn => "Full DNS ...
require 'rails_helper' RSpec.describe UsersController, type: :controller do describe "POST #authenticate" do context "with invalid params" do it "returns 400" do post :authenticate, format:"json" expect(response).to have_http_status(400) end it "renders user authenticated m...
# frozen_string_literal: true lib = File.expand_path('lib', __dir__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'active_encryption/version' Gem::Specification.new do |spec| spec.name = 'active_encryption' spec.version = ActiveEncryption::VERSION spec.authors = ['Arnaud ...
class AddFieldsToDictPalletTypes < ActiveRecord::Migration def change add_column :dict_pallet_types, :height_mm, :integer add_column :dict_pallet_types, :width_mm, :integer add_column :dict_pallet_types, :length_mm, :integer add_column :dict_pallet_types, :weight_g, :integer end end
# frozen_string_literal: true class NullTalkSummary def title '(No Talks Yet)' end def body <<~SENTINEL There have been no talks yet. SENTINEL end end
class RobotWeapon < ActiveRecord::Base include HealthManager belongs_to :robot belongs_to :weapon has_one :health, as: :machine validates :robot, presence: true validates :weapon, presence: true validates :health, presence: true accepts_nested_attributes_for :health after_in...
module JobHelper def calculate_job_discount(job) return 0 unless job.promotion_id discount = 0.00 promotion = job.promotion return 0 unless promotion if promotion total_service_price = job.services.map{|s| s.time * s.price}.inject(:+) total_service_price = (job.job_details.pluck(:pr...
require 'fileutils' desc "removes all but the last two deploys (so we can keep our \"releases\" directory a reasonable size)" task :cleanup_deploys do deploy_root = File.expand_path("../../../../..", __FILE__) releases_dir = "#{deploy_root}/releases" old_backup_paths = Dir["#{releases_dir}/*"].sort[0...-2] ...
class ChangeStartAndEnd < ActiveRecord::Migration[6.1] def change rename_column :matches, :start, :started_at rename_column :matches, :end, :ended_at end end
require 'rails_helper' describe Match, type: :model do let(:competitor1) { create(:competitor, name: "Alex")} let(:competitor2) { create(:competitor, name: "Jason")} let(:match1) { create(:match, competitor1: competitor1, competitor2: competitor2) } let(:match_list) { create_list(:match, 3, competitor1: comp...
require 'test_helper' class PresentTest < SexyPgConstraintsTest def assert_protects_from_blank(column, contraint) ActiveRecord::Migration.constrain :books, column, contraint => true assert_prohibits Book, column, contraint do |book| book.send("#{column}=", ' ') end assert_allows Book do |book...
require 'rubygems' require "xmpp4r" require "xmpp4r/pubsub" require "xmpp4r/pubsub/helper/servicehelper.rb" require "xmpp4r/pubsub/helper/nodebrowser.rb" require "xmpp4r/pubsub/helper/nodehelper.rb" module Commonsense module Xmpp class NodeCreater def self.create_nodes include Jabber Jab...
require 'test_helper' class DynamicImagesControllerTest < ActionController::TestCase setup do @dynamic_image = dynamic_images(:one) end test "should get new" do get :new assert_response :success end test "should create dynamic_image" do assert_difference('DynamicImage.count') do post ...
FactoryBot.define do factory :reward do status { Reward.statuses.keys.sample } association :account, factory: [:account, :with_session] end end
class ChangePatientTypeToString < ActiveRecord::Migration[5.2] def change change_column :patients, :ward_assigned, :string end end
class ChangeProductsServicesToDescription < ActiveRecord::Migration[5.0] def change rename_column :companies, :products_services, :description end end
# frozen_string_literal: true ## --- BEGIN LICENSE BLOCK --- # Copyright (c) 2016-present WeWantToKnow AS # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including wit...
class CreateGouGouSites < ActiveRecord::Migration def self.up create_table :gou_gou_sites do |t| t.integer :gou_id t.integer :gou_site_id t.decimal :price, :precision => 8, :scale => 2 t.integer :click_count,:default=>0 t.timestamps end end def self.down drop_table :gou_...
class Poll class InvalidCandidateError < StandardError end class MultipleVoteError < StandardError end class OverdueVoteError < StandardError end attr_reader :title, :candidates, :votes, :closing def initialize(title, candidates, closing) @title = title @candidates = candidates @closing = ...
#!/usr/bin/env ruby # Copyright 2020 Ismo Kärkkäinen # Licensed under Universal Permissive License. See License.txt. require 'optparse' require 'json' $IN = nil $WIDTH = 256 $HEIGHT = 256 $COMPONENTS = 3 $DEPTH = 8 $OUTPUT = nil $FORMAT = nil parser = OptionParser.new do |opts| opts.summary_indent = ' ' opts.su...
java_import 'backtype.storm.testing.TestWordSpout' require 'examples/simple/exclamation_bolt' # this example topology uses the Storm TestWordSpout and our own JRuby ExclamationBolt module RedStorm module Examples class ExclamationTopology < RedStorm::SimpleTopology spout TestWordSpout, :parallelism => 10...
class CommentsController < ApplicationController before_action :authenticate_user!, except: [:index] before_action :set_post, only: %i[create index destroy] def index @comments = @post.comments.order(created_at: :desc) end def create @comment = current_user.comments.create(comment_params) redire...
class Addition < ApplicationRecord belongs_to :recipe belongs_to :ingredient validates :recipe_id, numericality: { only_integer: true } validates :ingredient_id, numericality: { only_integer: true } end
class Train ALLOWED_TYPES = [:passenger,:cargo,:other] def self.find(number) #на мой взгляд об известных программе поездах должен знать класс Application, а не Train, #т.к. Train будет знать обо всех объектах типа "поезд", которые создавались, #но не все они могут быть значимы для программы (некоторые...
class Station < ActiveRecord::Base enum status: [:online, :maintenance, :offline] validates :name, presence: true end
chickens = ["Margeret", "Hetty", "Henrietta", "Audrey", "Mabel"] # # for chicken in chickens # p chicken # end # # #when only using one line of code in an each loop, use curly brackets # chickens.each {|chicken| p chicken} # #when using multiple lines of code in an each loop, use do > end and put code between # chick...
class BookingsController < ApplicationController before_action :set_booking, only: %i[ show edit update destroy ] before_action :find_site # GET /bookings def index @bookings = Booking.all end # GET /bookings/1 def show end # GET /bookings/new def new @booking = Booking.new end # G...
module BikeContainer attr_accessor :bikes attr_reader :capacity DEFAULT_CAPACITY = 4 def initialize @bikes = [] @capacity = DEFAULT_CAPACITY end def is_empty? raise "#{self.class.name} is empty" if bikes.empty? end def is_full? raise "#{self.class.name} is full" if bikes.length == c...
# frozen_string_literal: true require 'sinatra/base' require 'jiji/web/services/abstract_service' module Jiji::Web class LogService < Jiji::Web::AuthenticationRequiredService options '/:backtest_id' do allow('GET,OPTIONS') end get '/:backtest_id' do index = request['offset'] ? request[...
require "minitest/autorun" require_relative "../lib/toll_free/dictionary" describe TollFree::Dictionary do it "can lookup a word" do dictionary = TollFree::Dictionary.new("/usr/share/dict/words") dictionary.include?("hello").must_equal(true) end it "can reject a nonexistent word" do dictionary = T...
class Test < ActiveRecord::Base has_many :levels has_many :questions validates :brief, length: { maximum: 1000, too_long: "%{count} characters is the maximum allowed" } validates :name, length: { maximum: 50, too_long: "%{count} characters is the maximum allowed"} validates :name, presence: true va...
# Method name: count_max # Inputs: A list of numbers # Returns: The number of times the largest number in the list # appears in the list # Prints: Nothing # # For example, # count_max([10, 1,2,10,10]) == 3 # because "10" is the largest number in the list and it occurs 3 times # This is how...
require 'rails_helper' RSpec.describe Program, type: :model do # Associations it { is_expected.to have_many :player_cards } end
require 'spec_helper' describe "wizard_zones/index" do before(:each) do assign(:wizard_zones, [ stub_model(Wizard::Zone), stub_model(Wizard::Zone) ]) end it "renders a list of wizard_zones" do render end end
require 'json' class Simulator attr_accessor :name, :version, :udid def initialize captures @name, @version, @udid = captures end def self.random match: /^iPhone 6$/, min_version: 8.0, max_version: 10.0, exact_version: nil Simulator.new JSON.parse(`xcrun simctl list --json`) .fetc...
require 'rails_helper' feature "New Post Page" do scenario "when user is not logged in" do visit new_post_path expect(page).to have_content("Please sign-in first") end scenario "when user is logged in" do sign_in_user visit root_path click_link "Add Post" expect(page).to have_content...
class WelcomeController < ApplicationController def index @songs = %w(君のこころは輝いてるかい? 恋になりたいAQUARIUM ジングルベルがとまらない) @aqours = [ '高海 千歌', '桜内 梨子', '松浦 果南', '黒澤 ダイヤ', '渡辺 曜', '津島 善子', '国木田 花丸', '小原 鞠莉', '黒澤 ルビィ' ] end end
require_relative 'base_action' module Miri module Action class Spotify1 < BaseAction # Set to zero to play entire track PREVIEW_TRACK_SECONDS=10 def process(artist_text) @artist_text = artist_text play_track_for_artist end def keywords [ ...
require "spec_helper" RSpec.describe "Day 12: The N-Body Problem" do let(:runner) { Runner.new("2019/12") } describe "Part One" do it "calculates the total energy after N steps" do expect(runner.execute!(<<~TXT, part: 1, STEPS: 10)).to eq(179) <x=-1, y=0, z=2> <x=2, y=-10, z=-7> ...
require "digest" module Tephue class BcryptHasher def self.hash(salt, word) BCrypt::Engine.cost = 10 BCrypt::Engine.hash_secret word, salt end def self.salt BCrypt::Engine.generate_salt 10 end end end
class Api::V1::ChambersController < Api::ApplicationController before_action :find_chamber before_action :authorize_token def show json_response @chamber end def update if @chamber.update(chamber_params) json_response @chamber else raise ActiveRecord::RecordInvalid end end ...
module FlightsHelper cattr_accessor :params def flight_start_before_end if self.departure > self.arrival errors.add(:departure, "cannot be after arrival.") end end def flight_trip_date_confirm @trip = Trip.find_by(id: params[:trip_id]) if self.arrival > @trip.end || self.arrival < @trip....
class RoomMessage < ApplicationRecord validates :message, presence: true belongs_to :employee belongs_to :room def as_json(options) super(options).merge(avatar_url: employee.avatar_url, sender_name: employee.full_name, sender_id: employee.id) end def ...
# 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...
# frozen_string_literal: true # Module with utilities module Utils def clear_console system('clear') || system('cls') end end
# write a method that takes an Array of numbers # and returns an Array with the same number of elements # and each element has the running total from the original Array # Examples: # # running_total([2, 5, 13]) == [2, 7, 20] # running_total([14, 11, 7, 15, 20]) == [14, 25, 32, 47, 67] # running_total([3]) == [3] # r...
Rails.application.routes.draw do devise_for :users resources :recipes root "recipes#index" end
#!/opt/puppetlabs/puppet/bin/ruby require 'json' require 'optparse' def debug(str) puts "DEBUG: #{str}" if $options[:debug] end # curl data from a specified url def curl_data(command) debug "Running command '#{command}'" data = `#{command}` retcode = $?.exitstatus if(retcode != 0) then if(retcode == 7...
class AddCurrentWorkoutGroupToUser < ActiveRecord::Migration[5.1] def change add_column :users, :current_workout_group, :integer add_index :users, :current_workout_group end end
class UserDetail < ActiveRecord::Base belongs_to :user belongs_to :department belongs_to :grade # 必須入力 validates :user_id, :department_id, :grade_id, :tel, :name_ja, :name_en, presence: true validates :user_id, uniqueness: true # 重複不可 validates :name_en, format: { with: /\A[a-zA-Z\s]...
require 'rails_helper' feature "User" do scenario "will be asked to add their first entry on signup" do user = create(:user) signin user expect(page).to have_text "ADD YOUR FIRST ENTRY" expect(page).to_not have_text "SAVE" end scenario "can save a new mileage record" do user = create(:user, email: 'ugh@e...
class Post < ActiveRecord::Base has_many :comments, :dependent => :destroy validates :title, :presence=>true validates :body, :presence=>true scope :latest, order("created_at DESC") scope :order_by_title, order("title ASC") # # before_save :title_case before_create :set_publish_status before_updat...
require_relative "../../shared_ruby/euler.rb" def inside_triangle?(a, b, c) # Compute vectors v0 = [ c[0] - a[0], c[1] - a[1] ] v1 = [ b[0] - a[0], b[1] - a[1] ] v2 = [ -a[0], -a[1] ] # Compute dot products dot00 = v0.dot(v0) dot01 = v0.dot(v1) dot02 = v0.dot(v2) dot11 = v1.dot(v1) dot12 = v1.dot...
require_relative 'ui_valet' module AppiumValet class InputValet < UIValet def into(textfield:) input_field = textfield_element(textfield) input_field.clear input_field.send_keys(@selector_text) end private def textfield_element(search_value) return driver.textfield(search_va...
require 'rdf' module WorksVocabularies class WorksTerms < RDF::Vocabulary("http://hydra.org/works/models#") # Class definitions term :Collection term :GenericWork term :GenericFile term :File end end
# frozen_string_literal: true class BasePresenter include QuranUtils::StrongMemoize attr_reader :params def initialize(params) @params = params end delegate :next_page, :current_page, :per_page, :total_records, :total_pages, to: :finder def sanitize_query_fields(fields) fi...
songs = [ "Phoenix - 1901", "Tokyo Police Club - Wait Up", "Sufjan Stevens - Too Much", "The Naked and the Famous - Young Blood", "(Far From) Home - Tiga", "The Cults - Abducted", "Phoenix - Consolation Prizes", "Harry Chapin - Cats in the Cradle", "Amos Lee - Keep It Loose, Keep It Tight" ] def help...
class Dancer attr_accessor :age def initialize(name, age) @name = name.to_s @age = age.to_i @card = [] end def name @name end def age @age end def pirouette p "*twirls*" end def bow p "*bows*" end def queue_dance_with(partner) @card << partner.to_s end def card @card end de...
# -*- encoding: utf-8 -*- require File.expand_path('../lib/absolute_renamer/version', __FILE__) Gem::Specification.new do |gem| gem.authors = ["Simon COURTOIS"] gem.email = ["scourtois@cubyx.fr"] gem.summary = "absolute_renamer is a very powerful tool that helps " \ "fil...
require 'rails_helper' RSpec.describe User, :type => :model do specify { expect(subject).to respond_to(:authenticate) } describe '#sign_in!' do subject { User.new } before do subject.sign_in! Timecop.freeze end after { Timecop.return } specify { expect(subject.last_signed_in.to_s)...
require 'guard' require 'guard/guard' module Guard class Ctags < Guard VERSION = '0.0.1' def initialize watchers=[], options = {} @ui_prefix = 'CTags' puts "HELLO FRM #@ui_prefix" commands = generate_commands_for_options(options) commands.each do |ext, func| watcher = watche...
class Vote < ActiveRecord::Base named_scope :for_voter, lambda { |*args| {:conditions => ["voter_id = ? AND voter_type = ?", args.first.id, args.first.type.name]} } named_scope :for_voteable, lambda { |*args| {:conditions => ["voteable_id = ? AND voteable_type = ?", args.first.id, args.first.type.name]} } nam...
require "uri" module RSpec module Rest module RestURLExampleGroup def http_method meth = rest_url_group[:description_args].first.split("\s")[0].downcase.to_sym case meth when :get,:post,:put,:delete,:head then meth else raise "invalid describe format for rest_url (#{rest_url...
# == Schema Information # # Table name: cats # # id :integer not null, primary key # birth_date :date not null # color :string not null # name :string not null # sex :string(1) not null # description :text # created_at :datetime # u...
class ReservationsController < ApplicationController before_action :authorized def index if !current_user || current_user.name != "admin" redirect_to root_path end if params[:commit] == "Filter" @reservations = Reservation.all & Reservation.filter_by_user(params) else @rese...
json.array!(@tv_shows) do |tv_show| json.extract! tv_show, :id, :title json.url tv_show_url(tv_show, format: :json) end
# Cookbook Name:: ca_certificates # Recipe:: default # # Copyright 2015, Alexander van Zoest # # 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...
module Speak def speak(sound) puts "#{sound}" end end class GoodDog include Speak end class HumanBeing include Speak end sparky = GoodDog.new sparky.speak("Arf!") bob = HumanBeing.new bob.speak("Hello!") puts "---GoodDog ancestors---" puts GoodDog.ancestors puts '' puts "---HumanBei...