text
stringlengths
10
2.61M
module Sentry class RequestInterface < Interface REQUEST_ID_HEADERS = %w(action_dispatch.request_id HTTP_X_REQUEST_ID).freeze IP_HEADERS = [ "REMOTE_ADDR", "HTTP_CLIENT_IP", "HTTP_X_REAL_IP", "HTTP_X_FORWARDED_FOR" ].freeze attr_accessor :url, :method, :data, :query_string, :c...
require File.dirname(__FILE__) + '/setup' require 'javaclass/string_hexdump' class TestStringHexdump < Test::Unit::TestCase def test_hexdump_empty assert_equal("00000000h: #{' '*16}; \n", ''.hexdump) end def test_hexdump_line assert_equal("00000000h: 61 #{' '*15}; a\n", 'a'.hexdump) en...
require 'mruby/bindings' # CTypes.define('Example') do # self.needs_unboxing = true # self.needs_boxing_cleanup = false # self.needs_unboxing_cleanup = false # self.needs_type_check = true # # self.recv_template = 'mrb_value %{value};' # self.format_specifier = 'o' # self.get_args_template = '&%{value...
class AttachmentsController < ApplicationController before_action :authenticate_user! skip_before_filter :verify_authenticity_token, only: [:create] def index if params[:for_course] @course = Course.find_by course_code: params[:for_course] @attachments = @course.attachments.approved.page(params[...
# You have a bank of switches before you, numbered from 1 to n. Each switch is # connected to exactly one light that is initially off. You walk down the row # of switches and toggle every one of them. You go back to the beginning, and # on this second pass, you toggle switches 2, 4, 6, and so on. On the third # pass, y...
class Crypto def initialize(text) @text = text @size = nil end def normalize_plaintext @text = @text.scan(/\w/).join.downcase end def size normalize_plaintext Math.sqrt(@text.size).ceil end def plaintext_segments normalize_plaintext @text.scan(/.{1,#{size}}/) end def ci...
# Username Creator # [cool, coolbeans, cool, coolerbeans, coolbeans, cool, cool] # [cool, coolbeans, cool1, coolerbeans, coolbeans1, cool2, cool3] # want to add consecutive digits after the word if the name has occured already def username_creator(array) username_hash = {} results = [] array.each do |user...
class Logger attr_reader :filename def initialize(filename) @filename = filename @file = File.open(filename, "a") end def log(message) @file.write(timestamp + " " + message + "\n") end private def timestamp "[" + Time.now.to_s + "]" end end
class EvenementsController < ApplicationController before_action :set_evenement, only: [:show, :edit, :update, :destroy] # GET /evenements # GET /evenements.json def index if user_signed_in? @categories = Category.all @organisateur = Organisateur.find_by(user_id: current_user.id) if @orga...
require 'rails_helper' RSpec.describe AptSearch do context 'Parsing html from a passed in page' do let(:html){File.open(Rails.root.join('spec', 'stubs', 'html.txt'), 'r').read} it 'Correctly gets apartment info' do data = AptSearch.new.get_apartment_data_from_raw_html(html) expect(data.count).to eq(13...
class AdminsController < ApplicationController include AdminsHelper #page where admin can choose to login/signup def index logger.info("(#{self.class.to_s}) (#{action_name}) -- Entering the admin index page") session_check end #page after admin logs in def home logger.info("(#{self.class.to_s}) (#{act...
class GroupGame < ActiveRecord::Base belongs_to :group belongs_to :game end
require 'rails_helper' RSpec.describe PieceSituation, type: :model do it 'has a valid factory' do expect(create :piece_situation).to be_valid end describe 'Validations' do it { should validate_presence_of :name } end end
module DidYouMean module Formatters class Plain def initialize(suggestions = []) @suggestions = suggestions end def to_s output = "\n\n" output << " Did you mean? #{format(@suggestions.first)}\n" output << @suggestions.drop(1).map{|word| "#{' ' * 18}#{format(w...
class ShortenedUrl < ApplicationRecord validates :short_url, presence: true, uniqueness: true validates :long_url, presence: true validates :user_id, presence: true belongs_to :submitter, primary_key: :id, foreign_key: :user_id, class_name: :User has_many :visits, primary_key: :id, forei...
Rails.application.routes.draw do get 'homes/show' get 'homes/index' get 'homes/new' get 'homes/edit' devise_for :users # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html resources :books root 'homes#show' resources :users end
module ErrorHandler # 1. Please pay attention to the indentation. Many Ruby devs are very particular about it # 2. How come an ErrorHandler is responsible for printing the menu? This functionality has nothing # to do with error handling. PROGRAM_PHRASES = { "menu" => "\n\nEditor Commands as follow:\n ...
class Wordfreq STOP_WORDS = ['a', 'an', 'and', 'are', 'as', 'at', 'be', 'by', 'for', 'from', 'has', 'he', 'i', 'in', 'is', 'it', 'its', 'of', 'on', 'that', 'the', 'to', 'were', 'will', 'with'] def initialize(filename) contents = File.read(filename).downcase.gsub("--", " ") contents = contents.gsub(...
# == Schema Information # # Table name: assets # # id :integer not null, primary key # user_id :integer # photo_id :integer # source_id :integer # source_type :string(255) # source_asset_id :integer # archive_id :string(255) # state :string(255) ...
FactoryBot.define do domain = Faker::Internet.domain_name factory :ldap do name { "Active Directory" } host { Faker::Internet.private_ip_v4_address } port { 389 } domain { domain } username { "administrator" } password { "Pa$$word" } tree_base { domain } company end end
# frozen_string_literal: true class EtsPdf::Parser::ParsedLine LINE_TYPES = %w[course group period].map do |type| [type, "EtsPdf::Parser::ParsedLine::#{type.classify}".constantize] end.to_h def initialize(line) @line = line @types = {} end attr_reader :line LINE_TYPES.each do |type, klass| ...
class InventoryShow < Demo def self.title "Inventory show command" end def run @prompt.say(<<~INTRO) Bolt has a subcommand 'inventory show', which accepts a target specification and returns the targets that exist in the inventory and match the spec. For example, {{bolt inventory show -t localhost...
# frozen_string_literal: true RSpec.describe 'Videos' do resource 'Admin videos' do let!(:video1) { create(:video) } let!(:video2) { create(:video) } let!(:video3) { create(:video, :with_category) } let!(:video4) { create(:video, :deleted) } # NOTE: Deleted records are not returned by default let...
module Tools def convert_node_to_index node case node when "A" 0 when "B" 1 when "C" 2 when "D" 3 when "E" 4 end end end class Station include Tools def initialize to_station_A, to_station_B, to_station_C, to_station_D, to...
class AddHoursBreak < ActiveRecord::Migration[5.1] def change add_column :timelogs, :total_break_hours, :decimal, precision: 2, scale: 2 add_column :timelogs, :total_hours, :decimal, precision: 2, scale: 2 remove_column :timelogs, :returned remove_column :timelogs, :sample remove_column :timelogs,...
# -*- mode: ruby -*- # vi: set ft=ruby : Vagrant.configure(2) do |config| config.vm.box = "ubuntu/trusty32" config.vm.hostname = "webserver.dev" # Static IP address config.vm.network "public_network", ip: "192.168.2.10" # Assemption, one machine per project config.vm.synced_folder "./projects/", "/var...
class CreateAnswers < ActiveRecord::Migration def change create_table :answers do |t| t.string :text t.boolean :best, default: false t.integer :user_id t.integer :question_id end add_column(:users, :created_at, :datetime) add_column(:users, :updated_at, :datetime) change_c...
require 'minitest/autorun' require 'teebo' class CreditCardTest < MiniTest::Test # Verifies that the length of a string generated by the 'CreditCard.number_to_digits' method # matches the length passed in. def test_cc_generate_length assert_equal 13, Teebo::CreditCard.number_with_length(13)....
FactoryGirl.define do factory :product do name "Tecnica Moon Boots" description "The one and only Stanton—our casual weather-beaten short in a classic fit with a twist" price_in_cents 790000 end end
module Merb module Static class Cookie # :api: private attr_reader :name, :value # :api: private def initialize(raw, default_host) # separate the name / value pair from the cookie options @name_value_raw, options = raw.split(/[;,] */n, 2) @name, @value = Merb::P...
class ApplicationController < App helpers AppHelper get "/" do @page = Page.find_by_slug_cached "home" erb :"pages/show" end # CLEAR CACHE post "/publish" do App.cache.flush redirect "/" end # Bypasses cache to show current changes # but does not clear the cache get "/preview" do ...
class AddExhibisionStateToItems < ActiveRecord::Migration[5.2] def change add_column :items,:exhibision_state, :integer,null:false end end
class AddScreenNameAndLocationToUsers < ActiveRecord::Migration def change change_table(:users) do |t| t.column :screen_name, :string, limit: 18 t.column :location, :string end end end
class AddEmailSnippetToOrdersAndGroups < ActiveRecord::Migration def change add_column :order_groups, :email_snippet, :text add_column :orders, :email_snippet, :text end end
Rails.application.routes.draw do get 'pages/aboutus' get 'pages/contact' devise_for :users, :controllers => { registrations: 'registrations' }, path: 'auth', path_names: { sign_in: 'login', sign_out: 'logout', password: 'secret', confirmation: 'verification', unlock: 'unblock', registration: 'register', sign_up:...
require_relative "board" require_relative "piece" require_relative "human_player" require_relative "networked_player" class Checkers def initialize(player1, player2) @board = Board.new @color_of_current_player = :white @players = [player1, player2] end def run until game_over? @board.displ...
module OpenActions class OpenAction # @private def self.demodulize(name) name.split('::').last end def self.inherited(klass) OpenActions.actions[demodulize(klass.to_s)] = klass end # @return [Hash] Accumulated config for this action type. def self.config @config ||= {} ...
#!/usr/bin/env ruby # Encoding: utf-8 # # Copyright 2019 Google LLC # # 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 # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by ...
require 'mp3info' module Mediabumper # ID3 tags parsing library abstraction class TaggedFile def initialize(path) Mp3Info.open(path) do |mp3info| [:title, :artist, :album, :year].each do |key| instance_variable_set :"@#{key}", mp3info.tag.send(key) self.class.send :attr_reader...
# frozen_string_literal: true class User < ApplicationRecord authenticates_with_sorcery! has_many :body_scales, dependent: :destroy end # == Schema Information # # Table name: users # # id :integer not null, primary key # email :string not null # crypted_password :s...
if Rails.env.production? protocol = "https" end C2::Application.config.action_mailer.default_url_options ||= { host: AppParamCredentials.default_url_host, protocol: protocol || "http" } # indicate that this is not a real request in the email subjects, # if we are running in non-production env. # NOTE that stagi...
module Wizardry module Questions # Ask a question that can be answered with one line of text class ShortAnswer < Wizardry::Questions::Answer def initialize(name) Rails.logger.debug("🧙 Adding short question '#{name}'") super end def form_method :govuk_text_field ...
class Translation < ActiveRecord::Base def translate! self.input_text ||= "" self.output_text = "" wordcount = input_text.split(" ").count (wordcount / 1.2).ceil.times do self.output_text += Emoji.random end return self.output_text end end
class EventsController < ApplicationController before_action :authenticate def index @events = Event.where('start_time > ?', Time.zone.now).order(:start_time) end def new @event = current_user.created_events.build end def create @event = current_user.created_events.build(event_parmas) if ...
require 'formula' class Bwa < Formula homepage 'http://bio-bwa.sourceforge.net/' url 'http://downloads.sourceforge.net/project/bio-bwa/bwa-0.6.2.tar.bz2' sha1 'fd3d0666a89d189b642d6f1c4cfa9c29123c12bc' head 'https://github.com/lh3/bwa.git' # These inline functions cause undefined symbol errors with CLANG. ...
module Troles::Adapters::ActiveRecord module Strategy module BaseMany # @param [Class] the role subject class for which to include the Role strategy (fx User Account) # def self.included(base) base.send :include, Troles::Strategy::BaseMany end end end end
class CreateThings < ActiveRecord::Migration def change create_table :things do |t| t.string :description t.integer :vote_code, :null => false t.boolean :active, :default => true t.timestamps end add_index :things, :vote_code end end
class Event < ActiveRecord::Base attr_accessible :event_date, :event_address, :event_name, :event_end, :event_url, :event_author, :event_state, :event_zip_code, :event_description, :event_origin, :latitude, :longitude extend Geocoder::Model::ActiveRecord geocoded_by :full_address after_validation :geocode ...
class Awarding < ActiveRecord::Base validates_presence_of :award, :year belongs_to :award module PeopleExtensions define_method("as") do |role| return self if role_name.blank? role_name = RoleType.its_name(role) self.scoped( # PostgreSQL doesn't allow forward references to joined ta...
class AddPokeTypeToCampaign < ActiveRecord::Migration def change add_column :campaigns, :poke_type, :string, default: 'email' end end
class UsersController < ApplicationController skip_before_action :verify_authenticity_token def new @user = User.new respond_to do |format| format.json { render json: {user: @user}, status: :ok } end end def show begin @user = User.find(params[:id]) respond_to do |format| format.json { render ...
require_relative './../../spec_helper.rb' describe MessageModule::RemoveService do describe '#call' do context "Valid ID" do before do message = create(:message) @removeService = MessageModule::RemoveService.new({"id" => message.id}) end it "Return success message" do ...
class Puppet::Provider::Rbac_api < Puppet::Provider require 'net/https' require 'uri' require 'json' require 'openssl' require 'yaml' CONFIGFILE = "#{Puppet.settings[:confdir]}/classifier.yaml" confine :exists => CONFIGFILE # This is autoloaded by the master, so rescue the permission exception. @co...
require_relative '../backend/rsync' module Susanoo module ServerSync module Syncers class Base include ActiveSupport::Configurable include ServerSync::Helpers::Loggable attr_accessor :server, :sync_files %i(src dest user priority).each do |attr| config_accessor a...
require 'spec_helper' describe Crypto::SecretBox do let (:key) { [0x1b,0x27,0x55,0x64,0x73,0xe9,0x85,0xd4,0x62,0xcd,0x51,0x19,0x7a,0x9a,0x46,0xc7, 0x60,0x09,0x54,0x9e,0xac,0x64,0x74,0xf2,0x06,0xc4,0xee,0x08,0x44,0xf6,0x83,0x89].pack('c*') } # from the nacl distribution context "new" do it "accepts stri...
class AssignmentsController < ApplicationController load_and_authorize_resource # GET /assignments # GET /assignments.json def index respond_to do |format| format.html # index.html.erb format.json { render json: @assignments } end end # GET /assignments/1 # GET /assignments/1.json ...
require 'test/unit' require 'cgiext' require 'cgi' class CGIExtTest < Test::Unit::TestCase def test_escape_html ## escape html characters input = '<>&"\'' expected = '&lt;&gt;&amp;&quot;\'' actual = CGIExt.escape_html(input) assert_equal(expected, actual) assert_equal(CGI.escapeHTML(inpu...
class PriorityQueue def initialize @heap = [] end def add!(x) @heap << x sift_up(@heap.length - 1) self end def peek @heap[0] end def remove!() raise RuntimeError, "Empty Queue" if @heap.length == 0 if @heap.length == 1 @heap = [] else @heap[0] = @heap.pop ...
$:.unshift(File.dirname(__FILE__)) unless $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__))) require 'rubygems' require 'rest_client' require 'cgi' require 'yaml' module Mediawiki VERSION = '0.0.4' def self.search_for_html(wiki_host, term) RestClient.get "#{wiki_host...
module Boilerpipe::SAX class BoilerpipeHTMLParser def self.parse(text) # strip out tags that cause issues text = Preprocessor.strip(text) # use nokogiri to fix any bad tags, errors - keep experimenting with this text = Nokogiri::HTML(text).to_html handler = HTMLContentHandler.new ...
module Errors class AuthenticationMissing < StandardError; end class AppMissing < StandardError; end end
class InstructorsController < ApplicationController def show @instructor = Instructor.find(params[:id]) @courses = @instructor.courses end end
class StoresController < ApplicationController def index @stores = Store.all end def new @store = Store.new end def create @store= Store.new(store_params) if @store.save redirect_to stores_url else puts @store.errors.full_messages render :edit end end...
require './input_functions' require 'colorize' # gem install colorize require 'spreadsheet' # gem install spreadsheet class Track attr_accessor :id, :title, :location def initialize (id, title, location) @id = id @title = title @location = location end end class Album attr_accessor :id, :title, :artist, ...
class ChangeColumnsOnInvoicesForCurrency < ActiveRecord::Migration def change remove_column :invoices, :exchange_rate add_column :invoices, :exchange_rate, :decimal end end
module SecureAttachable extend ActiveSupport::Concern included do before_save :assign_asset_key end def assign_asset_key # self.asset_key ||= generate_asset_key end def generate_asset_key SecureRandom.hex(10) end module ClassMethods def validates_image_attachment attribute vali...
class RemoveProfileFromSchoolChild < ActiveRecord::Migration[5.1] def change remove_reference :school_children, :profile, foreign_key: true end end
require 'csv' require 'xmlsimple' # Compare XML and CSV Result module ParseFile def ParseFile.parser_csv_by_filename filename start_parse = false result = [] CSV.foreach(filename) do |row| if start_parse == true result.push(row.drop(1)) elsif row.leng...
# -*- mode: ruby -*- # vi: set ft=ruby : Vagrant.configure(2) do |config| config.vm.box = "nritholtz/ubuntu-14.04.1" config.vm.hostname = "Teamscale-DEMO-VM" #Display settings config.vm.provider "virtualbox" do |vb| #Display the VirtualBox GUI when booting the machine vb.gui = true ...
require './square.rb' # Represents the chessboard, containing individual squares class Board attr_accessor :squares, :visited, :edge_to # Creates the board with the necessary connections def initialize @squares = [] @visited = [] @edge_to = {} for i in 0..7 for j in 0..7 @squares <<...
class CreateBottoms < ActiveRecord::Migration[6.0] def change create_table :bottoms do |t| t.string :clothing t.timestamps end end end
class Admin::UserKidsController < Admin::BaseController def new @kid = Kid.find(params[:kid_id]) @user_kid = UserKid.new() @users = User.all end def create kid = Kid.find(params[:user_kid][:kid_id]) new_link = UserKid.new(user_kid_params) unless new_link.save flash.alert = "User cou...
Gem::Specification.new do |s| s.name = 'random_string_generator' s.version = '0.0.1' s.date = '2014-01-11' s.summary = "A gem to generate random strings" s.description = "This gem is a great way to generate random strings in Ruby" s.authors = ["Anuja Kelkar"] s.email = 'anujamkelkar@gmail.com' s.files =...
default['vault_certificate'] = { # The cipher that will be used to encrypt the key when :key_encryption_password is set. 'key_encryption_cipher' => 'AES-256-CBC', 'always_ask_vault' => false, # The owner of the subfolders, the certificate, the chain and the private key 'owner' => 'root', # The group of the ...
require 'spec_helper' describe RCI do it 'has a version number' do expect(RCI::VERSION).not_to be nil end end
class Entity < ActiveRecord::Base has_many :transactions has_one :company, :through => :transactions has_many :sales, :foreign_key => :seller_id, :class_name => "Transaction" has_many :sellers, :through => :sales has_many :securities, :through => :transactions has_one :pass has_one :ce_link def sec #e...
namespace :dev do def show_sppiner(msg_start, msg_end = "Concluído!") spinner = TTY::Spinner.new("[:spinner] #{msg_start}...") spinner.auto_spin yield spinner.success("(#{msg_end})") end desc 'Popula banco de dados' task popula_db: :environment do if Rails.env.development? # Popula ...
# frozen_string_literal: true require File.expand_path('config/application', __dir__) Demo::Application.load_tasks namespace :demo do task limit: :environment do puts '=> Creating sidekiq tasks' 100.times do SlowWorker.perform_async FastWorker.perform_async end run_sidekiq_monitoring ...
require_relative '../spec_helper' describe "user can edit from index" do it "they see the form" do Condition.create(date: "01/05/2017", max_temperature_f: "90", mean_temperature_f: "75", min_temperature_f: "19", mean_humidity...
class VehicleConsumption < ActiveRecord::Base belongs_to :vehicle belongs_to :desk_supplie belongs_to :driver end
require_relative 'spec_helper' require 'tdd' require 'rspec' describe '#my_uniq' do let(:test) {(0..4).to_a} let(:testB) { [1,2,1,3,3] } it 'should not remove unique values' do expect(test.my_uniq).to eq([0,1,2,3,4]) end it 'should remove non unique values' do expect(testB.my_uniq...
class ContestsController < AuthController before_filter :admin_filter, only: ['new','edit', 'create', 'update'] before_filter :check_attendance, only: ['show'] # GET /contests def index # 開催期間に当てはまるコンテストだけ表示する @contests = Contest.order(:start_time) end # GET /contests/1 def show @contest = C...
module TicTacToeRZ module Exceptions class GameRuleViolationError < StandardError end end end
# Longest Vowel Chain =begin problem: Given a lowercase string that has alphabetic characters only (both vowels and consonants) and no spaces, return the length of the longest vowel substring. Vowels are any of aeiou. =end def find_substrings(str) substrings = [] (0...str.size).each do |start| (start...str...
class Api::AreasController < ApplicationController respond_to :json def index @areas = Area.all.map { |i| AreaSerializer.new(i).serializable_hash } render json: { success: true, response: @areas } end def events @events = @areas.events.map...
require "application_system_test_case" class MainModelsTest < ApplicationSystemTestCase setup do @main_model = main_models(:one) end test "visiting the index" do visit main_models_url assert_selector "h1", text: "Main Models" end test "creating a Main model" do visit main_models_url cli...
require 'spec_helper' describe Line do it 'initializes a line instance with a name' do test_line = Line.new({'name' => 'blue'}) test_line.should be_an_instance_of Line end it 'gives the line a name' do test_line = Line.new({'name' => 'blue', 'id' => 2}) test_line.name.should eq 'blue' test_l...
# == Schema Information # # Table name: posts # # id :integer not null, primary key # content :text not null # created_at :datetime not null # updated_at :datetime not null # user_id :integer not null # # Indexes # # index_posts_on_user_id ...
module GplusStats module Matchers end end module GplusStats::Matchers::Match def call(html) matches(html) || 0 end protected def matchers private_methods.map(&:to_s).select {|m| m =~ /match_/} end def matches(html) results = matchers.map {|matcher| send(matcher, html) } results.compac...
module BadgeConcerns module UserBadgeable extend ActiveSupport::Concern include BadgeConcerns::SimpleBadgeable included do after_update :award_on_profile_complete end private def award_on_profile_complete award_to(self, :complete_profile) if profile_complete? end end end
require 'rails_helper' RSpec.feature "Users", type: :feature do # テスト実行前に送信メールをクリアする background do ActionMailer::Base.deliveries.clear end def confirmation_url(mail) body = mail.body.encoded body[/http[^"]+/] end scenario "to move sign up" do visit root_path expect(page).to have_http_s...
class PartyHasntPaid < ActiveModel::Validator def validate(order) if order.party.has_paid order.errors[:base] << "This party has already paid." end end end class Order < ActiveRecord::Base belongs_to(:food) belongs_to(:party) validates_with PartyHasntPaid end
require 'rspec' require 'onlyoffice_api' require_relative '../../../libs/app_manager' current_device = 'samsung_s4W' main_page = nil folder_name = nil describe 'open files' do before :all do current_device = AppManager.initial_device(current_device) user_data = AppManager.get_user_data(current_device.name) ...
require 'rubygems' require 'bundler/setup' require 'gosu' ROOT_PATH = File.dirname(File.expand_path(__FILE__)) $LOAD_PATH.unshift(File.join(ROOT_PATH, 'lib')) require 'camera' require 'level/base' require 'config' require 'image_registry' require 'hud/debug' require 'hud/info' require 'hud/health' require 'hud/gameov...
class ModifyUserIdOnItem < ActiveRecord::Migration[6.1] def change remove_column :items, :seller_id add_reference :items, :user, index: true end end
class UsersController < ApplicationController before_action :hide_blogroll, only: [:show] before_action :signed_in_user, only: [:edit, :update, :destroy] #before_action :signed_out_user, only: [:new, :create] before_action :correct_user, only: [:edit, :update, :mood] before_action :admin_user, o...
require 'forced_notification_to_owner/patches/issue_patch' Redmine::Plugin.register :redmine_forced_notification_to_owner do name 'Redmine Forced Notification To Owner plugin' author 'Max Konin' description 'This is a plugin for Redmine' version '0.0.1' end
require 'rails_helper' describe Assessment do it {should have_many(:indications)} it {should have_many(:feelings)} it {should have_many(:competencies)} it {should have_many(:providers)} it {should validate_presence_of(:word)} it {should validate_uniqueness_of(:word)} end
class AddFootballClubs < ActiveRecord::Migration def up create_table :football_clubs do |t| t.string :name t.string :alias t.integer :league t.text :description t.string :web_site t.string :logo t.timestamps end end def down drop_table :football_clubs end...
#!/usr/bin/env ruby # /r/dailyprogrammer 119 Intermediate # Nothing clever, just A*, not short at all... # - UziMonkey class Map attr_accessor :map, :width, :height attr_accessor :start, :end def initialize(ascii) size,map = ascii.split("\n",2) @map = map.split("\n").map do|line| line.split('').m...