text
stringlengths
10
2.61M
# encoding: utf-8 class AccountsController < ApplicationController before_action :not_signed_in?, only: [:show, :edit, :update, :destroy] def new if signed_in? redirect_to root_path else @user = User.new end end def create @user = User.create(account_params) if @user.save ...
class CajasRegistradorasController < ApplicationController before_action :set_caja_registradora, except: [:index, :new, :create] before_action :quitarBandera, :definirControlador def definirControlador @controlador = 'cajas_registradoras' @controladorSingular = 'la caja registradora' end def quitar...
class TransportGpsSetting < ActiveRecord::Base validates_presence_of :client_id, :client_secret, :vendor_name before_save :gps_server_verification # GPS api server handshake to fetch authorization details def gps_server_verification verification_details end def verification_details respo...
class NetworkInterface < ActiveRecord::Base acts_as_authorizable acts_as_audited named_scope :def_scope acts_as_reportable acts_as_commentable belongs_to :node has_many :ip_addresses, :dependent => :destroy # This creates a polymorphic association to Outlet model which can be shared by other int...
require 'rdiscount' #TODO: Fix this stupid require statement. module StaticContent class Content < ActiveRecord::Base validates :slug, :text, presence: true validates :slug, uniqueness: true def self.from_slug(slug, options={}) raise ArgumentError.new("You must provide a default text for a content...
class RemoveTicketPriceFromEvents < ActiveRecord::Migration def change remove_column :events, :ticket_price, :string end end
require 'dm-migrations' # module DataMapper # module Migrations # module SingletonMethods # def repository_execute(method, repository_name) # models = DataMapper::Model.descendants # puts "model: #{models}" # models = models.select { |m| m.default_repository_name == repository_name ...
module WillPublish module Attributes SYSTEM_ATTRIBUTES = %w(id created_at updated_at is_published_version) class << self def filtered_attributes(attrs, only, except) attrs.reject!{|k,v| !only[:attributes].include?(k.to_sym) } unless only.blank? || only[:attributes].blank? attrs.reject!...
# frozen_string_literal: true RSpec.describe 'Event List Request', type: :request do include_context 'with event' include_context 'with branch location' include_context 'with json response' subject(:index_all!) { get '/api/events', params: params } let(:params) { nil } let(:last_year_event) do build(...
class CreatePosTables < ActiveRecord::Migration def change create_table :products do |t| t.column :name, :string t.column :price, :float end create_table :cashiers do |t| t.column :name, :string t.column :password, :string end create_table :purchases do |t| t.column...
module SpecHelpers def login_as(user, redirect = nil) redirect = redirect ? "?redirect=#{redirect}" : '' visit "/login#{redirect}" fill_in 'E-mail', with: user.email fill_in 'Senha', with: 'testdrive' click_button 'Acessar minha conta' end def click_with_alert(target) page.accept_alert...
class FontVollkornSc < Formula head "https://github.com/google/fonts.git", verified: "github.com/google/fonts", branch: "main", only_path: "ofl/vollkornsc" desc "Vollkorn SC" homepage "https://fonts.google.com/specimen/Vollkorn+SC" def install (share/"fonts").install "VollkornSC-Black.ttf" (share/"fonts...
class ProfileController < ApplicationController before_action :authenticate_user! before_action :ensure_signup_complete, only: [:index, :new, :create, :update, :destroy] before_action :set_user, only:[:index, :show, :edit, :update, :finish_signup, :change_role] before_action :make_payment_services, only: [:inde...
#!/usr/bin/env ruby # encoding: ascii-8bit require 'pry' require 'yweather' require 'weather_prowl' PRIORITY_THRESHOLD = WeatherProwl::PRIORITY[:normal] LOW_TEMP_THRESHOLD = 15 HIGH_TEMP_THRESHOLD = 100 yweather_client = Yweather::Client.new weather = yweather_client.get_response_for_zipcode(ARGV.shift) priority = W...
$LOAD_PATH.unshift(File.dirname(__FILE__)) require 'directors_database' require 'pp' def directors_totals(nds) # Remember, it's always OK to pretty print what you get *in* to make sure # that you know what you're starting with! # # # The Hash result be full of things like "Jean-Pierre Jeunet" => "22231212312...
# 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 rake db:seed (or created alongside the db with db:setup). # # Examples: # # cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }]) # Mayor.create(name: 'Emanuel...
# frozen_string_literal: true require 'rails_helper' RSpec.describe Bank, type: :model do it { is_expected.to respond_to :name } it { is_expected.to validate_presence_of :name } it { is_expected.to validate_uniqueness_of :name } it { is_expected.to respond_to :code } it { is_expected.to validate_presence_o...
module RestClient VERSION_INFO = [2, 0, 2] unless defined?(self::VERSION_INFO) VERSION = VERSION_INFO.map(&:to_s).join('.') unless defined?(self::VERSION) def self.version VERSION end end
module FishTank # Generic Tetrapod class Taxon::Tetrapod < FishTank::Taxon # TODO: Update UBERON terms to represent actually meaningful layout, this was cloned from Fish def description return { 'UBERON_0001703' => [10, 0, 10, 9], # 'neurocranium' 'UBERON_0000970' => [8, 3, 4, 4],...
class AddSocialMediaUrlsToPerson < ActiveRecord::Migration def self.up add_column :people, :flickr_url, :string add_column :people, :twitter_url, :string add_column :people, :facebook_url, :string add_column :people, :linked_in_url, :string end def self.down remove_column :people, :linked_in_...
class ApplicationMailer < ActionMailer::Base default from: 'no_reply@todo.com' layout 'mailer' end
require 'rails_helper' describe Movie, type: :model do subject { build(:movie) } it 'should have a valid factory' do expect(subject).to be_valid end describe 'Associations' do it { should belong_to(:query) } end describe 'Validations' do it { should validate_presence_of(:tmdb_id) } it { ...
class Rental < RentalBase include PriceService def update_attributes params params.each do |attr_key, attr_value| instance_variable_set(attr_key, attr_value) end end def delta_from_amounts old_amounts, new_amounts old_amounts.map do |actor, amount| [actor, amount - new_amounts[actor]] ...
# Virus Predictor # I worked on this challenge [by myself, with: ]. # We spent [#] hours on this challenge. # EXPLANATION OF require_relative # # #require_relative 'state_data' class VirusPredictor # Creates a new instance and sets the arguments equal to instance variables def initialize(state_of_origin, populat...
require 'rails_helper' def sign_up visit root_path within '.sign-up-form' do fill_in :user_username, with: 'user' fill_in :user_email, with: 'test@galvanize.it' fill_in :user_password, with: 'password' fill_in :user_password_confirmation, with: 'password' click_on 'Sign up' end end def sig...
class ParticipatingSchoolsController < ApplicationController def index @schools = School.participating.with_location_info.order('town_id, name') end def show @school = School.find(params[:id]) @school_events = events_scope_for(@school).newest_first @pending_events_count = @school.pending_events.c...
json.array! @events do |event| date_format = event.is_all_day? ? '%Y-%m-%d' : '%Y-%m-%dT%H:%M:%S' json.id event.id json.title (current_user.present? && (current_user.id == event.user_id || current_user.id == @stadium.user_id)) ? event.user.name : "Занято" json.start event.start.strftime(date_format) json.end ...
module Orientdb class RecordId attr_reader :cluster, :position alias_method :eql?, :== def initialize(rid=nil) @cluster = nil @position = nil if rid.is_a? String and not rid.empty? parse_rid(rid) elsif rid.is_a? Orientdb::RecordId @cluster = rid.cluster @...
class SiteController < ApplicationController before_filter :authorize def index current_user gon.rabl "app/views/site/user.json.rabl" end end
require 'rails_helper' RSpec.describe SupplyTeachers::Admin::CurrentData, type: :model do describe '#validations' do context 'when no instances exist' do it 'validation fails' do expect(build(:supply_teachers_admin_current_data)).to be_valid end end context 'when one instance already...
# -*- coding: utf-8 -*- # Url 関係設定. module OpensocialWap module Config # # 実行時にURLを決定したいときの設定 Gree # class GreeDynamicUrl < DynamicUrl def initialize(context, sandbox) @context = context @sandbox = sandbox end def container_host if request.respond_to?(:mobil...
FactoryGirl.define do factory :account, class: Account do name nil contractor_id nil balance 0 min_balance 0 max_balance 0 origination_capacity 0 termination_capacity 0 end end
class CreateGoalevents < ActiveRecord::Migration[6.0] def change create_table :goalevents do |t| t.references :goal, null: false, foreign_key: true t.references :player, null: false, foreign_key: true t.integer :assist t.float :startdepth t.float :startwidth t.float :enddepth ...
class AddGameIdToHumen < ActiveRecord::Migration[5.2] def change add_column :humen, :game_id, :integer end end
# This is a simplified controller spec, mainly illustrating how one might # ensure that the controller's methods are properly locked down from # unauthorized access. require 'spec_helper' describe Admin::UsersController do describe 'user access' do before :each do user = User.create( email: 'adm...
class DashboardController < ApplicationController def index @tasks = Task.all.sort_by {|t| t[:created_at]} @upcoming_quotations = Quotation.where('event_date >= ? AND status = ?', Date.today, STATUS_CONFIRMED).order('event_date ASC') @pending_payments = Quotation.select(:client_id).where(status: STATUS_I...
module Graphlient module Errors class GraphQLError < Error attr_reader :response def initialize(response) super('the server responded with a GraphQL error') @response = response end def errors @response.errors end def to_s errors.details.map do...
# frozen_string_literal: true class GradingPalletsController < ApplicationController before_action :set_grading_pallet, only: %i[show edit update destroy] def index @grading_pallets = GradingPallet.active end def show; end def new @grading_pallet = GradingPallet.new end def edit; end def c...
require 'test_helper' class TeamSeasonsControllerTest < ActionDispatch::IntegrationTest setup do @team_season = team_seasons(:one) end test "should get index" do get team_seasons_url assert_response :success end test "should get new" do get new_team_season_url assert_response :success ...
# cd /var/www/test/headfirstpatterns/ch01/SimUDuck02 # ruby -I lib duck.rb require 'duck' require 'flyable' require 'quackable' class MallardDuck < Duck include Flyable include Quackable def display puts ":MallardDuck:".downcase end end class RedheadDuck < Duck include Flyable include Quackable d...
#!/usr/bin/env ruby # encoding: utf-8 class A # 2) def self.inherited(child) p "#{self} は #{child} に継承されたよ" end end class B < A end __END__
class MessageMailer < ApplicationMailer default from: "noreply@brxyxmp.xyz" default to: "brxyxmp@gmail.com" def new_message(message) @message = message mail subject: "Message from #{message.name}" end end
require 'rubygems' require_relative 'spec_helper' describe "Rack::Validator test" do it "should trim all params" do params = {"one" => " before", "two" => "after ", "three" => " everywhere ", "four" => nil} validator = Rack::Validator.new(params, false) validator.trim("one") validator.trim("two") v...
class AddOrderCountToOrders < ActiveRecord::Migration[5.2] def change add_column :orders, :oder_count, :intrger end end
class CreateFinanceTaxPayments < ActiveRecord::Migration def self.up create_table :tax_payments do |t| t.references :taxed_entity, :polymorphic => true, :null => false t.references :taxed_fee, :polymorphic => true, :null => false t.decimal :tax_amount, :precision => 10, :scale => 4 t.ref...
require_relative 'manufacturer' require_relative 'instance_counter' require_relative 'validation' # common Wagon methods class Train include InstanceCounter include Manufacturer include Validation TRAIN_NUMBER_FORMAT = /^[a-z\d]{3}(\-[a-z\d]{2})?$/i.freeze TRAIN_TYPES = %i[cargo passenger].freeze ...
class Item < ApplicationRecord extend ActiveHash::Associations::ActiveRecordExtensions belongs_to :user has_one :order has_one_attached :image belongs_to_active_hash :category belongs_to_active_hash :shippingcharges belongs_to_active_hash :scheduleddelivery belongs_to_active_hash :sender belongs_to_ac...
require 'spec_helper' describe QML do it 'should have a version number' do expect(QML::VERSION).not_to be_nil end end
class Article < ActiveRecord::Base belongs_to :user has_many :comments validates :user_id, presence: true validates :title, presence: true validates :perma_link, presence: true, uniqueness: true paginates_per 10 end
class User < ActiveRecord::Base include Humanity::Base has_many :emails has_many :permits has_many :groups, through: :permits belongs_to :group alias_attribute :netid, :username scope :custom_search, -> query { fields = %w{username first_name last_name full_name users.title users.department email u...
class AdminSearchController < ApplicationController before_filter :authenticate_user! before_filter :except => [:delete_files] do |controller_instance| controller_instance.send(:valid_role?, User::ROLES[:process_files]) end before_filter :only => [:delete_files] do |controller_instance| controller_insta...
class Usertime < ActiveRecord::Base COLORS = ["#000099","#CCCCCC","#009999","#990000","#009900","#00FFFF","#990099","#999900","#999999","#0000FF","#00FF00","#FF0000","#FF00FF","#FFFF00" ] NUMCOLS = Usertime::COLORS.length belongs_to :user, :class_name =>"Goldberg::User" def self.buildtimes(user) times = ...
FactoryGirl.define do factory :client_document_notification do days {Faker::Number.number(3)} end end
# == Schema Information # Schema version: 20090522150930 # # Table name: filing_infos # # id :integer(4) not null, primary key # desigOfficerWardorCircle :string(255) # returnFileSec1 :integer(4) # returnType1 :string(255) # origRetFileDate :date # receip...
class AddPublishedAtToTips < ActiveRecord::Migration def change add_column :tips, :published_at, :timestamp end end
require "rails_helper" RSpec.describe PlaylistsController, type: :controller do describe "GET #index" do it "assigns all playlists as @playlists and renders the index template" do playlist = Playlist.create(name: "Jones") get(:index) expect(assigns(:playlists)).to eq([playlist]) expect(...
describe Project, type: :model do it { is_expected.to belong_to(:developer) } it { is_expected.to validate_presence_of(:name) } it { is_expected.to validate_presence_of(:release_date) } it { is_expected.to validate_presence_of(:developer) } context 'with @kind' do Project.kinds.keys.each do |kind| ...
# Copyright 2014 Square Inc. # # 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 # # Unless required by applicable law or agreed ...
source 'https://rubygems.org' #<<<<<<< HEAD # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' gem 'rails', '4.1.0' # Use sqlite3 as the database for Active Record # gem 'sqlite3' # uncomment this if it errors out group :development do gem 'sqlite3' end group :production do gem 'pg' gem 'rails_12fa...
module DepartmentsHelper def print_summary_title(item) link_to item.title.size > 16 ? item.title.first(13) + '…' : item.title, item_path(item) end def print_summary_creator(item) item.creator.size > 16 ? item.creator.first(13) + '…' : item.creator end def print_selected_...
## Ejercicio 2: Arrays y strings #Dado el arreglo #~~~ruby nombres = ["Violeta", "Andino", "Clemente", "Javiera", "Paula", "Pia", "Ray"] #~~~ #Se pide: #1. Extraer todos los elementos que excedan mas de 5 caracteres utilizando el método *.select*. new_array = nombres.select{ |e| e.length > 5 } puts new_array puts "f...
class MakeChangesToValidation < ActiveRecord::Migration[5.2] def change remove_column :direct_messages, :is_slacker remove_column :memberships, :member_id remove_column :memberships, :channel_id remove_column :direct_messages, :body remove_column :direct_messages, :receiver_id end end
class SchoolsController < ApplicationController def new @school = School.new end def create @school = School.new(school_params) @school.user = current_user if @school.save redirect_to pages_dashboard_path, notice: "School created" else render 'new' end end private def...
###--------------------------------------------------------------------------### # CP Pop-ups script # # Version 1.2a # # ...
require 'rails_helper' RSpec.describe Post, type: :model do it "値を代入すると無事登録されること" do testdata="試験投稿" post=Post.new( content: testdata, ) expect(post.test).to eq testdata end end
class SnippetsChannel < ApplicationCable::Channel def subscribed stream_from 'snippets' end end
# frozen_string_literal: true module Decidim module Opinions # Exposes the opinion resource so users can view and create them. class OpinionsController < Decidim::Opinions::ApplicationController helper Decidim::WidgetUrlsHelper helper OpinionWizardHelper helper ParticipatoryTextsHelper ...
class ProfileController < ApplicationController def show end def update user_params = params.require(:user) user = current_user user.first_name = user_params[:first_name] user.last_name = user_params[:last_name] user.timezone = user_params[:timezone] || User::DEFAULT_TIMEZONE user.save! ...
require 'ipaddress' module ChefAB class TimeIPBasedUpgrader < BaseUpgrader include IPmetric attr_accessor :start_time, :period attr_accessor :initial_ip def initialize(options) options[:node_id] = ip_metric(options[:initial_ip], options[:node_id]) super(options) @start_time = opt...
class AnnualSummary < Prawn::Document def initialize super({:page_size => 'A4', :page_layout => :landscape}) @terms = Term.where(year: '2016') @level = Level.find_by(name: '12') @grades = Grade.where(level_id: @level.id, year: '2016') @markpercents = Markpercent.where(level_id: @level.id) ...
=begin * Graph * Description :Handles all operation done on the graph * Author:Ignacio Ferrero =end require "rubygems" require_relative 'AddInfo.rb' class Graph #Global variable with all the information :nodes and vertex attr_accessor :parse @parse = {} def initialize(graph_parse) @parse = graph...
require_relative '../../spec_helper' collector_installer_type = Puppet::Type.type(:collector_installer) describe collector_installer_type do let :params do [ :description, :install_dir, :architecture, :account, :access_id, :access_key ] end it 'should have the expected parameters' do expect(collector_i...
class Question < ActiveRecord::Base validates :question_text, presence: true validate :check_answer def check_answer if answers.empty? errors.add(:answers, "can't be empty") end end end
require 'bundler/setup' require 'rdkafka' require 'json' def load data = [] if File.file?("#{Dir.pwd}/data/consumer_orders.json") file = File.read("#{Dir.pwd}/data/consumer_orders.json") data = JSON.parse(file) end data end def save(new_order) data = load data << new_order File.open("#{Dir.pw...
module Fog module Bluebox class Real require 'fog/bluebox/parsers/get_flavor' # Get details of a flavor # # ==== Parameters # * flavor_id<~Integer> - Id of flavor to lookup # # ==== Returns # * response<~Excon::Response>: # * body<~Array>: # TODO ...
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), 'submodules', 'fakefs', 'lib') require 'ruby_parser' require 'fakefs/safe' class TryRubyBaseSession def reset self.start_time = Time.now self.current_statement = [] self.nesting_level = 0 self.past_commands = [] end def calculate_nesting_level...
require 'pry' # # # def numeral(num) # numeral_hash = {"I": 1, "V": 5, "X": 10, "L": 50, "C": 100, "D": 500, "M": 1000} # # sum = 0 # counter = 0 # # while counter < num.length # sum += numeral_hash[num[counter].to_sym] # counter +=1 # end # # sum # end # # # puts numeral("MDCCC") class Numeral...
class CreateFollowups < ActiveRecord::Migration def change create_table :followups do |t| t.string :internet_type t.string :internet_speed t.integer :monthly_cost t.string :community_name end add_foreign_key :users, :details end end
require( "pry-byebug" ) require_relative("fish.rb") class River attr_accessor :list_of_fish def initialize( list_of_fish ) @list_of_fish = list_of_fish end def missing_fish( index_begining, list) number = index_begining - list.length text = "#{number} fish is missing" return text end ...
require "rails_helper" RSpec.describe Api::V1::InvoiceItemsController do before(:each) do merchant = Merchant.create( name: "Bob's House of Boats" ) customer = Customer.create( first_name: "Dave", last_name: "Chappelle" ) @invoice = Invoice.create( customer_id: customer....
require 'rails_helper' feature 'Test 5' do let(:user) { create :user, email: 'weronika.rudowicz@netguru.com' } before do allow_any_instance_of(PagesController).to receive(:authenticate_user!).and_return(true) allow_any_instance_of(PagesController).to receive(:current_user).and_return(user) end scenar...
class CommentRatingsController < ApplicationController before_filter :org_access_only def create provider = Provider.find(params[:provider_id]) comment_id = params[:comment_id] helpful = ( params[:commit] == 'Yes' ) comment_rating_id = CommentRating.add_rating(comment_id, current_user, helpful) ...
require 'digest/md5' class Gravatar def initialize(emails) @hashes = emails.map { |email| hash(email) } end def urls @hashes.map do |hash| "http://www.gravatar.com/avatar/#{hash}?d=404&s=150" end end private def hash(email) Digest::MD5.hexdigest(email.downcase.strip) end end
require 'test_helper' class UserTest < ActiveSupport::TestCase def setup User.create(username: "DuckForQuack", email: "test@example.com", password: "password", password_confirmation: "password") @user = User.new(username: "JohnDoe", email: "john@doe.com", password: "password", password_confirmation: "pass...
#!/usr/local/bin/ruby require 'net/http' require 'net/http' require 'hpricot' require 'uri' require 'cinch' class Weather include Cinch::Plugin match /weather (.+)/ def execute(m,location) location=location.gsub(' ','+') xml=Net::HTTP.get(URI.parse("http://www.google.com/ig/api?weather=#{location}")) ...
require 'csv' require 'yaml' section_names = [ '1면', '정치', '정치', '정치', '자치행정', '자치행정', '전면광고', '국제통일', '금융', '금융', '전면광고', '금융', '금융', '산업', '산업', '산업', '산업', '정책', '정책', '기획', '기획', '오피니언', '오피니언', '전면광고' ] Category.parse h = {} h[:name] = '내...
require 'narp/node_extensions.rb' require 'narp/basic_extensions.rb' module Narp class Join < Treetop::Runtime::SyntaxNode def value w = text_value.strip.squeeze(" \t").downcase.sub(/\/join unpaired\s*/, '') case w when 'leftside' 'left join' when 'rightside' 'right join'...
=begin #qTest Manager API Version 8.6 - 9.1 #qTest Manager API Version 8.6 - 9.1 OpenAPI spec version: 8.6 - 9.1 Generated by: https://github.com/swagger-api/swagger-codegen.git =end require 'date' module SwaggerClient class UserProfile # ID of the User attr_accessor :user_id # ...
class CommentDecorator < ApplicationDecorator delegate :text delegate :avatar, to: :user, prefix: true def commented_by "#{user.full_name} | #{h.time_ago_in_words(object.created_at)} ago" end private def user @_user ||= object.user.decorate end end
class ContratoAprovadoReport < Prawn::Document def to_pdf(aprovado) template = "#{Rails.root}/public/contratos/contrato_aprovado.pdf" Prawn::Example.generate("contrato_matricula.pdf", :template => template) do end end end
require File.dirname(__FILE__) + '/../test_helper.rb' require 'ostruct' class TestUnpackable < Test::Unit::TestCase TEST_MOD = StructPacking::Unpackable def setup end class ClsIntNoAttr include TEST_MOD self.byte_format = "uint32_t packtestint;" end def test_unpack_undefined_field_int ...
class IndustryController < ApplicationController before_action :authenticate_region! before_action :set_industry helper_method :brands_ids # before_action :region_updowns def show @regions = get_regions(@region) @current_region = @region @categories = @industry.category.children.order(:id).tagge...
#!/usr/bin/env ruby # Solution for The 3n + 1 Problem by @alfyboza abort 'Expecting input via STDIN.' if STDIN.tty? def parse(n) unless n == 1 if (n & 1) == 1 [n] + parse(3 * n + 1) else [n] + parse(n / 2) end else [n] end end STDIN.each_line do |line| start, stop = line.split.map...
Gem::Specification.new do |s| s.name = 'rtask-db-drop-connections' s.version = '1.0.5' s.date = '2016-03-02' s.summary = 'Add db:drop_connections rake task to Rails Application' s.description = 'Add db:drop_connections rake task to Rails Application' s.authors = ['Alex Kalini...
class TaskMailer < ApplicationMailer default from: 'taskcontrol@gmail.com' def creation_email(task) @task = task mail( subject: 'タスク完了メール', to: '1231.not.0101.indigo@gmail.com', from: 'taskcontrol@gmail.com' ) end end
#!/usr/bin/ruby # This example demonstrates the facade pattern in the Ruby language. class Facade def initialize @subsystems = [ConcreteSubsystemOne.new, ConcreteSubsystemTwo.new] end def start_subsystems returnstring = "" for subsystem in @subsystems returnstring += subsystem.start end ...
class AddFieldsToStudents < ActiveRecord::Migration[6.0] def change add_column :students, :given_name, :string add_column :students, :family_name, :string add_column :students, :student_number, :string add_column :students, :photo, :string add_column :students, :given_name_kanji, :string add_c...
require 'rails_helper' include Warden::Test::Helpers RSpec.describe "Private::Conversations", type: :request do let(:sender) { create(:user) } let(:recipient) { create(:user) } let(:new_post) { create(:post, user: recipient) } let(:conversation) { build(:private_conversation, sender: sender, recipient: recipie...
# Rakefile require 'rubygems' require 'rake' require 'echoe' Echoe.new('parent_resource', '0.1.0') do |p| p.description = "Infers a \"parent\" resource for nested resources from the url path." p.url = "http://github.com/stevegraham/parent_resource" p.author = "Steve Graham" p.email ...
class ViewCount < ActiveRecord::Base belongs_to :viewable, :polymorphic => true validates_uniqueness_of :ip_address, :scope => [:viewable_id, :viewable_type] acts_as_geocodable def to_location begin Graticule.service(:host_ip).new.locate(self.ip_address) rescue => e Rails.logger.warn ...