text
stringlengths
10
2.61M
Factory.define :user do |u| u.sequence(:user_name) { |a| "user#{a}" } u.email { |a| "#{a.user_name}@mailinator.com" } u.password { |a| "pass_#{a.user_name}" } u.password_confirmation { |a| a.password } end Factory.define :owner, :class => :owner, :parent => :user do |o| o.sequence(:user_name) { |s| "owner#{s...
class FFProbe class PacketInfo < Entity attr_accessor :codec_type, :stream_index, :pts, :pts_time, :dts, :dts_time, :size, :file_pkt_nb, :stream_pkt_nb, :duration_ts, :duration_time, :flag_key units :pts_time => "s", :dts_time => "s", :size => "byte"...
class Shop < ApplicationRecord belongs_to :shopping_center, class_name: 'ShoppingCenter' validates :name, presence: true, length: { maximum: 50 } validates :address, allow_blank: true, length: { maximum: 50 } validates :opening_hours, length: { maximum: 50 }, allow_blank: true validates :regular_holiday, l...
class AddOwnerToComments < ActiveRecord::Migration[5.0] def change add_column :comments, :user_id, :integer, default: 1 end end
class PriceUpdate < ApplicationRecord belongs_to :station def disallow self.current = false save end def set_as_current self.current = true save end end
# == Schema Information # # Table name: friendships # # id :integer not null, primary key # friender_id :integer not null # friendee_id :integer not null # created_at :datetime not null # updated_at :datetime not null # class Friendship < ActiveRecord::Base ...
# frozen_string_literal: true module Vedeu module Cells # Provides the character/escape sequence to draw one cell of a # border with a custom value, colour and style. # # @api private # class Border < Vedeu::Cells::Empty extend Forwardable def_delegators :geometry, ...
class Notebook < ActiveRecord::Base validates :user_id, :title, presence: true belongs_to(:user, class_name: "User", foreign_key: :user_id, primary_key: :id ) has_many :notes, class_name: "Note", foreign_key: :notebook_id, primary_key: :id, dependent: :destroy def is_owner?(user) ...
# => # => Author:: Valentin, DanAurea # => Version:: 0.1 # => Copyright:: © 2016 # => License:: Distributes under the same terms as Ruby # ## ## Classe permettant de créer un controlleur pour la vue FenetreCharger ## class ChargerControleur < Controller ## ## Initialize ## def initiali...
require 'minitest/autorun' class Ball8Tests < MiniTest::Unit::TestCase def setup @ball8 = Ball8.new end def test_the_truth assert_equal true, @ball8.is_the_truth_true? end def test_tdd_is_worth_every_minute_of_your_time assert @ball8.is_tdd_worth_every_minute? end def test_windows_is_bette...
require 'rails_helper' RSpec.describe User, type: :model do it { is_expected.to validate_presence_of :name } it { is_expected.to validate_presence_of :level } it { is_expected.to validate_numericality_of :level } it { is_expected.to validate_inclusion_of(:level).in_range(5..40) } it { is_expected.to validate...
# frozen_string_literal: true require 'spec_helper' require_relative '../../tasks/initialize.rb' describe TerraformInitialize do describe "#initialize" do let(:terraform_out) { "Terraform message" } let(:terraform_err) { "" } let(:terraform_code) { 0 } let(:terraform_response) { [terraform_out, terr...
# # Methods placed in this module can be used inside of any view. # View helpers allow you to encapsalate complex logic and keep your # views pristine. # module ViewHelpers def code(language) "<script type='syntaxhighlighter' class='brush: #{language}'>" end def endcode "</script>" end end
class Deck include Celluloid attr_accessor :cards def initialize @cards = (1..100).to_a.shuffle end def deal_card(player) card = @cards.pop player.cards.push card end end
module Restfulie::Client::Feature class SslVerifyModeRequest def initialize(mode = OpenSSL::SSL::VERIFY_NONE) @mode = mode end def execute(flow, request, env) env[:ssl_verify_mode] = @mode flow.continue(request, env) end end end
class HomeController < ApplicationController # We use state instead skip_before_action :verify_authenticity_token, only: :redirect def index # Save to session for verification session[:state] = SecureRandom.hex(24) end def redirect @state = params[:state] @code = params[:code] @id_token...
# By using the symbol ':user', we get Factory Girl to simulate the User model. # USERS Factory.define :user do |user| user.name "MichaelHartl" user.email "mhartl@example.com" user.password "foobar" user.password_confirmation "foobar" end Factory.sequence :name do ...
require 'test_helper' class InternetsControllerTest < ActionController::TestCase setup do @internet = internets(:one) end test "should get index" do get :index assert_response :success assert_not_nil assigns(:internets) end test "should get new" do get :new assert_response :success ...
class Fish attr_accessor :fish_name def initialize(name) @fish_name = name end end
# frozen_string_literal: true require './lib/constant' class ToyRobot attr_reader :position, :direction, :table def initialize(table) raise TypeError, 'Invalid table' if table.nil? @table = table end # Places the robot on the table in position X,Y and facing NORTH, SOUTH, EAST or WEST def place(x...
# 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...
require 'maws/mash' unless defined? SPEC_PATH SPEC_PATH = File.dirname(__FILE__) # for testing purposes, it's like the whole application lives inside tmp/spec_maws_root/ folder SPEC_BASE_PATH = File.expand_path(SPEC_PATH + "/../tmp/spec_maws_root") BASE_PATH = SPEC_BASE_PATH KEYPAIRS_PATH = SPEC_BASE_PATH ...
class Genre < ActiveRecord::Base validates_presence_of :title validates_uniqueness_of :title has_many :movies end
class Topic < ApplicationRecord has_many :posts def self.search(search) Topic.where("name like ?", "%#{search}%") end end
require "rubygems" require "test/unit" require "truby_license" class Fixnum def seconds self end def minutes 60 * seconds end def hours 60 * minutes end def days 24 * hours end def weeks 7 * days end def months 30 * days end def years 365 * days end def from_now...
$:.unshift File.dirname(__FILE__) require 'bundler' require 'delayed/tasks' require 'lib/youtube_multiple_dl' namespace :jobs do task :environment do Database.connect end end namespace :db do desc 'Migrate the database' task :migrate do Database.migrate end desc 'Rollback previous migration...
module TierOneFireMoves def self.singe_1 { name: "Singe", type: "damage", realm: "ethereal", element: "fire", power: 10.0, cost: 2, effect1: ["dot", "hp", -1, 1, 3], effect2: "", cooldown: 1, cooldown_total: 1, rank: 1, tie...
class Project::File attr_accessor :id, :name, :url def initialize(id, name, url) @id = id @name = name @url = url end end
class ApiController < ActionController::Base protect_from_forgery with: :null_session skip_before_action :verify_authenticity_token before_action :verify_api_key private def verify_api_key authenticate_or_request_with_http_token do |token, options| ApiKey.exists?(access_token: token) end end...
class DropKeywords < ActiveRecord::Migration def change drop_table :keywords end end
require 'spec_helper' describe Rack::Casual::Client do CAS_URL = "http://localhost:8080" TICKET = "ST-1283452541rB0287BFA91EA6854CF" SERVICE_URL = "http://localhost" before :all do Rack::Casual.setup do |config| config.cas_url = CAS_URL end end let(:client) { Rack::Casual::Clie...
# frozen_string_literal: true # CreateMapPositions class CreateMapPositions < ActiveRecord::Migration[5.2] def change create_table :map_positions do |t| t.string :title t.string :latitude t.string :longitude t.timestamps end end end
module CalculateStatistic MAIN_FIELDS = %w[ labor_productivity production labor_intensity proceed gain coefficient_of_turnover coefficient_of_wear turnover_ratio reception_staff_ratio factor_disposal_personnel staff_stability_factor financial_stability_ratio autonomy_ratio coe...
require 'rails_helper' RSpec.describe "friendships/new", type: :view do before(:each) do assign(:friendship, Friendship.new( :to_id => 1, :from_id => 1, :approved => false )) end it "renders new friendship form" do render assert_select "form[action=?][method=?]", friendships_p...
require 'rails_helper' RSpec.feature 'Viewing your schools', skip: 'Disabled for 30 Jun 2021 service closure' do include ActionView::Helpers::TextHelper let(:responsible_body) { create(:trust, :manages_centrally) } let(:schools) { create_list(:school, 3, :with_preorder_information, :with_headteacher_contact, :w...
class CourseLicense < ApplicationRecord belongs_to :course belongs_to :instructor belongs_to :school end
# frozen_string_literal: true # Returns a ResultSet with canary/skipped-target errors for each Target provided. # # This function takes a single parameter: # * List of targets (Array[Variant[Target,String]]) # # Returns a ResultSet. Puppet::Functions.create_function(:'canary::skip') do dispatch :skip_result do p...
class Interface attr_accessor :main_menu_answer, :move_answer, :action def interface initialize_participants loop do main_menu if action.player.game_played >= 1 exit(0) if main_menu_answer == 0 new_game loop do game_end if action.game_ended? break if action.game_en...
require 'fog/core/model' module Fog module Compute class Aliyun class Volume < Fog::Model # "ImageId": "", # "InstanceId": "", # "OperationLocks": { # "OperationLock": [] # }, # "Portable": true, # "ProductCode": "", # "RegionId": "cn-qing...
class IngredientsController < ApplicationController before_action :authenticate_user! def index @ingredients = Ingredient.where(account: current_user.account).order(:name) end def show @ingredient = Ingredient.find_by(id: params[:id], account: current_user.account) end def new @ingredient = I...
require "rails_helper" RSpec.describe TasksController, type: :controller do let(:task) {Task.create(name: "Test", complete: false)} let(:complete_task) {Task.create(name: "Test", complete: true)} let(:task_params) { task_params = { name: "Test", complete: true} } describe 'GET index' do before do ta...
require 'json' require 'nokogiri' module Cb class ApplicationApi ############################################################# ## Get an application for a job ## ## For detailed information around this API please visit: ## http://api.careerbuilder.com/ApplicationInfo.aspx ########################...
require 'rails_helper' RSpec.describe Admin, type: :model do let(:admin) { Admin.new(email: "leo@correa.com", password: "password", password_confirmation: "password") } it "requires an email" do admin.email = nil expect(admin).to be_invalid end end
class LocationsController < ApplicationController def index result = Geocoding.new(params[:address]).location if result.success? render json: result, status: 200 else render json: { error: result.message }, status: result.code end end end
class CreateAttempts < ActiveRecord::Migration[5.2] def change create_table :attempts do |t| t.references :user, null: false, foreign_key: true t.references :test, null: false, foreign_key: true t.integer :score, null: false, default: 0 t.boolean :finished, null: false, default: false ...
module Swow class ParseTimestamps < ::Faraday::Response::Middleware def initialize(app, options = {}) @min_timestamp = bnet_timestamp(Time.new(2000, 1, 1).to_i) @max_timestamp = bnet_timestamp(Time.now.to_i + 3600 * 24 * 30) super(app) end def call(env) response = @app.call(env) ...
class DonationHistory < ApplicationRecord # Relationships # ----------------------------- belongs_to :constituent, :foreign_key => :lookup_id, :primary_key => :lookup_id belongs_to :donation_program # test # Scopes # ----------------------------- # This is a test. # Validations # ----------------...
require 'rails_helper' describe "landing page " do it "should say Hanger Management" do visit root_path expect(page).to have_content('Hanger Management') end it "should contain a search button" do visit root_path expect(page).to have_button('Search') end end describe "...
require 'mongo' def datetime_to_mongo(dt) Time.utc(dt.year, dt.month, dt.day, dt.hour, dt.min) end class ArticleStore include Mongo attr_reader :articles, :entities def initialize @db = MongoClient.new('localhost', 27017).db('lnexplorer') @articles = @db.collection('articles') @entities = @db.co...
require "spec_helper" describe FacebookFriendResults do let(:access_token) { "CAAHZBbNfO3DQBAMYCB3YYtuBUogGgcTH7X4Sz4cHFoXEt4VZCjbDHDQODPT5pXRIzcRGCLemzeSjb282wRZAAD1UZCCGSECZCNgbOa62jWx9hxPHpxdAdAAl9IHtEwvpoHrR7EzUWFAMeH9fJBIkmEaOie44TXoizbmbHWfZACtdZAz6Vt279CGua3MZB9szqWCRj1PB4BtmfHEky00wlmlO" } let(:user) { Use...
require 'spec_helper' describe SitesController do include Devise::TestHelpers integrate_views before :each do @owner = Factory.create(:owner) @owner.confirm! sign_in :user, @owner end describe "#create" do it "should work" do FtpClient.should_receive(:noop) post :create, :site ...
# frozen_string_literal: true RSpec.describe MondialRelay::Services::ParcelShopsService do it_behaves_like :service do let(:service) { build(:parcel_shops_service) } end end
class Purchaser < ActiveRecord::Base attr_accessible :name validates_uniqueness_of :name validates_presence_of :name has_many :purchases end
# == Schema Information # # Table name: tax_assignments # # account_category :integer # brand_id :integer # country_code :integer # state_code :integer # county_code :integer # city_code :integer # franchise_code :integer # charge_elt_type :integer # charge_elt_id :integer ...
# frozen_string_literal: true require './lib/board.rb' require './lib/pieces/pieces.rb' RSpec.describe Bishop do def all_board_pos (0..7).to_a.repeated_permutation(2).to_a end def moves(row, col) d = [[1, 1], [-1, 1], [-1, -1], [1, -1]] result = [] (1..7).each do |n| result += d.select { ...
require 'rails_helper' RSpec.describe SongsController, :type => :controller do describe 'new' do before { get :scraping } it '200' do expect(response).to have_http_status(200) expect(response).to render_template(:scraping) end end =begin describe 'confirm' do before do params ...
class AddRobotToInventors < ActiveRecord::Migration[5.2] def change add_reference :inventors, :inventor, foreign_key: true end end
## # Main mount points class Application < Sinatra::Base ## Register auth hook for authenticated pages. register do def auth( type ) condition do @user = BAP::User.find( session[:user_id] ) if( @user == nil ) puts "Redirecting to /login because @user is nil." redirect "/login" end end...
module CarthageCache class ArchiveBuilder attr_reader :terminal attr_reader :repository attr_reader :archiver attr_reader :project def initialize(terminal, repository, archiver, project) @terminal = terminal @repository = repository @archiver = archiver @project = projec...
#!/usr/bin/env ruby require './microtest' def solve(hexstr) version_sum(extract_packet(Bitstream::new(hexstr))) end def version_sum(packet) subversions = if packet.subpackets.nil? [] else packet.subpackets.map { |p| version_sum(p) } end packet.version + subversions.sum end class Bitstream # Invariants: ...
class PostLikesController < ApplicationController before_action :authenticate_user! def create post_id = params[:post_id] post = Post.find(post_id) if current_user.like?(post) raise 'already like' else current_user.like(post) end redirect_to '/posts' end def destroy pos...
class PathContainer def initialize(paths) @paths = paths.select { |path| path.nodes.count != 1 } end def number_of_nodes_equal_to(number_of_nodes) @paths.select { |path| path.nodes.count == number_of_nodes } end def number_of_nodes_less_than(number_of_nodes) @paths.select { |path| path.nodes.cou...
Rails.application.routes.draw do resource :messages get 'landing/index' root "landing#index" end
require 'combine_pdf' require_relative 'lib/visit-report' require_relative 'lib/visit-summary' require_relative 'lib/intervention-report' require_relative 'lib/offer-document' require_relative 'lib/order-document' require_relative 'lib/delivery-note' require_relative 'lib/production-ticket' require_relative 'lib/invoi...
#1 def repeat_2(string, int) int.times {puts string} end repeat_2('Hello', 3) def repeat(str, int) int.times {puts str} end repeat("hello", 3) #2 # absolute value def is_odd_2?(int) int % 2 != 0 end puts is_odd_2?(2) # => false puts is_odd_2?(5) # => true puts is_odd_2?(-17) # => true puts is_odd_2?...
# -*- encoding : utf-8 -*- require 'uri' class UserSessionsController < ApplicationController def new @redirect_to = params[:redirect_to] @active_admissions_exist = Admission.has_active_admissions? end def destroy session[:applicant_id] = nil session[:member_id] = nil flash[:success] = t...
# Implement and algorithm to determine if a string has all unique characters def is_unique?( string ) return false if string.length > 128 string_index = 0 string_array = [] while string_index < string.length current_letter_value = string[ string_index ].ord return false if string_array[ current_lett...
module IntegrationSpecHelper def setup_mock_auth(service_name=:cg, user=create(:user)) OmniAuth.config.mock_auth[service_name] = OmniAuth::AuthHash.new( provider: service_name.to_s, raw_info: { 'name' => "George Jetson" }, uid: '12345', nickname: 'georgejetsoncg', extra...
# encoding: utf-8 require File.expand_path("../spec_helper", __FILE__) describe "Pres" do before :each do browser.goto(WatirSpec.files + "/non_control_elements.html") end describe "#length" do it "returns the number of pres" do browser.pres.length.should == 7 end end describe "#[]" do ...
# frozen_string_literal: true require 'encase' require 'set' require 'jiji/configurations/mongoid_configuration' require 'jiji/model/settings/abstract_setting' module Jiji::Model::Settings class PairSetting < AbstractSetting include Encase include Mongoid::Document needs :pairs field :pair_names,...
module Antlr4::Runtime class ATNConfigSet attr_accessor :has_semantic_context attr_accessor :readonly attr_accessor :configs attr_accessor :unique_alt attr_accessor :dips_into_outer_context attr_accessor :full_ctx attr_accessor :conflictingAlts def initialize(full_ctx = true) @...
class Appointment =begin Variable date : String doctor : doctor_object patient : object =end attr_accessor :date, :doctor, :patient def initialize(date, doctor) @date = date @doctor = doctor @doctor.add_appointment(self) end end
namespace :balances do desc "Reset monthly category balances" task :monthly_reset => :environment do logger = Logger.new(STDOUT) Category.all.each do |category| category.update!(balance: category.monthly_amount) message = %Q(Your "#{category.name}" budget is now at #{category.balance.format}.) ...
module Bluesky # The application entry point class Application include DOMHelper include TryHelper # Top level ViewController attr_accessor :root_view_controller # Receives all notifications attr_accessor :delegate def initialize @dispatch_queue = [] @debug = false e...
# coding: utf-8 class ApplicationController < ActionController::Base protect_from_forgery helper_method :current_user, :only_admin_users before_filter :setup_subdomain def authenticate unless current_user reset_session redirect_to login_url return false end end def only_admin_u...
#!/usr/bin/env ruby # -*- mode: ruby -*- # Copyright (c) 2009-2011 VMware, Inc. ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", __FILE__) require 'bundler/setup' require 'vcap_services_base' $LOAD_PATH.unshift(File.expand_path("../../lib", __FILE__)) require "postgresql_service/node" class VCAP::Services:...
# frozen_string_literal: true require 'rails_helper' RSpec.describe Admin::CompanySearchForm, type: :model do describe 'attributes' do subject(:search_form) { described_class.new } describe '#name' do it '呼べること' do expect(search_form).to be_respond_to :name end end end describe...
module ApplicationHelper require 'exifr' def cover_image_dir AppConstants::COVER_IMAGE_DIR end def selectable_qualities AppConstants::SELECTABLE_QUALITIES end def image_filters AppConstants::IMAGE_FILTERS end def isbn_from_filename(filename) filename.gsub(/[\w_]+(\d{13,13})_.*/,...
class Game < ActiveRecord::Base def default_words "ав­то­мат, агент, ад­во­кат, акт, ак­тёр, ак­ция, аль­бом, Аме­ри­ка, ам­фи­бия, " \ "ан­гел, Ан­глия, ап­па­рат, аре­на, ат­лас, ат­лет, Аф­ри­ка, ба­боч­ка, ба­гет, ба­за, " \ "ба­ланс, банк, бан­ка, ба­ня, бар, ба­рак, ба­рьер, бас­сейн, ба­та­рея...
# message_dialog.rbの読み込み require './message_dialog' class GamesController # MessageDialogモジュールのinclude include MessageDialog EXP_CONSTANT = 2 GOLD_CONSTANT = 3 def battle(**params) build_characters(params) # 初期値を表示 initial_message(params) # 戦闘開始 loop do # コマンドメッセージ、コマンド追加 p...
class AddIsAmountColumnToRefundRule < ActiveRecord::Migration def self.up add_column :refund_rules, :is_amount, :boolean,:default=>false rename_column :refund_rules, :refund_percentage, :amount end def self.down remove_column :refund_rules, :is_amount end end
json.array!(@breweries) do |brewery| json.extract! brewery, :id, :name, :country, :region, :specialty, :category, :since json.url brewery_url(brewery, format: :json) end
require 'json' class Markov DELIMITER_REPLACE = %r{\s(\W)}.freeze CAPITALIZED_WORD = %r{\A[A-Z]+[a-zA-Z0-9\-\.,]*}.freeze TOKEN_SPLITTER = %r{\s+|(\,\s+)|(\.\s+|\.$)|(\?\s+|\?$)|(\!\s+|\!$)}.freeze SENTENCE_END = %r{\A[\.|\?|!]\z}.freeze attr_accessor :state def initialize @state = {} @starter_words = []...
# 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...
#!/usr/bin/env ruby # ----------------------------------------------------------------------------- # Intercepts DCE router events and pushes them on the queue # # Author: Fernand # ----------------------------------------------------------------------------- require 'rubygems' require 'main' $: << File.expand_path(F...
class Document < ActiveRecord::Base attr_accessor :entities, :persons def self.get(source_url) if document = Document.find_by(source_url: source_url) #Quick check to see if we've got this before document else #TODO: secure this content, metadata = Rika.parse_content_and_metadata(so...
class Mood < ActiveRecord::Base belongs_to :user validates :name, presence: true, length: { maximum: 10 } validates :value, presence: true, :inclusion => { :in => 0..10 } validates :color, format: {with: /#[a-f\d]{6}\z/i } @colors = Hash.new('#000000') def self.init(id) Mood.where("user_id = ?",id...
require File.dirname(__FILE__) + '/spec_helper' require "moneta/sdbm" describe "Moneta::SDBM" do before(:each) do @cache = Moneta::SDBM.new(:file => File.join(File.dirname(__FILE__), "sdbm_cache")) @cache.clear end after(:all) do FileUtils.rm_rf(Dir.glob(File.join(File.dirname(__FILE__), "sdbm_cac...
require 'erb' module Shomen # = ERB Template # # Template is used by the generator to build # template files. It has access to all the # the <i>data methods</i> in the generator. class Template include ERB::Util # New ERBTemplate instance. def initialize(generator, provisions) @gener...
# Sum Square - Square Sum # Write a method that computes the difference between the square of the sum of the first n positive integers and the sum of the squares of the first n positive integers. def sum_square_difference(num) # First half of the equation # Get a range between 1 and num and add to array arr = (...
# Connects a Document to a Meeting class MeetingDocument < ApplicationRecord belongs_to :document, optional: true, dependent: :destroy belongs_to :meeting attr_writer(:locale) mount_uploader(:file_sv, DocumentUploader) mount_uploader(:file_en, DocumentUploader) validates :kind, presence: true enum kind: {...
class Account::MembershipController < ApplicationController def show @user = current_user.decorate end end
class Pin < ApplicationRecord has_many :comment, through: :user belongs_to :user end
# -*- coding: utf-8 -*- require 'fileutils' class Photo < ActiveRecord::Base # TODO: audit_status, 设置 is admin 才能修改 acts_as_commentable acts_as_votable counts :comments_count => {:with => "Comment", :receiver => lambda {|comment| comment.commentable }, ...
class Movie < ActiveRecord::Base attr_accessible :title, :rating, :description, :release_date def self.ratings Movie.all.map(&:rating).uniq.sort end end
module RabbitJobs class Publisher # Abstract publisher. class Base class << self def cleanup fail NotImplementedError end def publish_to(_routing_key, _klass, *_params) fail NotImplementedError end def direct_publish_to(_routing_key, _payload...
class Pullrequest::CommentUpdated < Pullrequest::Base attr_accessor :comment validates :comment, presence: true, comment: true def payload payload = super payload[:text] = "#{verb} pull request <#{comment[:links][:html][:href]}|##{pullrequest[:id]}> (<#{repository[:links][:html][:href]}|#{repository[:ful...
require 'maws/trollop' class CommandOptionsParser def initialize(config) @config = config end def process_command_options(command) banner_text = usage(@config.profile.name, @config.command_name) banner_text << "\n#{command.description}\n\n" banner_text << "options:\n" command_opts = Trollop:...
class StarredJobsController < ApplicationController def create job = StarredJob.new(starred_job_params.merge({user_id: current_user.id})) job.save end def destroy StarredJob.find_by(uid: params[:id]).destroy end private def starred_job_params params.permit(:title, :decription, :poste...
module MassiveRecord module ORM module SingleTableInheritance extend ActiveSupport::Concern included do after_initialize :ensure_proper_type end def ensure_proper_type attr = self.class.inheritance_attribute if respond_to?(attr) && self[attr].blank? && ...