text stringlengths 10 2.61M |
|---|
#
# Module Export
#
# @author [Sreeraj S]
#
# FileParsing module for excel exporting.
class FileParsing
EXPORT_LIMIT = 1_000
ROW_LIMIT = 64_000
NIL_CONTENT = nil
extend ActionView::Helpers::NumberHelper
def initialize(old_file_path, new_file_path)
@old_file_path = old_file_path
@new_file_path = new_... |
module Antlr4::Runtime
class ArrayPredictionContext < PredictionContext
attr_accessor :parents
attr_accessor :return_states
def initialize(parents, return_states = nil)
if parents.is_a? SingletonPredictionContext
return_states = [parents.return_state]
parents = [parents.parent]
... |
class Discussion < ActiveRecord::Base
has_many :comments, dependent: :destroy
has_many :votes, through: :comments
belongs_to :user
validates_presence_of :title, :content
validates :title, length: {minimum: 5}
validates :content, length: {minimum: 5}
end
|
# auto_spec.rb
require 'rubygems'
require 'spec'
require 'auto'
require 'auto_manager'
describe Auto do
it "should let create a new Auto object" do
Auto.new("034NNAS", "BMW", "335i", "Convertable", "silver").should be_instance_of(Auto)
end
it "should have auto_id, reg. number, brand, name, type, color" do
... |
=begin
Main class to interface with Yahoo
=end
require 'net/http'
require 'observer'
module YahooStock
# ==DESCRIPTION:
#
# Class to generate the right url and interface with yahoo
#
class Interface
include Observable
class InterfaceError < RuntimeError ; end
BASE_URLS = {
:quote ... |
module AriaApi
class Service
class << self
def actions
@actions ||= client.operations
end
private
def client
if AriaApi::Configuration.wsdl_path
local_client
else
remote_client
end
end
def local_client
Savon.client(... |
class TM::Project
attr_reader :name, :id
attr_accessor :tasks
@@counter = 0
@@tasks = []
@@projects = []
def self.projects
@@projects
end
def initialize name
@name = name
@id = @@counter
@@counter += 1
@@projects << self
end
# def
# end
def get_completed_tasks
list ... |
class NewEventController < Formotion::FormController
attr_accessor :parent
def init
super.initWithForm(form)
end
def form
@form ||= Formotion::Form.new({
sections: [{
rows: [{
title: "Name",
type: :string,
key: :name
}, {
title: "Start Tim... |
class Transaction < ActiveRecord::Base
has_many :debits
has_many :credits
belongs_to :group
validates :group, :presence => true
validates_numericality_of :amount, :greater_than => 0
def validate_and_activate!
ActiveRecord::Base.transaction do
return false if debits.sum(:amount_cents) != credits.s... |
class Project < ActiveRecord::Base
belongs_to :user
belongs_to :category
has_many :project_image
accepts_nested_attributes_for :project_image, reject_if: :all_blank, allow_destroy: true
before_save :modify_slug
validates :title, :description, presence: true
validates_presence_of :slug
def to_param
"#{se... |
class AddDefaultValueToSubscriptionConfirmed < ActiveRecord::Migration[6.1]
def change
change_column_default :subscriptions, :confirmed, false
change_column_default :courses, :status, 'Closed'
end
end
|
gem "minitest"
require './lib/rdomino/script_changer'
require 'minitest/autorun'
module Rdomino
describe ScriptChanger do
let(:script_changer){ ScriptChanger.new <<-HERE }
'++LotusScript Development Environment:2:5:(Options):0:74
Option Explicit
'++LotusScript Development Environment:2:5:(Forward):0:1
Declare... |
#!/usr/bin/env ruby
# encoding: utf-8
# File: watcher_table.rb
# Created: 24/09/13
#
# (c) Michel Demazure <michel@demazure.com>
# script methods for Jacinthe Management
module JacintheManagement
module GuiQt
# Table to show reports of cronman activities
class WatcherTable < Table
# Build the reporti... |
class MessageTransform
def initialize(pattern, formatter, name = nil)
@pattern = pattern
@formatter = formatter
@name = name
end
def process(message)
if message =~ @pattern
message = message.gsub(@pattern, @formatter)
end
message
end
def self.create_highlighter(string, target =... |
require 'rails_helper'
RSpec.describe UsersController, type: :controller do
let!(:user) {User.create!(name: 'VanVan',location: 'Cuba',username: 'aquinomas',password: 'aquinomas')}
let!(:question) {Question.create!(title: "Test title", body: "Test body", user: user)}
let!(:lionking) {User.create!(name: 'lionking'... |
# Add it up!
# Complete each step below according to the challenge directions and
# include it in this file. Also make sure everything that isn't code
# is commented in the file.
# I worked on this challenge [ with: Chris B].
# 0. total Pseudocode
# make sure all pseudocode is commented out!
# Input: Array of numbe... |
require 'rails_helper'
feature 'User can show badges', %q{
In order to view a list of your awards
I'd like to be able to view my badges
} do
given(:user) { create :user }
given(:question) { create :question, user: user }
given!(:badge) { create :badge, :has_image, title: "Badge", question: question, user: u... |
$:.push File.expand_path("../lib", __FILE__)
# Maintain your gem's version:
require "ajax_forms/version"
# Describe your gem and declare its dependencies:
Gem::Specification.new do |s|
s.name = "ajax_forms"
s.version = AjaxForms::VERSION
s.authors = ["Guillermo Bisheimer, Christian Pfarher"]
s.... |
require 'rails_helper'
feature 'as a visitor' do
context 'when visiting the /get_started' do
it 'sees info to get started' do
visit get_started_path
expect(page).to have_content('Browse tutorials from the homepage.')
expect(page)
.to have_content('Filter results by selecting' \
... |
# frozen_string_literal: true
class Event < ApplicationRecord
belongs_to :issue
validates_presence_of :action
validates_inclusion_of :action, in: %w[opened closed reopened]
scope :opened, -> { where(action: 'opened').and(action: 'open') }
scope :closed, -> { where(action: 'closed') }
scope :reopened, -> ... |
require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths"))
require File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "lib", "access_levels"))
Then /^reset code for "([^\"]*)" should exist$/ do |role|
case role
when "standard user"
@standard_user = User.find @standard_use... |
# frozen_string_literal: true
module BindingOfIsaacItemDatabase
VERSION = "0.1.0"
end
|
class CreateIngredients < ActiveRecord::Migration
def change
create_table :ingredients do |t|
t.string :name, null: false
t.string :description
t.float :amount
t.string :unit
t.timestamp null: false
end
add_reference :ingredients, :recipe, index: true
end
end
|
require "spec_helper"
shared_examples_for "vim" do
before(:each) {
# clear buffer
vim.normal 'gg"_dG'
# Insert two blank lines.
# The first line is a corner case in this plugin that would shadow the
# correct behaviour of other tests. Thus we explicitly jump to the first
# line when we requ... |
Leverans::App.controllers :schedule do
def self.protect(protected)
condition do
redirect '/' unless authorized?
end if protected
end
get :index, protect: true do
sheet = Leverans::Sheet.new(settings.google_sheet)
user = sheet.users.user_by_email(session[:current_user])
if user.nil?
... |
# encoding: UTF-8
# Copyright 2012 Twitter, Inc
# http://www.apache.org/licenses/LICENSE-2.0
module TwitterCldr
module Transforms
class VariableRule < Rule
class Parser < TwitterCldr::Parsers::Parser
private
def do_parse(options)
var_name = name
next_token(:equals)
... |
Rails.application.routes.draw do
get 'pages/new'
get 'pages/home'
root 'welcome#index'
resources :welcome
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
root "pages#home"
resources :pages
end
|
# Create a 8x8 playing grid(double array)
# Print out the playing board
# Print out the players menu to choose a token.
# Once the menu is printed user picks what column it goes into 1 - 8
# The token slides to the bottom of the playing grid.(row/column/cell)
# Once the user picks create a rando... |
Rails.application.routes.draw do
devise_for :users
# The priority is based upon order of creation: first created -> highest priority.
# See how all your routes lay out with "rake routes".
# You can have the root of your site routed with "root"
resources :restaurants do
resources :reviews, except: [:inde... |
class SrpmsController < ApplicationController
def show
@branch = Branch.find_by_name_and_vendor!(params[:branch], 'ALT Linux')
@srpm = @branch.srpms.where(name: params[:id]).includes(:packages, :branch).first
render status: 404, action: 'nosuchpackage' and return unless @srpm
@ftbfs = @branch.ftbfs.w... |
class AddDescriptionToRecipesteps < ActiveRecord::Migration
def change
add_column :recipesteps, :description, :text
end
end
|
# encoding: UTF-8
module FreeImage
##
# FreeImage supports the following dithering algorithms:
#
# :fs:: Floyd & Steinberg error diffusion algorithm
# :bayer4x4:: Bayer ordered dispersed dot dithering (order 2 – 4x4 -dithering matrix)
# :bayer8x8:: Bayer ordered dispersed dot dit... |
class CrimeThief < ApplicationRecord
belongs_to :crime
belongs_to :thief
end
|
ActiveAdmin.register Campaign do
index do
column(:preview) do |resource|
link_to(image_tag(resource.charity.picture_url(:small), :size => "50x50"), [:admin, resource])
end
column(:name) do |resource|
link_to(resource.name, [:admin, resource])
end
column :tagline
default_actions
... |
require "active_storage/blob"
# Image blobs can have variants that are the result of a set of transformations applied to the original.
class ActiveStorage::Variant
attr_reader :blob, :variation
delegate :service, to: :blob
def initialize(blob, variation)
@blob, @variation = blob, variation
end
def proc... |
class RubyRewriter < Parser::Rewriter
def on_begin(node)
eq_nodes = []
node.children.each do |child_node|
if assignment?(child_node)
eq_nodes << child_node
elsif eq_nodes.any?
align(eq_nodes)
eq_nodes = []
end
end
align(eq_nodes)
super
end
def alig... |
{{ruby_copyright}}
require 'hacer'
module {{ project_name | underscore | camelize }}
class ToDoItem
attr_reader :impl
def initialize(impl)
@impl = impl
end
def id
@impl.todo_id
end
def text
@impl.text
end
end
class ToDoList
def initialize(path)
@impl = ... |
# Convert a Hash-like object immediately by using `hash_obj.extend( Objectify )`!
module Objectify
# Test to ensure this only goes on a Hash.
def self.included( mod )
raise TypeError, "Cannot objectify #{mod}; expected Hash" unless mod == Hash
end
# Automation support for per-instance extensio... |
class CreateOligos < ActiveRecord::Migration
def self.up
create_table :oligos do |t|
t.integer :user_id
t.string :name
t.string :sequence
t.text :description
t.text :notes
t.integer :length
t.float :gcpercentage
t.float :tm
t.string :freezer
t.string :bo... |
require 'blueprint_ruby_client'
module Talis
module Hierarchy
# Represents hierarchy asset API operations provided by the Blueprint gem:
# {https://github.com/talis/blueprint_rb}
#
# In order to perform remote operations, the client must be configured
# with a valid OAuth client that is allowed t... |
class ReversePolishNotation
OPERANDS = %w(* / + -)
def rpn
user_input = ""
stack = []
if ARGV[0]
#we're reading from a file
end
until user_input == "="
user_input = gets.chomp
if user_input[-1] == "t"
puts "Inside txt file"
return rpn_f... |
=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 "uri"
module SwaggerClient
class TestrunApi
attr_accessor :api_client
def initialize(api_client... |
module Linguistics
module Latin
module Verb
class ParticipleBlock
attr_reader :participle_methods
def initialize(s)
raise "ParticipleBlock instantiation argument was nil!" if s.nil?
if s.is_a? Hash
@participle_methods = s.keys
end
@parti... |
class Pool < ApplicationRecord
belongs_to :bank
belongs_to :currency
has_many :income_by_custommers, dependent: :destroy
has_many :mining_histories, dependent: :destroy
end
|
# Given a nonnegative integer, return a hash whose keys are all the odd nonnegative integers up to it
# and each key's value is an array containing all the even non negative integers up to it.
#
# Examples:
# staircase 1 # => {1 => []}
# staircase 2 # => {1 => []}
# staircase 3 # => {1 => [], 3 => [2]}
# staircase 4... |
class Prayer < Request
before_validation :set_defaults
def set_defaults
self.first_name ||= "Anonymous"
end
end
|
class Runtime
include Itl::Bytecode
def initialize()
@globals = Env.new(self)
@compiler = Compiler.new
@parser = Parser.new
load_default_functions
end
def load(file, env=@globals)
parseAndRun(File.open(file, 'r').read, env)
end
def par... |
require File.join(File.dirname(__FILE__), 'test_helper')
# initialize
# ----------
class IQ::Crud::BaseHandler::InitializeTest < Test::Unit::TestCase
def test_should_set_responses_instance_variable_to_empty_hash
instance = Factory.base_handler_instance
assert_equal({}, instance.instance_variable_get('@respon... |
require "time"
require "date"
class BusinessHours
def initialize(open,close)
open,close=parse(open,close)
@open = open
@close = close
@specific_date = {}
@week = {}
@week_days = Time::RFC2822_DAY_NAME.map { |e| e.downcase.to_sym }
@week_days.each do |day|
@week[day] = [ open, close]
... |
require 'active_support'
require 'active_support/core_ext'
require 'simple_jsonapi/helpers/exceptions'
require 'simple_jsonapi/helpers/serializer_inferrer'
require 'simple_jsonapi/helpers/serializer_methods'
require 'simple_jsonapi/parameters/fields_spec'
require 'simple_jsonapi/parameters/include_spec'
require 'simp... |
module GoogleApps
# Mock backend.
class Mock
# Mock response.
class Response < Struct.new(:code, :body)
end
attr_reader :domain
def initialize(params)
@domain = params[:domain]
@mocks = {}
@changes = []
end
# Mock a raw XML response.
# First a... |
FactoryBot.define do
factory :user, class: User do
first_name { Faker::Name.first_name }
last_name { Faker::Name.last_name }
email { Faker::Internet.safe_email }
password {Faker::Internet.password}
password_confirmation {password}
end
end
def user_with_arguments(arg_count: 1)
FactoryBot.cr... |
# frozen_string_literal: true
module Vedeu
module Logging
# If the system supports Process::CLOCK_MONOTONIC use that for
# timestamps.
#
# @api public
#
module ClockTime
# {include:file:docs/dsl/by_method/clock_time.md}
# @return [Float|Time]
def self.clock_time
i... |
class Schedule < ApplicationRecord
belongs_to :user
belongs_to :thing
belongs_to :staff
# validations
validates_presence_of :user_id, :thing_id, :staff_id, :from, :to
end
|
class UserStory
include Mongoid::Document
field :code, :type => String
field :summary, :type => String
field :details, :type => String
field :order, :type => Integer
field :points, :type => Integer
field :status, :type => Integer
has_many :scenarios
has_many :technical_stories
has_many :pr... |
class AddIndexToTaskAttributeRevisions < ActiveRecord::Migration
def change
add_index :task_attribute_revisions, :task_id
end
end
|
# -*- encoding: utf-8 -*-
require File.expand_path('../lib/requirejs_optimizer/version', __FILE__)
Gem::Specification.new do |gem|
gem.authors = ["Jesse Trimble"]
gem.email = ["jesseltrimble@gmail.com"]
gem.description = %q{A tool for optimizing Require.js modules using r.js under the asset pipel... |
class AddColumnPositionToInterpretations < ActiveRecord::Migration[5.1]
def change
add_column :interpretations, :position, :integer, default: 0
end
end
|
module RequirejsOptimizer
module Step
class Base
def perform(*)
raise NotImplementedError
end
def to_proc
self.method(:perform).to_proc
end
end
end
end
|
class FoodReport
def initialize(food_report)
@food_report = food_report["report"]
end
def report_type
@food_report["type"]
end
def ndbno_number
@food_report["food"]["ndbno"]
end
def food_name
@food_report["food"]["name"]
end
def food_group
@food_report["food"]["fg"]
end
def nutrients
... |
class CashRegister
attr_accessor :total, :discount, :items, :price
def initialize(discount = 0)
@total = 0
@discount = discount
@items = []
end
def add_item(item, price, quantity = 1)
@price = price
@total += @price * quantity
counter = 0
while counter < quantity
@items << item
counter += 1
end
@items
end
... |
json.array!(@diagnostic_amiantes) do |diagnostic_amiante|
json.extract! diagnostic_amiante, :id, :docs, :accompagnateur, :commentaires, :conclusions
json.url diagnostic_amiante_url(diagnostic_amiante, format: :json)
end
|
module Concerns::Board::Association
extend ActiveSupport::Concern
included do
belongs_to(:section)
has_many(:comments, class_name: "BoardComment", dependent: :destroy)
end
end
|
shared_context 'authenticated user' do |user|
let(:auth_context) do
user = create(:user)
{
user: user,
headers: {
Controllers::Application::TOKEN_HEADER => Session::Cache.tokenize(user)
}
}
end
let(:user) { auth_context[:user] }
let(:auth_header) { auth_context[... |
class AddVmTypeAndEstimatedTimeToApplication < ActiveRecord::Migration
def change
add_column :applications, :vm_type, :string
add_column :applications, :estimated_time, :integer
Application.all.each do |app|
app.update_attribute(:vm_type, 'c1.medium')
app.update_attribute(:estimated_time , 20)... |
# frozen_string_literal: true
require 'rvg/rvg'
require 'uncryptid/board'
require 'uncryptid/clue'
require 'uncryptid/renderer'
module Uncryptid
TERRAINS = [
:desert,
:forest,
:mountain,
:swamp,
:water,
]
ANIMALS = [:bears, :cougars]
BLUE_STRUCTURES = [:blue_shack, :blue_stone]
GREEN_... |
class ChangeDatatypeValveOfRoadbikes < ActiveRecord::Migration[5.0]
def change
change_column :roadbikes, :valve, :integer
end
end
|
require 'spec_helper'
describe "moderation" do
context" of topics" do
let!(:moderator) { FactoryGirl.create(:user, :login => "moderator") }
let!(:group) do
group = FactoryGirl.create(:group)
group.members << moderator
group.save!
group
end
let!(:forum) { FactoryGirl.create(:f... |
# frozen_string_literal: true
# desc "Explaining what the task does"
# task :easy_monitor do
# # Task goes here
# end
# Create an influxdb db
namespace :easy_monitor do
desc 'Create a influx db called easy_monitor default to localhost port 8086'\
'you can pass tour host and port to the task <host> <port>'
t... |
# Monkey patching RestClient::Request.process_url_params
# To support array in URL params
# RestClient.get('http://www.example.com', params: {weekday: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri']})
# => GET http://www.example.com?weekday[]=Mon&weekday[]=Tue&weekday[]=Wed&weekday[]=Thu&weekday[]=Fri
module RestClient
class Re... |
class FellowsController < Hemp::BaseController
def index
@fellows = Fellow.all
end
def new
end
def create
Fellow.create(fellow_params)
redirect_to "/"
end
def update
fellow.first_name = params[:first_name]
fellow.last_name = params[:last_name]
fellow.email = params[:email]
f... |
class CreateSkirts < ActiveRecord::Migration[5.1]
def change
create_table :skirts do |t|
t.integer :length, null: false
t.integer :waist, null: false
t.integer :pleat_width
t.integer :waistband_width
t.timestamps
end
end
end
|
require 'delegate'
module Diffa
class DateAggregation
def initialize(user, attr_name, query_params, view_map)
@user = user
@granularity = determine_granularity(attr_name, query_params)
@constraints = {text: 'user = ?', vars: [@user]}
@constraints = add_constraints(attr_name, query_params, ... |
class AddGeoColumnsToSapApplications < ActiveRecord::Migration
def change
add_column :sap_applications, :lat, :float
add_column :sap_applications, :lng, :float
add_index :sap_applications, [:lat, :lng]
end
end
|
module IQ::ViewPathExtensions::ActionView::Base
def self.included(base) # :nodoc:
base.send :alias_method_chain, :find_full_template_path, :exclude_controller_path
base.send :alias_method_chain, :find_base_path_for, :exclude_controller_path
end
private
def find_full_template_path_with_e... |
require 'sidekiq/api'
class SidekiqQueuesController < ApplicationController
skip_before_action :require_authentication
def index
base_stats = Sidekiq::Stats.new
stats = {
enqueued: base_stats.enqueued,
queues: base_stats.queues,
busy: Sidekiq::Workers.new.size,
retries: base_st... |
# frozen_string_literal: true
require 'feedjira'
class FeedFetcher
include Sidekiq::Worker
sidekiq_options retry: false
def perform(feed_url)
begin
feed = Feedjira::Feed.fetch_and_parse(feed_url)
feed_status = 'success'
rescue => err
feed_status = err.message
end
EntryArticl... |
require 'rails_helper'
describe GoalsController, type: :controller do
let(:current_user) { FactoryGirl.build(:user, id: 123) }
before do
allow(request.env['warden']).to receive(:authenticate!).and_return(current_user)
allow(controller).to receive(:current_user).and_return(current_user)
end
describe '... |
FactoryBot.define do
factory :genre do
end
factory :anime do
rating {rand(1..10)}
end
end
|
require 'rspotify/oauth'
class PopulateArtistSongTableJob < ApplicationJob
queue_as :default
def perform(*args)
# fetch all song uris from db
song_uris = Song.all.pluck(:song_uri)
# strip spotify:track:
song_uri_ids = song_uris.map { |song_uri| song_uri.gsub('spotify:track:', '') }
song_uris_f... |
Rails.application.routes.draw do
root 'static_pages#root'
namespace :api, :defaults => { :format => 'json' } do
resources :todos
end
end
|
FactoryBot.define do
factory :user do
name { Faker::Name.name }
username { Faker::Internet.username(specifier: 4..20, separators: %w[- _]) }
email { Faker::Internet.email }
password { 'password' }
trait :with_avatar do
avatar { FilesTestHelper.avatar_png }
end
end
end
|
require 'cloudformation_mapper/resource'
class CloudformationMapper::Resource::AwsPropertiesEc2Elb < CloudformationMapper::Resource
register_type 'AWS::ElasticLoadBalancing::LoadBalancer'
type 'Template'
parameter do
type 'Template'
name :Properties
parameter do
type 'Elastic Load Balancin... |
# frozen_string_literal: true
FactoryBot.define do
factory :avatar do
association :user
trait :today do
created_at { 1.hour.ago }
end
trait :yesterday do
created_at { 1.day.ago }
end
end
end
|
class Admin::StripeItemsController < ApplicationController
before_filter :authenticate_user!
def index
@stripe_items = StripeItem.all
respond_to do |format|
format.html
format.json { render json: @stripe_items }
end
end
def show
@stripe_item = StripeItem.new
respond_to do |fo... |
Rails.application.routes.draw do
devise_for :users
# For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html
root to: 'pages#home'
namespace :admin do
root to: "application#index"
resources :projects
end
resources :projects
get "contact", to: "pag... |
Pod::Spec.new do |s|
s.name = 'Dekoter'
s.version = '0.3.1'
s.summary = "NSCoding's counterpart for Swift structs."
s.description = <<-DESC
Fills a gap left by the missing NSCoding's support for Swift structs. If you've ever implemented NSCoding, Koting will be familiar to ... |
class Post < ApplicationRecord
max_paginates_per 10
has_many :comments, dependent: :destroy
validates :title, presence: true, uniqueness: true
validates :body, presence: true
end
|
class AddSenderIDtoMessages < ActiveRecord::Migration
def change
add_column :messages, :sender_facebook_id, :string
end
end
|
module ContextIO
# Methods for sending HTTP requests
#
# @api private
module Request
# Perform an HTTP DELETE request
#
# @param [String] path The path to request.
# @param [Hash] params Parameters to put in the query part of the URL
#
# @return [Hash, Array, Object] The parsed JSON resp... |
require "rake/testtask"
require "bundler/gem_tasks"
# -- Testing stuff --
desc "Test everything"
task "test:all" => "test:adapters"
# Ruby versions we're testing with.
RUBIES = %w{1.9.3 2.0.0 jruby-1.7.13}
# Use rake test:rubies to run all combination of tests (see test:adapters) using
# all the versions of Ruby sp... |
class Game < ActiveRecord::Base
attr_accessible :outcome
has_and_belongs_to_many :players
end
|
module MDS
module Services
module ShippingStatus
class Tracking
include Base
set_xml_root 'MDSShippingTracking'
set_url_package 'mds.shipping.Tracking'
def initialize(config)
super
@number_of_days = config[:number_of_days] || 2
end
d... |
# ================= PREDICATE ENUMERABLE METHODS ========================
# include? method ==============================
numbers = [5, 6, 7, 8]
numbers.include?(6)
#=> true
numbers.include?(3)
#=> false
friends = ['Sharon', 'Leo', 'Leila', 'Brian', 'Arun']
# Novo array onde friends são diferentes de Brian
inv... |
FactoryGirl.define do
factory :article do
title "What to Wear to an Interview: 9 Looks to Score Your Dream Job"
url "http://www.whowhatwear.co.uk/what-to-wear-to-an-interview"
description "MyText"
image_url "MyString"
publisher "MyString"
user nil
gender nil
end
end
|
class OrdersController < ApplicationController
before_action :load_order, only: :show
before_action :load_cart, only: %i(new create)
def index; end
def show; end
def new
@order = Order.new
end
def create
@order = Order.new order_params
ActiveRecord::Base.transaction do
@order.save
... |
class Page < ActiveRecord::Base
include Sluggable
before_save :generate_slug, :rank_self, :rank_siblings
belongs_to :category
has_attached_file :image, :styles => { :medium => "350x350>", :thumb => "100x100>" }, :default_url => "/images/:style/missing.png"
validates_attachment_content_type :image, content_... |
module AchievementConcerns
module LikeAchievementable
extend ActiveSupport::Concern
include AchievementConcerns::SimpleAchievementable
private
def like_post
grant_on_create self.resource.publisher_type == "EducationalInstitution" ?
:like_institution_post : :like_post
grant_on_rece... |
class Concept < ActiveRecord::Base
#running into problems with new columns not being added even after a server reboot
# needed to manually add new columns to Versions table
acts_as_versioned
# associations
belongs_to :owner, :class_name => "User", :foreign_key => "user_id"
has_many :comments
has_at... |
class Model::Section::EventPartner < SitePrism::Section
element :header, "#edit-field-event-partners-heading-und-0-value"
elements :label, "label.option"
end |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.