text stringlengths 10 2.61M |
|---|
module Api::V1
class DaysController < ApiController
before_action :set_user
# GET /days
def index
date_range = get_date_range
if date_range
render json: @user.days.where(date: date_range)
else
render json: @user.days
end
end
def show
render json: @us... |
require 'spec_helper'
describe "xml_file_downloads/index.html.erb" do
before(:each) do
Factory(:xml_file_download, :url => "http://url.sk")
end
it "renders a list of xml_file_downloads" do
visit '/xml_file_downloads'
page.should have_content "http://url.sk"
end
end
|
module Spree
module Api
module V2
module Storefront
module Account
class CreditCardsController < ::Spree::Api::V2::BaseController
before_action :require_spree_current_user
def index
render_serialized_payload { serialize_collection(resource) }
... |
fastlane_version "2.89.0"
default_platform :ios
file = File.read('../app.json')
appConfig = JSON.parse(file)
platform :ios do
desc "Submit a new Beta Build to Apple TestFlight"
lane :beta do
match(type: "appstore", readonly: false)
increment_build_number(
xcodeproj: "./ios/etorus.xcodeproj",
... |
class VoteMailer < ActionMailer::Base
default from: MAIL['user_name']
def confirmation(vote)
@vote = vote
mail(to: @vote.email, subject: 'Welcome to My Awesome Site')
end
end
|
# frozen_string_literal: true
# rubocop:todo all
require 'spec_helper'
describe Mongo::Grid::FSBucket::Stream::Read do
let(:support_fs) do
authorized_client.database.fs(fs_options)
end
before do
support_fs.files_collection.drop rescue nil
support_fs.chunks_collection.drop rescue nil
end
let(:... |
# == Schema Information
#
# Table name: provinces
#
# id :integer not null, primary key
# name :string(255)
# pro_remark :string(255)
# display_weight :integer
# created_at :datetime
# updated_at :datetime
#
class Province < ActiveRecord::Base
has_many :cities
accep... |
# Copyright (c) 2015 Vault12, Inc.
# MIT License https://opensource.org/licenses/MIT
ENV['RAILS_ENV'] ||= 'test'
require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help'
require 'response_helper'
require 'minitest/reporters'
Minitest::Reporters.use!
class ActiveSupport::TestCase
inc... |
class Product
attr_reader :id, :name, :price
@@count = 30
def initialize(product_params)
@id = @@count += 1
@name = product_params[:name]
@price = product_params[:price]
end
end
class Dietshop
attr_reader :products
#ใใคใจใใใทใงใใใฎ้ๅบใจๅๆใซๅๅใคใณในใฟใณในใ็ๆ
def initialize(product_params)
@products = []
... |
class MoviePerformer < ActiveRecord::Base
belongs_to :movie
belongs_to :performer
end
|
class Micropost < ActiveRecord::Base
attr_accessible :content
belongs_to :user
has_many :comments, dependent: :destroy
has_many :likes, foreign_key: "liked_micropost_id"
has_many :likers, through: :likes, source: :liker
validates :user_id, presence: true
validates :content, presence: true, length: {maxim... |
require 'rails_helper'
describe PushNotificationSubscription, :type => :model do
before :each do
mock_geocoding!
end
# Class methods
describe '.channel_name_for' do
it 'should return the correct channel name' do
item = create(:test_item)
expect( PushNotificationSubscription.channel_name_fo... |
require "rails_helper"
RSpec.describe ApplicationBundle, type: :model do
it "creates an application bundle" do
application = FactoryBot.create(:application)
bundle = FactoryBot.create(:bundle)
application_bundle = ApplicationBundle.create!(
application: application,
bundle: bundle,
)
... |
class TimetableCustomerService < ActiveRecord::Base
belongs_to :customer_service
has_many :day
attr_accessible :hour_final,
:hour_initial
validates :customer_service_id,
:uniqueness => true
attr_accessor :segunda, :terca, :quarta, :quinta, :sexta, :sabado, :domingo ... |
class Email < ActiveRecord::Base
belongs_to :contact, inverse_of: :emails, touch: true
attr_accessible :address, :contact_id, :has_bounced
validates_uniqueness_of :address
validates_presence_of :address
validates_presence_of :contact
before_validation :clean_up_address
private
def clean_up_address
... |
#!/usr/bin/ruby
require "nokogiri"
f_path = "lua_api_documentation.txt"
def write_arg(arg_hash, xml)
if arg_hash[:second_ident]
type = arg_hash[:first_ident]
name = arg_hash[:second_ident]
else
name = arg_hash[:first_ident]
type = name
end
optional = arg_hash[:optional]
default = arg_hash[:default]
xm... |
# frozen_string_literal: true
module KittyPolicy
class AccessDenied < StandardError
attr_reader :user, :action, :subject
def initialize(user = nil, action = nil, subject = nil)
@user = user
@action = action
@subject = subject
super 'Not authorized'
end
end
end
|
resource_group_name = attribute('resource_group_name', default: 'Belfast-Demo-VSTS', description: 'Name of the resource group to interogate')
title 'Check all resources are present'
control 'Belfast-Demo-Resources' do
impact 1.0
title 'Determine that all resources for the Managed Application have been created'
... |
# frozen-string-literal: true
module Sequel
module Plugins
# This plugin implements a simple database-independent locking mechanism
# to ensure that concurrent updates do not override changes. This is
# best implemented by a code example:
#
# class Person < Sequel::Model
# plugin :opti... |
class Opendata::Agents::Nodes::Mypage::Dataset::MyDataset::ResourcesController < ApplicationController
include Cms::NodeFilter::View
include Member::LoginFilter
include Opendata::MemberFilter
helper Opendata::FormHelper
helper Opendata::UrlHelper
before_action :accept_cors_request
before_action :set_data... |
shared_examples_for 'globus::install' do |facts|
it { is_expected.to contain_package('globus-connect-server-io').with_ensure('present') }
it { is_expected.to contain_package('globus-connect-server-id').with_ensure('present') }
it { is_expected.not_to contain_package('globus-connect-server-web') }
it { is_expect... |
class CreateProjects < ActiveRecord::Migration[6.0]
def change
create_table :projects do |t|
t.string :title
t.string :description
t.boolean :personal_completed
t.string :personal_github_repo_url
t.boolean :personal_sharable
t.string :type, null: false
t.references :templ... |
# 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 'test_helper'
require_relative '../../app/helpers/date_time_helper'
class DateTimeHelperTest < ActiveSupport::TestCase
test "should provide list of available times in half hour intervals" do
start_time = '12:00pm'
end_time = '2:00pm'
interval_in_minutes = 30
available_times = DateTi... |
class FollowsController < ApplicationController
before_action :authenticate_user!
def index
@follows = current_user.followedd
end
def follow
@follow_user = User.find(params[:id])
current_user.follow(@follow_user)
redirect_to home_path_url, :alert => "User followed!"
end
def unfollow
@... |
class ProjectsController < ApplicationController
before_action :set_project, only: [:show, :edit, :update, :destroy]
before_action :authenticate_user!, except: [:index]
def index
@projects = Project.all.order("created_at DESC")
if user_signed_in?
@projects = Project.where(:user_id => current_user.i... |
class ExercisePhoto < ActiveRecord::Base
mount_uploader :photo, ImageUploader
belongs_to :exercise
end
|
require 'socket'
require 'commandprocessor'
class TCPTimeServer
attr_reader :hostname
attr_reader :port_number
def initialize(hostname, port_number)
@hostname = hostname
@port_number = port_number
@server = TCPServer.new(self.hostname, self.port_number)
@timeout_seconds = 5
end
def run
... |
class Board
attr_reader :board_length,
:cells
def initialize(board_length)
@board_length = board_length
@cells = cell_generator
end
def letter_generator
potential_letters = ('A'..'Z').to_a
potential_letters[0..(@board_length - 1)]
end
def number_generator
letters = lette... |
class Status < ActiveRecord::Base
attr_accessible :description
has_many :paper_submissions
validates :description, :presence => true, :uniqueness => true
end
|
module PizzaOrder
class Pizza
attr_reader :name, :toppings
def initialize(name, *toppings)
@name, @toppings = name, toppings
end
def has_topping?(t)
toppings.include?(t)
end
end
end
|
require './src/services/importer_base.rb'
require './src/services/modules/by_date_to_csv.rb'
module Services
# *************************************************************************
# this Importer is used to pull and cache a copy of the drug counts by day
# **************************************************... |
# frozen_string_literal: true
require 'parsing_nesting/tree'
module BlacklightAdvancedSearch::ParsingNestingParser
def process_query(_params, config)
queries = keyword_queries.map do |field, query|
query = sanitize_quotes(query)
ParsingNesting::Tree.parse(query, config.advanced_search[:query_parser]).... |
# == Schema Information
#
# Table name: checkins
#
# id :integer not null, primary key
# checkin_date :date not null
# created_at :datetime not null
# updated_at :datetime not null
#
class Checkin < ApplicationRecord
paginates_per 10
CHECKIN_DAYS = [
'ye... |
require_relative "../record"
class Metacrunch::ULBD::Record::Element
SUBFIELDS = {
a: { "nicht spezifiziert" => :NW }
}
attr_accessor :properties
def initialize(datafield, options = {})
@tag = datafield.tag
@ind1 = datafield.ind1
@ind2 = datafield.ind2
@properties = {}
datafield.subf... |
# == Schema Information
#
# Table name: cars
#
# id :integer not null, primary key
# make :string not null
# model :string not null
# year :integer not null
# vin :string not null
# color :string default("black")
# cat... |
class CreatePageErrors < ActiveRecord::Migration
def change
create_table :page_errors do |t|
t.belongs_to :user
t.belongs_to :url
t.text :description
t.boolean :resolved?
t.timestamps
end
end
end
|
$LOAD_PATH << File.expand_path("../lib", __FILE__)
require 'memeasure'
Gem::Specification.new do |s|
s.name = 'memeasure'
s.version = MeMeasure::VERSION
s.date = '2015-12-30'
s.summary = "Basic ruby memory profiling tool"
s.description = "A bare bones memory measurement tool for ruby / ... |
class AlterFeedItemAddImage < ActiveRecord::Migration
def self.up
add_column :feed_items, :image_thumbnail, :string, :limit => 255
add_column :feed_items, :image_url, :string, :limit => 255
add_column :feed_items, :image_credits, :string, :limit => 255
end
def self.down
end
end
|
class AddClumnaNuevaToAcademico < ActiveRecord::Migration[5.1]
def change
add_column :academicos, :jornada, :string
add_column :academicos, :imagen, :string
end
end
|
class User < ApplicationRecord
enum role: [:user, :admin, :super_admin]
after_initialize :set_default_role, :if => :new_record?
def set_default_role
self.role ||= :user
end
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
end
|
require 'byebug'
class Employee
attr_reader :salary, :employees
def initialize(name, title, salary, boss)
@name = name
@title = title
@salary = salary
@boss = boss
end
def bonus(multiplier)
@salary * multiplier
end
end
class Manager < Employee
attr_accessor :employees
def initialize... |
# O(1) Constant
def func(values)
puts values[0]
end
# O(n) Linear
def func(list)
list.each do |element|
puts element
end
end
# O(n^2) Quadratic
def func(list)
list.each do |element_1|
list.each do |element_2|
puts element_1.to_s + ', ' + element_2.to_s
end
end
end
# O(n) Linear (expected ... |
class HistoryBuy
include ActiveModel::Model
attr_accessor :postal_code,:delivery_area_id,:municipality,:address,:building,:phone_number,:user_id,:item_id,:token
# ใใใซใใชใใผใทใงใณใฎๅฆ็ใๆธใ
with_options presence: true do
validates :postal_code, format: {with: /\A[0-9]{3}-[0-9]{4}\z/, message: "is invalid. Include hy... |
class EbookConverter
attr_accessor :input_file, :format, :switches
def initialize(input_file, format)
@input_file = input_file
@format = format
@switches = $settings.dup
@switches.delete("code_dir")
@file_stem = @switches["filename"]
end
def input_dir
input_file.split("/")[0 .. -2].jo... |
class SitemapElement
attr_accessor :url, :created_at
def initialize (url, created_at)
@created_at = created_at
@url = url
end
end |
class Order < ApplicationRecord
belongs_to :user
has_many :inventories, dependent: :nullify
has_many :desired_services, dependent: :destroy
has_many :order_items, dependent: :nullify
has_many :service_items, through: :order_items
has_many :services, through: :service_items
validates :deceased_first_name... |
require "nokogiri"
require "open-uri"
require_relative "util"
class Crawler
private
def get_page_source(url)
charset = nil
html = open(url) do |f|
charset = f.charset
f.read
end
[charset, html]
end
def parse_html(url)
charset, html = get_page_source(url)
Nokogiri::HTML.par... |
require 'json'
module JsonToBook
extend self
def transform(json)
JSON.parse(json)
end
end
require 'minitest/autorun'
describe JsonToBook do
subject { JsonToBook }
let(:json) {
<<EOS
[{
"id": "978-0641723445",
"cat": ["book","hardcover"],
"name": "The Lightning Thief",
"auth... |
module AdminArea
class CurrenciesController < AdminController
def index
currencies = Currency.all.order(:name)
render cell(Currencies::Cell::Index, currencies)
end
def new
run Currencies::New
render cell(Currencies::Cell::New, @model, form: @form)
end
def create
run... |
class CreatePeopleTable < ActiveRecord::Migration
def change
create_table :people do |t|
t.belongs_to :location
t.string :pfid
t.string :name
t.string :date_of_birth
t.string :place_of_birth
t.string :description
end
add_index :people, :pfid, unique: true
add_index ... |
require_relative 'player_hand'
class Player
attr_reader :name, :hand, :score
def initialize(name = 'Alfred', hand = PlayerHand.new([]), score = 0)
@name = name
@hand = hand
@score = 0
end
def take_card(card)
hand.add_card(card)
end
def give_cards_by_rank(rank)
hand.give_cards_by_rank... |
class PigLatinizer
attr_accessor :text, :word_array, :pig_latin_word, :pig_latin_array
def to_pig_latin(text)
@text = text
@pig_latin_array = []
@word_array = text.split(" ")
@word_array.each do |word|
@pig_latin_array << piglatinize(word)
end
pig_latin_text = @pig_latin_array.join(... |
class Links::Season::HrRosterStats < Links::Base
def site_name
"Hockey-Reference"
end
def description
"Roster and Statistics"
end
def url
"http://www.hockey-reference.com/teams/" \
"#{team.abbreviation}/#{season.year_end}.html"
end
def group
1
end
def position
0
end
end... |
Rails.application.routes.draw do
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
# Original code:
# get 'index', to: 'students#index'
# RailsGuides: 1.3 Configuring the Rails Router
# https://guides.rubyonrails.org/routing.html
# resources : stude... |
class EasyIssueQuery < EasyQuery
def self.entity_css_classes(issue, options={})
user = options[:user] || User.current
level = options[:level]
issue.css_classes(user, level)
end
def self.permission_view_entities
:view_issues
end
def query_after_initialize
super
self.export_formats[:a... |
class Garment < ActiveRecord::Base
include ActiveModel::Validations
include AttributeUpdater
include Monify
has_many :garment_categories
has_many :categories, through: :garment_categories, inverse_of: :garments
has_many :order_garments, inverse_of: :garment
has_many :orders, through: :order_garments, inve... |
class AddStatusToMessage < ActiveRecord::Migration
def self.up
remove_column :ideas, :last_comment_id
add_column :messages, :status, :string
add_index :messages, :status
end
def self.down
remove_index :messages, :status
remove_column :messages, :status
add_column :ideas, :last... |
require 'open-uri'
require 'rexml/document'
require_relative 'analyzer_view'
require_relative 'speech'
class Analyzer
attr_reader :url, :speech_path, :ignored
def initialize(args = {})
params = {
text: 'macbeth',
view: AnalyzerView.new,
ignored: ['ALL'],
speech_path: "PLAY/ACT/SCENE/SP... |
module IMP3::Commands::Genres
def genres_fetch_command (options)
if options.flush_cache
cache.artist_genres.clear
puts "Flushing artist genres cache."
end
tagged, requests, errors = 0, 0, 0
progress_bar tracks do |track, bar|
normalized_artist_name = track.artist.normalize
be... |
require 'test_helper'
require 'sucker_punch/testing/inline'
class TrainModelJobTest < ActiveJob::TestCase
PATH_TO_TRAINED_MODEL = "/training_data/svm_trained_model.csv"
test "should train model for the first time" do
TrainModelJob.perform_async(Prediction.last.id,74.2, 250, 1)
assert File.exist?(File.join... |
require "spec_helper"
module LabelGen
module Template
describe Ol875 do
context "as configured default" do
before :all do
LabelGen.configure do |conf|
conf.template_name = 'Ol875'
end
end
context "with template layout" do
let(:fname)... |
# Unorthodox/Impossible method creation (Advanced level)
# Create a method called ultimate.answer which takes no arguments.
# The method should simply return the number 42.
# Invoke your method and have it print the result to console.
ultimate = Object.new
def ultimate.answer
puts 42
return
end
ultimate.answer #=... |
module NestedViewHelper
def link_to_remove_fields(name, f)
html = []
html << f.hidden_field(:_destroy)
html << content_tag(:button, :type => :button, :class => ['btn', 'btn-danger', 'btn-mini'], :onclick => "remove_fields(this)") do
"Remove"
end.html_safe
html.join.html_safe
end
de... |
class AddFallbackSipAccountToPhone < ActiveRecord::Migration
def change
add_column :phones, :fallback_sip_account_id, :integer
end
end
|
class CategoryVendorSelectionsController < ApplicationController
def index
# Use's ActiveModel::Serializer to serialize records into JSON.
render json: ReduxDataQuery.call(CategoryVendorSelection.all, params[:query])
end
def create
categoryVendorSelection = CategoryVendorSelection.new(category_vendo... |
FactoryGirl.define do
factory :pledge do
dollar_amount 20
user
project
trait :pledge_2 do
dollar_amount 5
user
project
end
end
end
|
class ProjectsController < ActionController::Base
def new
if session[:auth_token]
@project = Project.new
@project.project_attachments.build
@project.tags.build
else
redirect_to root_url
end
end
def create
@project = Project.new(params[:project])
if @project.save
redirect_to project_path(@pr... |
class User < ActiveRecord::Base
has_many :hikes
end
|
# mi serve per cercare i libri in tutto il gioco
module GameFinder
# numero di mappe
MAP_NUMBER = 450
# mostra dove si trovano gli switch dei libri
# @return [String]
def self.find_books
result = ''
(462..494).each do |switch_id|
result += sprintf("#### Switch %d - %s ####\n", switch_id, $data_... |
class AddReviewFieldsToProjects < ActiveRecord::Migration
def change
add_column :projects, :comment_review_only, :boolean, default: false
add_column :projects, :custom_review_guidance, :text
end
end
|
require 'test_helper'
class UsersIndexTest < ActionDispatch::IntegrationTest
def setup
@admin = users(:bossman)
@non_admin = users(:jorge)
end
test "index as admin including pagination and delete links" do
sign_in_as(@admin)
get users_path
assert_select 'div.pagination'
first_page_of_users = User.w... |
require('rspec')
require('favorite_things_ruby')
require('pry')
describe("Item") do
before() do
Item.clear()
end
describe("attr_accessor") do
it("will change the name of an item using the name accesor")do
item = Item.new("tacos", 3)
item.name = "burrito"
expect(item.name).to(eq("burrit... |
Rails.application.routes.draw do
root 'pictures#index'
resources :pictures
end
# # Explaining it for myself.
#
# takes the 'pictures' instruction and directs the view to the pictures index in views/pictures/index
#
# takes the 'pictures/:id' instruction and implements the ruby code to display the appropriate pict... |
require 'rails_helper'
RSpec.describe User, type: :model do
def user_attributes(new_attr = {})
valid_attributes = {
email: "bob@gmail.com",
password: "12345678",
first_name: "Bob",
last_name: "Smith"
}
valid_attributes.merge new_attr
end
describe "Validations" do
it "req... |
class TransactionsController < ApplicationController
def index
@transaction_tokens = Transaction.all
@transactions = Array.new
@transaction_tokens.each do |transaction|
full_transaction = Transaction.fetch_by_token(transaction.token)
full_transaction[:id] = transaction[:id]
full_transact... |
require 'spec_helper'
describe DatePeriod::Month do
subject(:prev_month) { described_class.new(year: 1982, month: 1) }
subject(:month) { described_class.new(year: 1982, month: 2) }
subject(:next_month) { described_class.new(year: 1982, month: 3) }
describe '.including' do
it { expect(DatePeriod::Month.in... |
require 'test_helper'
class AccountTest < ActiveSupport::TestCase
def setup
@account_attributes = {email: 'dave@example.com'}
end
test "is valid proper attributes" do
account = Account.new(@account_attributes)
assert account.valid?
end
test "is not valid without email" do
account = Account.... |
class Station < ActiveRecord::Base
belongs_to :country
belongs_to :railway
end
|
class Api::TasksController < ApplicationController
before_action :set_list
before_action :set_task, except: [:create, :index]
def index
render json: @list.tasks
end
def create
@task = @list.tasks.create!(task_params)
render json: @task, status: :created
end
def destroy
@task.destroy
... |
class CreateCrmcomments < ActiveRecord::Migration
def change
create_table :crmcomments do |t|
t.references :user
t.datetime :dtime
t.text :comment
t.references :commentable, polymorphic: true
end
add_index :crmcomments, :user_id
end
end
|
require 'spec/expectations'
require 'watir'
# Commenting out the Safari pieces of this example, since my demo will be running on a Windows machine.
# require 'safariwatir'
# require 'rubygems'
Given /^I am on the weather\.com homepage$/ do
# @browser = Watir::Safari.new
@browser = Watir::Browser.new
@browser.go... |
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 => 'items#index'
resources :items do
resources :orders
end
end
#ใซใผใใฃใณใฐใฎใในใใใใ๏ผใฉใฎๅๅใซๅฏพใใ่ณผๅ
ฅใใผใธใชใฎใใๅคๅฅใใใใ๏ผ
#ใซใผใใฃใณใฐใ็ขบ่ชใใฆ่ฉณ็ดฐ็ป้ขใฎ่ณผๅ
ฅใใฟใณใฎใในใไฟฎๆญฃใใ
#Ordersใณใณใใญใผใฉใง๏ผ ite... |
class CreateArticleAudios < ActiveRecord::Migration
def self.up
create_table :article_audios do |t|
t.integer :audio_id, :article_id
end
add_index :article_audios, [:audio_id], :name => 'article_audios_audio_id_index'
add_index :article_audios, [:article_id], :name => 'article_audios_article_i... |
class CreateJobSphereships < ActiveRecord::Migration
def self.up
create_table :job_sphereships do |t|
t.integer :job_posting_id
t.integer :job_sphere_id
t.timestamps
end
end
def self.down
drop_table :job_sphereships
end
end
|
class Receptionist < ApplicationRecord
belongs_to :user
belongs_to :work_center
end
|
class Array
def my_each(&prc)
self.each do |ele|
prc.call(ele)
end
self
end
def my_select(&prc)
new_array = []
self.my_each do |ele|
new_array << ele if prc.call(ele)
end
new_array
end
def my_reject(&prc)
new_a... |
class EncountersCreateEncounters < ActiveRecord::Migration
def change
create_table :encounters do |t|
t.references :player
t.references :partner
t.references :position
t.text :state
t.text :descriptions
end
end
end
|
# frozen_string_literal: true
require_relative './post'
module ExamplePolicy
extend KittyPolicy::DSL
can :moderate do |user|
user == :admin
end
can :edit, Post do |user, post|
user == post.user
end
end
|
# 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... |
class GenerateStepDefinitionJob
include HaenawaConst
@queue = :normal
def self.perform(options = {})
ActiveRecord::Base.clear_active_connections! unless Rails.env.test?
options = HashWithIndifferentAccess.new(options)
@project = Project.find(options[:project_id])
@scenario = @project.scenarios.... |
module PitchHelper
def inject_extra_index_props(pitches)
JSON.parse(pitches.to_json).map do |pitch|
pitch["created_at"] = "#{time_ago_in_words(pitch["created_at"])} ago"
pitch["vote_count"] = Pitch.find(pitch["id"]).votes.count
pitch["comment_count"] = Pitch.find(pitch["id"]).comments.count
... |
Rails.application.routes.draw do
root to: 'api/v1/runnings#index'
namespace 'api' do
namespace 'v1' do
resources :runnings, only: :index
end
end
end
|
module ProcessMemory
# ProcessMemoryExใซๅนพใคใ่ฟฝๅ
class ProcessMemoryEx
# inspect modulesใๅ
ฅใใใจใใพใใซ้ทใใฎใง้ ใ
def inspect
# #<ProcessMemory::ProcessMemoryEx:0x000000029dc158 @pid=13508, @h_process=160, @target_is_x64=true>x
format("\#<#{self.class.name}:%0#{I_am_x64 ? 16 : 8}x @pid=#{@pid}, @h_process=#{@... |
require File.dirname(__FILE__) + '/../spec_helper'
###
# CONVIENENCE METHODS
###
def build_valid_landing_page(opts=nil, create=false)
opts ||= {}
opts[:status] ||= :active
lp = LandingPage.new opts
lp.should be_valid
lp.save.should be_true if create
lp
end
def mock_endeca_dimension_value... |
class RemoveUseIdFromPayments < ActiveRecord::Migration[6.0]
def change
remove_index :payments, :user_id
remove_column :payments, :user_id
end
end
|
Given(/^I'm using (\w+)$/) do |engine|
@engine = Engine.const_get(engine.capitalize).new
end
Given(/^I have movies$/) do |table|
movies = table.hashes
@engine.clear
@engine.import(movies)
end
When(/^I enter a search query "(.+)"$/) do |query|
@results = @engine.search(query)
end
When(/^I enter a search que... |
class Api::V1::ResourceSerializer < ActiveModel::Serializer
attributes :id,
:name,
:quantity,
:slug
end
|
class Category < ApplicationRecord
validates :name, presence: true
belongs_to :parent, class_name: :Category
belongs_to :grand_children, class_name: :Category
has_many :children,class_name: :Category, foreign_key: :pre_category_id
has_many :grand_children,class_name: :Category, foreign_key: :pre_precategory_... |
module PanicBoardData
class DataSequence
attr_accessor :data, :title, :refresh_every_n_seconds
def initialize(title)
@title = title
@data = {}
@refresh_every_n_seconds = 120
end
end
end
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.