text stringlengths 10 2.61M |
|---|
class Client < ActiveRecord::Base
has_one :address
has_many :orders
has_and_belongs_to_many :roles
scope :week, where("created_at > ?", DateTime.now-7.days).limit(5)
scope :last_week, lambda { where("created_at < ?", Time.zone.now ) }
scope :one_week_before, lambda { |time| where("created_at < ?", ... |
require 'rbbt/rest/common/misc'
module RbbtRESTHelpers
def input_label(id, name, description = nil, default = nil, options = {})
options ||= {}
text = consume_parameter :label, options
if text.nil?
text = name.to_s
text += html_tag('span', " (default: " << default.to_s << ")", :class => 'in... |
class RemoveReportUrlFragmentFromProjects < ActiveRecord::Migration
def change
remove_column :projects, :ci_report_url_fragment
end
end
|
# ConcernedWithRailsDevBoost
module RailsDevBoostConcernedWithFix
def concerned_with_with_dependency_tracking(*args)
concerned_with_without_dependency_tracking(*args)
my_file_path_without_rb = ActiveSupport::Dependencies.search_for_file(name.underscore).sub(/\.rb\Z/, '')
args.each do |dependency|
... |
class Properties
def initialize(filename)
@filename = filename
end
def property(mailaddr)
File.open(@filename, 'r') do |f|
f.read.split("\n").each do |line|
break line.split('=')[1] if line.match(/#{mailaddr}/)
end
end
end
end
|
require 'json'
require 'bunny'
require 'pebblebed/river/subscription'
module Pebblebed
class River
class << self
attr_accessor :rabbitmq_options
def route(options)
raise ArgumentError.new(':event is required') unless options[:event]
raise ArgumentError.new(':uid is required') unless... |
class Review < ApplicationRecord
enum review_type: %i(training testing).freeze
end
|
class PiedPiper::Cli
attr_accessor :name
def initialize(name)
@name = name
end
def call
puts "loading..."
puts ""
puts "Welcome to Pied Piper!"
PiedPiper::Scraper.new("http://www.piedpiper.com/#team").scrape
puts "#{self.name}"
start
end
def start
puts ""
puts "Type ... |
# frozen_string_literal: true
class User < ActiveRecord::Base
# ===== Decription:
# Required for authentication user
devise :database_authenticatable, :registerable, :recoverable, :rememberable, :validatable
include DeviseTokenAuth::Concerns::User
# ===== Decription:
# Relations between models
has_many ... |
class SurfResortReviewsController < ApplicationController
before_action :logged_in_user, only: [:new, :create, :edit, :update, :destroy]
before_action :find_surf_resort, only: [:new, :create, :edit, :update, :destroy]
before_action :find_surf_resort_review, only: [:edit, :update, :destroy]
before_action :... |
###############################################################################
# Datatype to represent an item belonging to a season. A collection of
# EpisodeItems.
###############################################################################
class Episode < ActiveRecord::Base
include SoftDelete
belongs_to ... |
class UserModel
attr_accessor :id, :name, :email, :password
def to_hash
{
name: @name,
email: @email,
password: @password,
}
end
end
|
require 'test_helper'
class RecipesTest < ActionDispatch::IntegrationTest
def setup
@chef = Chef.create!(chefname: "mashrur", email: "vincent@example.com",
password: "password", password_confirmation: "password")
@recipe = Recipe.create(name: "Vegetable sauce", description: "grea... |
class Concert < ActiveRecord::Base
has_many :reviews
has_many :users, through: :reviews
validates :name, presence: true
validates :artist, presence: true
validates :venue, presence: true
# binding.pry
def self.venue_order
@concert = Concert.order('venue ASC')
end
end
|
module Actions
class ChangeApiTier
extend Extensions::Parameterizable
with :api, :tier
def call
ActiveRecord::Base.transaction do
api.tier_usage.deactivate!
Models::TierUsage.create! api: api, tier: tier
end
end
end
end
|
class LocalityError < StandardError; end
class Locality
include Geokit::Mappable
def self.resolve(s)
begin
geoloc = geocode(s)
case geoloc.provider
when 'google', 'yahoo'
case geoloc.precision
when 'country'
# find database object
object = Count... |
require 'test_helper'
class Admin::HomeControllerTest < ActionDispatch::IntegrationTest
fixtures :seasons, :heroes
test '404s for non-admin' do
user = create(:user)
account = create(:account, user: user)
sign_in_as(account)
get '/admin'
assert_response :not_found
end
test '404s for anon... |
class CreateEvents < ActiveRecord::Migration
def change
create_table :events do |t|
t.string 'app_sha', null: false
t.string 'ip', null: false
end
end
end
|
require "spec_helper"
RSpec.describe HerokuCLI::PG do
let(:subject) { HerokuCLI::PG.new('test') }
before do
allow(subject).to receive(:heroku) { nil }
end
context 'info' do
context 'only main' do
before do
allow(subject).to receive(:heroku) { file_fixture('pg_info') }
end
i... |
require 'helper'
require 'media/filter/graph'
module Media
class Filter
class TestGraph < MiniTest::Unit::TestCase
def test_to_s
assert_equal('a; b; c', Graph.new(chains: %w(a b c)).to_s)
end
end
end
end |
class RemoveSellerIdFromProfile < ActiveRecord::Migration[5.2]
def change
remove_column :profiles, :seller_id, :integer
end
end
|
class Rating < ApplicationRecord
belongs_to :user_selection
validates :note, presence: true
end
|
# frozen_string_literal: true
class RegistrationGroupsController < AuthenticatedController
before_action :assign_event
before_action :assign_group, except: %i[new create]
def new
@group = RegistrationGroup.new
end
def show
@attendance_list = @group.attendances.active.order(created_at: :desc)
@a... |
require 'bunny'
require 'json'
module Playlister
module MessageQueue
class Base
attr_reader :connection, :channel, :exchange
attr_accessor :name
def initialize(queue_name = nil)
@connection = Bunny.new
@connection.start
@channel = @connection.create_channel
... |
# == Schema Information
#
# Table name: attribution_portfolios
#
# id :integer not null, primary key
# name :string not null
# human_name :string
# account_number :string
# created_at :datetime not null
# updated_at :datetime not null
#
class A... |
class Dream < Sinatra::Base
enable :sessions # for use flash
register Sinatra::ConfigFile
helpers Sinatra::Cookies
register Sinatra::MultiRoute
register Sinatra::Flash
register Sinatra::ActiveRecordExtension
set :public_folder, File.dirname(__FILE__) + '/assets'
set :views, File.dirname(__FILE__) + '... |
class Pdnsd < Formula
homepage "http://members.home.nl/p.a.rombouts/pdnsd/"
url "http://members.home.nl/p.a.rombouts/pdnsd/releases/pdnsd-1.2.9a-par.tar.gz"
version "1.2.9a-par"
sha256 "bb5835d0caa8c4b31679d6fd6a1a090b71bdf70950db3b1d0cea9cf9cb7e2a7b"
bottle do
cellar :any
sha256 "a55b3ea9a71be9bee77... |
class HomeController < ApplicationController
before_action :authenticate_user!, only: [:management]
before_action :is_admin?, only: [:management]
def index
@article = Article.all.order('created_at DESC').limit(5)
set_page_title '首頁'
end
def aboutus
set_page_title '關於我們'
end... |
class TableAdmins < ActiveRecord::Migration
def change
create_table :admins
add_column :admins, :name, :string
add_column :admins, :password, :string
end
end
|
json.array!(@items) do |item|
json.product do
json.(item.product, :id, :name, :description, :price)
json.images item.product.images do |image|
json.(image, :thumbnail_url, :url)
end
end
json.quantity item.quantity
end
|
Rails.application.configure do
config.cache_classes = false
config.eager_load = false
config.consider_all_requests_local = true
config.action_controller.perform_caching = false
config.action_mailer.raise_delivery_errors = false
config.active_support.d... |
module Morpheus
module ActsAsRestful
extend ActiveSupport::Concern
module InstanceMethods
def id
return nil unless rest
url = rest["self"]
return nil if url.blank?
url.match(/(\d+)\/?$/)[1].to_i
end
def rest
@rest ||= {}
end
def update_... |
class Round
include ActiveModel::Model
ENUM_GROUP = { grupo_1: 1, grupo_2: 2, grupo_3: 3}
attr_accessor :index, :player, :group, :play, :name, :group, :step
def initialize(index, group, name)
self.index = index.present? ? index.to_i : 1
self.group = group
self.name = name
end
def n... |
# frozen_string_literal: true
class ProductRecipe < ApplicationRecord
belongs_to :product
has_many :ingredients, dependent: :destroy
accepts_nested_attributes_for :ingredients, allow_destroy: true
def credit_to_line(inventory_line, inv_map)
max_quantity = find_max_quantity(inv_map)
return unless max_... |
class CreateGoldenHorses < ActiveRecord::Migration[5.0]
def change
create_table :golden_horses do |t|
t.integer :year
t.integer :best_newcomer_id
t.integer :best_supporting_actor_id
t.integer :best_supporting_actress_id
t.integer :best_actor_id
t.integer :best_actress_id
... |
require 'spec_helper'
RSpec.describe Channel, type: :model do
it { should validate_presence_of(:name) }
it { should validate_uniqueness_of(:name) }
describe 'associations' do
it { should have_many(:messages) }
it { should have_many(:subscriptions) }
it { should have_many(:subscribers).through(:subs... |
require 'rails_helper'
describe Api do
describe 'GET /api/ping' do
it "should return pong" do
get '/api/ping'
valid_response = { :pong => "ok" }.to_json
expect(response.status).to eq 200
expect(response.body).to eq valid_response
end
end
end
|
require "fastlane_core/ui/ui"
module Fastlane
UI = FastlaneCore::UI unless Fastlane.const_defined?("UI")
module Helper
class LocalizeHelper
# class methods that you define here become available in your action
# as `Helper::LocalizeHelper.your_method`
#
def self.getProjectPath(options)... |
class AddCollectionIdIndexToFileGroups < ActiveRecord::Migration
def change
add_index :file_groups, :collection_id
end
end
|
class P0200c
attr_reader :options, :name, :field_type, :node
def initialize
@name = "Floor mat alarm (P0200c)"
@field_type = RADIO
@node = "P0200C"
@options = []
@options << FieldOption.new("^", "NA")
@options << FieldOption.new("0", "Not used")
@options << FieldOption.new("1", "U... |
require File.expand_path('../spec_helper', __FILE__)
Dir["./lib/*.rb"].each {|file| require File.expand_path('../../'+file, __FILE__)}
describe BankingCodeChallenge::Bank do
before :each do
@bank1 = BankingCodeChallenge::Bank.new( "Bank1" )
@account_1_1 = BankingCodeChallenge::Account.new(1111,@bank1,1000)
... |
# nginx
## dependencies
include_recipe "../epel/default.rb"
include_recipe "../ssl/default.rb"
## install
package 'nginx' do
action :install
end
## service stop
service 'nginx' do
action [:stop]
end
remote_file "/etc/nginx/nginx.conf" do
user "root"
source :auto
mode "644"
owner "root"
group "root"
en... |
# encoding: utf-8
module Faceter
module Functions
# Ungroups array values using provided root key and selector
#
# @example
# selector = Selector.new(only: :bar)
# function = Functions[:ungroup, :qux, selector]
#
# function[[{ foo: :FOO, qux: [{ bar: :BAR }, { bar: :BAZ }] }]]
... |
json.array!(@pages) do |page|
json.extract! page, :type_id, :title, :content, :status
json.url page_url(page, format: :json)
end
|
class Fregerepl < Formula
desc "Formula for installing the Frege REPL (not the compiler!!!)"
homepage "https://github.com/Frege/frege-repl"
url "https://github.com/Frege/frege-repl/releases/download/1.4-SNAPSHOT/frege-repl-1.4-SNAPSHOT.zip"
version "1.4-SNAPSHOT"
sha256 "2cf1c2a8f7b64c9d70b21fbfd25b2af3f5e3be... |
class AddDevteamFieldsToContact < ActiveRecord::Migration
def change
add_column :contact_requests, :test_suite, :boolean
add_column :contact_requests, :ci_server, :boolean
add_column :contact_requests, :deploy_master, :boolean
add_column :contact_requests, :onestep_deploy, :boolean
add_column :con... |
# frozen_string_literal: true
Sequel.migration do
change do
create_table :stripe_invoices do
primary_key :id
foreign_key :user_id, SC::Billing.user_model.table_name, null: false, index: true
foreign_key :subscription_id, :stripe_subscriptions, null: false, index: true
String :stripe_id,... |
class CreateMetafields < ActiveRecord::Migration[5.0]
def change
create_table :metafields, id: :uuid do |t|
t.string :description
t.string :key
t.string :namespace
t.integer :owner_id
t.integer :owner_type
t.string :owner_resource
t.string :value
t.string :val... |
module DiscourseSimpleCalendar
class CalendarDestroyer
def self.destroy(post)
fields = [
DiscourseSimpleCalendar::CALENDAR_CUSTOM_FIELD,
DiscourseSimpleCalendar::CALENDAR_DETAILS_CUSTOM_FIELD
]
PostCustomField.where(post_id: post.id, name: fields)
.delete_al... |
class UserInfo
def initialize(user)
@user = user
end
def created
"You created your account on #{@user.created_at.strftime("%A %B %d, %Y")}."
end
def sign_ins
"You have signed in #{@user.sign_in_count} times."
end
def simulations
"You have ran #{@user.simulations_ran} simulations."
en... |
class EntityActionController
attr_accessor :entity, :id
attr_accessor :actions
def initialize(entity, id = nil)
@entity, @id = entity, id
@actions = []
end
def add(action, text = nil, resource = nil, params = {})
text = action if text.nil?
resource = action.respond_to?(:resource) ? action.re... |
require_relative '../phase2/controller_base'
require 'active_support'
require 'active_support/core_ext'
require 'erb'
module Phase3
class ControllerBase < Phase2::ControllerBase
# use ERB and binding to evaluate templates
# pass the rendered html to render_content
def render(template_name)
raise St... |
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe LandlordsController, type: :controller do
let(:current_user) { create(:user) }
let(:session) { { user_id: current_user.id } }
let(:params) { {} }
describe 'POST #create' do
subject { post :create, params: params, session: session }
c... |
Metasploit::Model::Spec.shared_examples_for 'Module::Class' do
#
# Module::Ancestor factories
#
module_ancestor_factory = "#{factory_namespace}_module_ancestor"
payload_module_ancestor_factory = "payload_#{module_ancestor_factory}"
non_payload_module_ancestor_factory = "non_#{payload_module_ancestor_factor... |
require "slim"
require "colorize"
require "jazz/version"
require "jazz/parser"
require "jazz/slim"
require "jazz/uberlogger"
require "jazz/scope"
require "jazz/method"
require "parallel"
include Jazz::UberLogger
# Ruby really should abort on unhandled exceptions by default...
Thread.abort_on_exception = true
class O... |
require 'spec_helper'
require 'natives/catalog'
describe Natives::Catalog do
describe "#new" do
it "loads catalogs" do
Natives::Catalog.any_instance.should_receive(:reload)
Natives::Catalog.new('rubygems', 'mac_os_x', '10.7.5', 'homebrew')
end
it "requires caller to provide platform and pac... |
class MapsController < ApplicationController
def index
@user = current_user
end
def new
@map = Map.new()
@user = current_user
end
def create
@map = Map.new(map_params)
p @map
@map.user_id = current_user.id
respond_to do |format|
if @map.save
@event = Songkick::Cal... |
require 'sinatra/base'
require 'json'
require_relative './lib/data.rb'
class ThermoNuclearServer < Sinatra::Base
enable :sessions
set :session_secret, 'fsddsgjk22'
before do
@datastorage = NuclearData.instance
end
get '/' do
headers 'Access-Control-Allow-Origin' => '*'
{temp: @datastorage.temp... |
require "rom"
require "rom/memory"
describe "ROM integration" do
before do
class UserMapper < Faceter::Mapper
group :email, to: :emails
list do
field :emails do
list { unfold from: :email }
end
end
end
# Set ROM environment
ROM.use :auto_registration
... |
RSpec.describe MonstersController do
describe "GET index" do
it "blocks unauthenticated access" do
get :index, format: :json
expect(response.body).to eq({user: :invalid}.to_json)
end
context 'with login' do
before do
@user = create(:user)
@monster = create(:monster, user... |
#!/usr/bin/env ruby
# Given an alphabet (alph) returns number of permutations of n digits,
# organized by the order established in alph
# opens input.txt and formats input parameters
alph, num = File.open("rosalind_lexf.txt", "rb").readlines
alph.rstrip!
alph = alph.split(' ')
num = num.to_i
def generate_order(array... |
class UserMailer < ActionMailer::Base
helper :application
default from: "EnerSerial@eneraque.com"
def update_pm(user, job, current_user)
@user = user
@url = 'http://enerserial.eneraque.com/users/sign_in'
@job_url = "http://enerserial.eneraque.com/jobs/#{job.id}"
@job = job
@current_user = cu... |
class CreateExcludedAdHocOptionValues < ActiveRecord::Migration[4.2]
def self.up
create_table :excluded_ad_hoc_option_values do |t|
t.integer :ad_hoc_variant_exclusion_id
t.integer :ad_hoc_option_value_id
end
end
def self.down
drop_table :excluded_ad_hoc_option_values
end
end
|
require 'test_helper'
class Admin::Api::ServicesTest < ActionDispatch::IntegrationTest
def setup
@provider = FactoryBot.create :provider_account, :domain => 'provider.example.com'
@service = FactoryBot.create(:service, :account => @provider)
host! @provider.admin_domain
end
# Access token
test '... |
require 'rspec/core/shared_example_group'
# Helper methods for running specs for metasploit-model.
module Metasploit::Model::Spec
extend ActiveSupport::Autoload
autoload :Error
autoload :I18nExceptionHandler
autoload :PathnameCollision
autoload :Template
autoload :TemporaryPathname
extend Metasploit::M... |
# Definition for singly-linked list.
# class ListNode
# attr_accessor :val, :next
# def initialize(val)
# @val = val
# @next = nil
# end
# end
# @param {ListNode} headA
# @param {ListNode} headB
# @return {ListNode}
def getIntersectionNode(headA, headB)
return nil if headA == nil || headB... |
class IncidentsubcategoriesController < ApplicationController
before_action :set_incidentsubcategory, only: [:show, :edit, :update, :destroy]
# GET /incidentsubcategories
# GET /incidentsubcategories.json
def index
@incidentsubcategories = Incidentsubcategory.all
end
# GET /incidentsubcategories/1
#... |
# frozen_string_literal: true
if Settings.carrierwave.storage == "file"
CarrierWave.configure do |config|
config.storage = :file
end
elsif Settings.carrierwave.storage == "aws"
CarrierWave.configure do |config|
config.storage = :aws
config.aws_bucket = Settings.carrierwave.aws_bucket
config.aws_a... |
# frozen_string_literal: true
module SeedsHelper
# rubocop:disable Rails/Output
def self.count_records_for(model)
puts "Seeding #{model.table_name}"
starting_record_count = model.count
starting_time = Time.zone.now
yield
ending_count = model.count
puts " -> #{ending_count - starting_rec... |
require 'hand'
describe Hand do
subject(:hand) { Hand.new }
subject(:empty_hand) { Hand.new }
let(:card1) { double("card1") }
let(:card2) { double("card2") }
let(:card3) { double("card3") }
let(:jack_club) { double("jack_club", suit: :club, value: :jack) }
let(:ten_club) { double("ten_club", suit: :club... |
require "app_up/hooks/hook"
module AppUp
module Hooks
class Hook < Struct.new(:shell, :files, :options)
def self.run(shell, files, options)
new(shell, files, options).run
end
def run
raise "Must be implemented"
end
end
end
end
|
class PlacesController < ApplicationController
def index
@places = Place.order('name')
end
def map
end
def show
set_place
end
private
def set_place
@place = Place.find_by(url_name: params[:id])
end
end
|
require_relative 'buddycloud-build-notification'
class BuddycloudNotification < Jenkins::Tasks::Publisher
attr_reader :api_base_url, :username, :password, :channel,
:send_success_notifications, :success_message,
:send_unstable_notifications, :unstable_message,
:send_failure... |
class CategoriesIndicator < ActiveRecord::Base
belongs_to :indicator, touch: true
belongs_to :category
end
|
#!/usr/bin/env ruby
class Tmux
class Battery
SYMBOLS = {
:charging => ["21c8".hex].pack("U*"),
:discharging => ["21ca".hex].pack("U*"),
}
def initialize
@output = `pmset -g batt`.strip.split("\n")
parse!
end
def run
case @state
when :charging
puts ... |
class HomeController < ApplicationController
def home
mg_client = Mailgun::Client.new 'key-37da36884b26bd3e362eaafccf989eb8'
message_params = {from: 'Mailgun Sandbox <postmaster@sandboxd7bc03e1757d4439ab1805e09a6e8bf7.mailgun.org>',
to: 'Kelton Manzanares <kelton.manzanares@gmai... |
class InitialLayout < ActiveRecord::Migration
def self.up
create_table "addresses", :force => true do |t| #table used to be :users
t.integer "user_id", :null => false #used to be :maia_user_id
t.integer "policy_id", :default => 1, :null =>... |
module Jekyll
module IntersectArrays
def intersect(input, source)
return [] unless input and source
input & source
end
end
end
Liquid::Template.register_filter(Jekyll::IntersectArrays)
|
module ItemsHelper
def time_from_today(the_time)
seconds = (Time.now - the_time).to_i
minutes = seconds / 60
hours = minutes / 60
days = hours / 24
months = days / 30
years = months / 12
if seconds < 60
result = seconds.to_s + ' seconds ago'
elsif minutes < 60
result = minutes.to_s + ' min... |
if Rails.env.development? || Rails.env.test?
begin
require 'rubocop/rake_task'
RuboCop::RakeTask.new(:rubocop) do |task|
task.options = ['--display-cop-names']
end
rescue LoadError
warn 'rubocop is not available.'
end
begin
require 'cane/rake_task'
desc 'Run cane to check quality... |
class EndParticipantCallMutation < Types::BaseMutation
description "End the participant's call leg"
argument :participant_id, ID, required: true
field :participant, Outputs::ParticipantType, null: true
field :errors, resolver: Resolvers::Error
policy CallPolicy, :manage?
def resolve
participant = Pa... |
ActiveAdmin.register Oscar do
menu parent: "Pride",priority: 1
# See permitted parameters documentation:
# https://github.com/activeadmin/activeadmin/blob/master/docs/2-resource-customization.md#setting-up-strong-parameters
#
permit_params :year, :best_picture_id, :best_supporting_actor_id, :best_supporting_actress_id... |
require 'rails_helper'
feature 'Only author can delete the question', %q{
In order to cancel requests to community for help
As an author of the question
I'd like to be able to delete the question
} do
given(:question) { create(:question, title: 'test_delete_question', body: '12345') }
describe 'An authentic... |
# Object to save user password as session variable
class CreateAppPayload
include ModelHelper
def initialize(email, password, tsalt)
@email = email
@password = password
@tsalt = tsalt
end
def call
payload = base_64_encode(
Teacher.token_key(@password, base_64_decode(@tsalt))
)
To... |
require 'crossed_wires/wire'
require 'crossed_wires/point'
RSpec.describe CrossedWires::Wire do
subject(:wire) { described_class.new(points) }
let(:points_alfa) do
[
CrossedWires::Point.new(0, 0),
CrossedWires::Point.new(0, 5),
CrossedWires::Point.new(4, 5),
CrossedWires::Point.new(4, ... |
# -*- encoding : utf-8 -*-
module Retailigence #:nodoc:
# Representation of the distance from the <tt>userlocation</tt> and the
# respective Product or Location
#
# === Attributes
# * <tt>distance</tt> - A float value based on the distance <tt>units</tt>
# * <tt>units</tt> - String of distance measurement. ... |
# frozen_string_literal: true
Given("the Formicidae family exists") do
create :family, name_string: "Formicidae"
end
|
class Greeter
def initialize (name = "World")
@name = name
end
def say_hi
puts "Hello #{@name}"
end
def say_goodbye
puts "See ya later #{@name}!"
end
def quick
puts @name[0..2]
end
end |
module Admin
class ImageGalleryImagesController < ApplicationController
# GET /image_gallery_images
# GET /image_gallery_images.xml
before_filter :load_image_gallery_group
def load_image_gallery_group
@image_gallery_group = ImageGalleryGroup.find(params[:image_gallery_group_id])
end
... |
class PlayersController < ApplicationController
before_action :set_player, only: [:show, :edit, :update, :destroy]
before_action :rand_logic, only: :index
require 'Logica'
# GET /players
# GET /players.json
def index
@m = Logica.start_engine
@players = Player.all
if @players.count > 0
@pla... |
Spree::Api::BaseController.class_eval do
skip_before_filter :authenticate_user, if: :create_user_action?
def create_user_action?
req = request.path_parameters
req[:controller] === 'spree/api/users' && req[:action] == 'create'
end
end
|
class RMQViewStyler
attr_accessor :view
attr_accessor :context
attr_accessor :bg_color
attr_accessor :corner_radius
def initialize(view, context)
@needs_finalize = false
@view = view
@context = context
@bg_color = nil
@corner_radius = nil
end
def cleanup
@layout_params = nil
... |
module V1
class SessionAPI < Grape::API
resource :session do
post :login do
user = User.find_for_authentication(email: params[:email])
raise V1::Exceptions::Unauthorized unless user.valid_password?(params[:password])
{ token: user.generate_token, user: user }
end
end
end
... |
class WeWorkRemotely < CrawlBase
def self.config
{
url: "https://weworkremotely.com/jobs/search?term=rails",
base_url: "https://weworkremotely.com",
list_link_selector: "article li a",
}.freeze
end
def to_h
{
company_name: doc.css(".listing-header-container .company").first.tr... |
RSpec.describe Entry, type: :model do
let(:entry) { Entry.find('1') }
describe '#first_part' do
it { expect(entry.first_part).to eq('aaa') }
end
describe '#theme' do
it { expect(entry.theme).to eq('default_2008 article') }
end
describe '#og_description' do
context :entry_1 do
let(:entry... |
module Forums
class PostPresenter < BasePresenter
presents :post
def created_by
@created_by ||= present(post.created_by)
end
def thread
@thread ||= present(post.thread)
end
def created_at
post.created_at.strftime('%c')
end
def created_at_in_words
time_ago_in... |
class ClientsController < ApplicationController
def index
setup_session_defaults_for_controller(:client, :last_name)
@clients = build_query(Client, :client)
end
def new
unless company = Company.find_by_id(params[:company_id])
flash[:error] = 'You must supply a company to create a client for.'
... |
class CreateMeals < ActiveRecord::Migration[5.0]
def change
create_table :meals do |t|
t.string :main_title
t.string :sub_title
t.string :description
t.string :cook_time
t.integer :servings_count #rem... |
atom_feed :url => forum_topic_url(@forum, @topic) do |feed|
feed.title(@topic)
feed.updated(@posts.first ? @posts.first.created_at : Time.now.utc)
@posts.each do |post|
feed.entry post, :url => forum_topic_url(@forum, @topic, :page => post.page) do |entry|
entry.title(@topic)
entry.content(format... |
class AddInstagramPicToPosts < ActiveRecord::Migration
def change
add_column :posts, :instagram_pic, :string
end
end
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.