text stringlengths 10 2.61M |
|---|
class ReviewsController < ApplicationController
skip_before_action :require_login
def create
@review = Review.new(review_params)
if @review.save
flash[:status] = :success
flash[:result_text] = "Successfully created your review!"
redirect_to product_path(@review.product_id)
else
... |
class CreateElectronicPortals < ActiveRecord::Migration
def change
create_table :electronic_portals do |t|
t.references :organ, index: true, foreign_key: true
t.string :value
t.timestamps null: false
end
end
end
|
#
# Cookbook Name:: nullmailer
# Recipe:: default
#
# Copyright 2010, Estately, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# U... |
# frozen-string_literal: true
module Decidim
module Opinions
class CollaborativeDraftWithdrawnEvent < Decidim::Events::SimpleEvent
i18n_attributes :author_nickname, :author_name, :author_path
delegate :nickname, :name, to: :author, prefix: true
def nickname
author_nickname
end
... |
load File.expand_path("../tasks/svn.rake", __FILE__)
require 'capistrano/scm'
class Capistrano::Svn < Capistrano::SCM
# execute svn in context with arguments
def svn(*args)
args.unshift(:svn)
context.execute *args
end
module DefaultStrategy
def test
test! " [ -d #{repo_path}/.svn ] "
e... |
# A temporary content format used as a splash page for scheduled documents.
#
# When a new document is scheduled for publication, a "coming_soon" content item
# is pushed to the Publishing API, along with a `PublishIntent` for the
# scheduled publication time. This is to get around the fact that the current
# caching i... |
class MuseumFinder::Scraper
def self.get_page
Nokogiri::HTML(open("https://www.si.edu/museums"))
end
def self.scrape_landing_page
museums_array = []
landing_page = self.get_page.css("div.content")
landing_page.css("div.b-text-wrapper").each do |museum|
name = museum.css("h3.title").t... |
Pod::Spec.new do |s|
version = "0.1.1"
s.name = "HXSlider"
s.version = version
s.summary = "HXSlider is a slider of special tailor-made."
s.homepage = "https://github.com/CapriHuang/HXSpec"
s.author = { "CapriHuang" => "1187395293@qq.com" }
s.source = { :git => "https://g... |
# == Schema Information
#
# Table name: series
#
# id :integer not null, primary key
# title :string not null
# year :integer not null
# description :text not null
# avg_rating :integer default(0)
# created_... |
# frozen_string_literal: true
module Docx #:nodoc:
VERSION = '0.6.2'
end
|
class AddRowsToProcessToImport < ActiveRecord::Migration
def change
add_column :imports, :rows_to_process, :integer
end
end
|
require 'byebug'
class Sudoku
def initialize(board_string)
@backtrack_array = board_string.to_s.split("").map { |digit| digit.to_i }
@backtrack_board = @backtrack_array.each_slice(9).to_a
@board_horizontal = Marshal.load(Marshal.dump(@backtrack_board))
@horizontal_arr = Marshal.load... |
class Contract < ActiveRecord::Base
extend BaseModel
has_many :agreements
has_many :nations, :through => :agreements
has_many :aids
validates_presence_of :buyer_id, :seller_id
after_initialize :set_defaults
after_create :add_to_agreements, :find_aid
after_save :update_money_paid, :update_tech_paid
af... |
module Rspec
class StrategyGenerator < ::Rails::Generators::NamedBase
source_root File.expand_path('../templates', __FILE__)
def create_spec_file
template(
'strategy_rspec.rb',
File.join('spec/strategies', "#{singular_name}_strategy_spec.rb")
)
end
end
end
|
require 'rails_helper'
RSpec.feature "User views all artists" do
scenario "they visit artists index" do
artist1_name = "Bob Marley"
artist1_image_path = "http://cps-static.rovicorp.com/3/JPG_400/MI0003/146/MI0003146038.jpg"
Artist.create(name: artist1_name, image_path: artist1_image_path)
arti... |
class GenerateDetailedTermReport
attr_accessor :over_marks, :fetch_report_headers
attr_accessor :exam_max_marks
def initialize(param)
@term = AssessmentTerm.find param[:exam].split('_').last
@param = param
@batch = Batch.find @param[:batch]
load_header_data
end
def fetch_report_data
... |
class PropertiesController < ApplicationController
def index
@properties = Property.all
end
def new
@property = Property.new
end
def create
@property = Property.new(property_params)
if @property.save
redirect_to root_path
else
render 'new'
end
end
def edit
@pro... |
class Symbol
# From https://api.rubyonrails.org/classes/ActiveSupport/Inflector.html#method-i-camelize
def camelize
self.to_s.sub(/^[a-z\d]*/) { |m| m.capitalize }
.gsub(/(?:_|(\/))([a-z\d]*)/i) { "#{$1}#{$2.capitalize}" }
.gsub('/', '::')
end
def constantize
self.camelize.constantize
end
end
|
require 'test_helper'
module JackCompiler
module Transformer
class TestParserProcessor < Minitest::Test
def test_analyze_symbols
parse_node = VisitorTestHelper.prepare_tree(<<~SOURCE, root_node: :class)
class Bill {
static integer tax_rate;
field integer total;
... |
class Comment < ActiveRecord::Base
belongs_to :article
validates :name, :email, :body, presence: true
validate :article_should_be_published
after_create :send_comment_email
private
def article_should_be_published
if article && !article.published?
errors.add(:article_id, "is not published yet")... |
class ApiEmployee
include HTTParty
base_uri CONFIG['url_api']
headers "Content-Type" => "application/json"
def self.create(employee, authorization)
post("/empregado/cadastrar", headers: { "Authorization" => authorization }, body: employee.to_json)
end
def self.list_all(authorization)... |
# == Schema Information
#
# Table name: awards
#
# id :integer not null, primary key
# year :integer
# body :text
# paper_id :integer
# created_at :datetime not null
# updated_at :datetime not null
# pinned :boolean
#
class Award < ActiveRecord::Base
belongs_... |
class UsersController < ApplicationController
def edit
@user = User.find(params[:id])
@page = params[:page]
end
def update
@user = User.find(params[:id])
@user.update(user_param)
redirect_to params[:user][:page].to_sym
end
private
def user_param
params.require(:user).permit(:na... |
class Api::CurrentSeason::PicksController < Api::CurrentSeasonController
expose(:character) { Character.find params[:character_id] }
expose(:current_picks) { character.picks.map &CurrentPick.method(:new) }
def create
team = Team.find params[:team_id]
week = character.season.weeks.find_by number: params[:... |
# typed: true
# frozen_string_literal: true
$LOAD_PATH.unshift File.expand_path('../lib', __dir__)
require 'simplecov'
SimpleCov.start
require 'ffprober'
require 'minitest/autorun'
def fake_ffprobe_version_path
"#{File.expand_path(__dir__)}/fake_ffprobe_version"
end
def fake_ffprobe_output_path
"#{File.expand_p... |
class AddBookingRefToCartItems < ActiveRecord::Migration[5.1]
def change
add_reference :cart_items, :booking, foreign_key: true
end
end
|
# create a hash that expresses the frequency with which
# each letter occurs in this string
statement = "The Flintstones Rock"
h = {}
statement.chars.each do |x|
h[x] = statement.count(x) if x != " "
end
puts h
puts statement |
class ShowResource < BaseResource
SHOW_CONTENT_TYPE = "application/vnd.com.example.show+json"
SHOW_CONTENT_TYPE_V2 = "application/vnd.com.example.show-v2+json"
def content_types_provided
[
['text/html', :to_html],
[SHOW_CONTENT_TYPE, :to_show_json],
[SHOW_CONTENT_TYPE_V2, :to_show_json_v2... |
class Artist
attr_accessor :name, :songs
@@all = []
def initialize(name)
@name = name
@songs =[]
end
def add_song(songname)
#song = Song.new(songname)
@songs << songname
end
def save
@@all << self
self
end
def self.all
@@all
end
def self.find_or_create_by_name(art... |
module XMLMunger
class NestedHash < Hash
#######
# Don't lose class type
#######
(Hash.instance_methods - Object.instance_methods).each do |m|
define_method(m) { |*args, &block|
result = super(*args, &block)
return NestedHash[result] if result.class == Hash
result
... |
class Licencia < ActiveRecord::Base
self.table_name = 'licencias'
self.inheritance_column = 'ruby_type'
self.primary_key = 'id'
if ActiveRecord::VERSION::STRING < '4.0.0' || defined?(ProtectedAttributes)
attr_accessible :id_empresa, :id_chofer, :cedula, :motivo, :fecha_desde, :fecha_hasta, :importe, :salar... |
# encoding: UTF-8
module CDI
module V1
module GameQuestions
class ReorderService < BaseReorderService
record_type ::GameQuestion
def record_error_key
:game_questions
end
end
end
end
end
|
class Comment < ApplicationRecord
belongs_to :betting_ticket
belongs_to :end_user
end
|
class CreateModelings < ActiveRecord::Migration
def up
create_table :modelings do |t|
t.integer :placement
t.timestamps
end
end
def down
drop_table :modelings
end
end
|
# -*- encoding: utf-8 -*-
require 'nkf'
class BusinessPartner < ActiveRecord::Base
before_create :set_default
include AutoTypeName
has_many :businesses, :conditions => ["businesses.deleted = 0"]
has_many :bp_pics, :conditions => ["bp_pics.deleted = 0"]
has_many :biz_offers, :conditions => ["biz_offers.deleted... |
#
# Copyright (c) 2017 joshua stein <jcs@jcs.org>
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DIS... |
class AddAverageScoreToLearningTrack < ActiveRecord::Migration
def change
add_column :learning_tracks, :average_score, :float, :null => false, :default => 0
end
end
|
class ServiceMappingController < ApplicationController
before_action :logged_in_user, only: [:destroy, :create, :update, :list, :search, :find]
def create
if params.has_key?(:id_station)
if current_user.check_permission params[:id_station], params[:table_id], 1
@station = Station.find params[:id_sta... |
class Api::V1::TagTaggablesController < Api::V1::ApiController
before_action :set_tag_taggable, only: %i[show update destroy]
def index
@tag_taggables = current_user.tag_taggables
end
def batch_ensure_tags
params['taggables'].values.each do |taggable_params|
params['tags_ids'].each do |tag_id|
... |
# frozen_string_literal: true
# Filters a collection based on the internal members aggregator
class DuplicateFileIterator
include Enumerable
def initialize(collection = [], duplicates: true)
@collection = collection
@duplicates = duplicates
end
def each(&block)
grouped = @collection.group_by(&:ag... |
# encoding: UTF-8
# Copyright 2012 Twitter, Inc
# http://www.apache.org/licenses/LICENSE-2.0
require 'spec_helper'
describe TwitterCldr::Shared::TerritoriesContainment do
describe '.parents' do
it 'returns the parent territory' do
expect(described_class.parents('RU')).to eq(['151', 'UN'])
end
it... |
class Participation < ApplicationRecord
belongs_to :event
belongs_to :participant, class_name: "User"
after_create :new_participant_email
def new_participant_email
ParticipationMailer.new_participant_email(self.participant,self.event).deliver_now
end
end
|
class MeowsGenerator
def initialize
@basic_symbols = [
%w(m M),
%w(e E),
%w(o O),
%w(oo OO),
%w(w W),
['', '!']
]
end
def init_base_state(basic_symbols)
[0]*basic_symbols.size #array of zeros indexes
end
def next
if @current_meow.nil?
@cu... |
# -*- encoding: utf-8 -*-
Gem::Specification.new do |s|
s.name = "strobe-rails-ext"
s.version = "0.0.1"
s.platform = Gem::Platform::RUBY
s.authors = ["Carl Lerche", "José Valim"]
s.email = ["carl@strobecorp.com", "jose.valim@gmail.com"]
s.homepage = "http://rubygems.org/gems/strob... |
class Post < ApplicationRecord
belongs_to :user
validate :user_id, presence: true
validates :body, length: {minimum: 0, maximum: 142}
end
|
class SubTasksController < ApplicationController
def create
@task_params = task_params
@task = Task.find(@task_params[:id])
@task_params[:sub_tasks_attributes].each do |st|
st[:category] = @task.category
end
@task.sub_tasks_attributes = @task_params[:sub_tasks_attributes]
if @task.save
... |
# 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... |
module Fog
module Compute
class DigitalOceanV2
class Real
def list_images
request(
:expects => [200],
:method => 'GET',
:path => '/v2/images'
)
end
end
# noinspection RubyStringKeysInHashInspection
class Mock
... |
# encoding: utf-8
module ActiveRecordUtils
VERSION = '0.4.1'
end # module ActiveRecordUtils
|
require_relative './spec_helper'
require_relative '../far_mar'
describe FarMar::Vendor do
it "does this exist" do
FarMar::Vendor.wont_be_nil
end
describe "self.all" do
let(:all_vendors) { FarMar::Vendor.all}
it "creates an array of vendor info" do
all_vendors.must_be_instance_of(Array)
... |
require 'test_helper'
class UserEquipsControllerTest < ActionDispatch::IntegrationTest
setup do
@user_equip = user_equips(:one)
end
test "should get index" do
get user_equips_url, as: :json
assert_response :success
end
test "should create user_equip" do
assert_difference('UserEquip.count') ... |
module ThemedTextService
module_function
def user_notify(appointment)
template = appointment.worker.user_notify_template || <<-TEXT
Здравствуйте <ИМЯ>!
В <ДЕНЬ НЕДЕЛИ> <ДАТА НАЧАЛА> Вы записаны к мастеру <ДМАСТЕР> на следующие услуги: <СПИСОК УСЛУГ>.
Продолжительность приема: <ПРОДОЛЖИТЕЛЬНОС... |
class Notification < ActiveRecord::Base
belongs_to :user
belongs_to :notifiable, polymorphic: true
validates :user_id, :presence => true
validates :notifiable_id, :presence => true
validates :notifiable_type, :presence => true
validates :title, :presence => true
scope :viewed, -> {where(viewed: true... |
class FontArsenal < Formula
head "https://github.com/google/fonts.git", verified: "github.com/google/fonts", branch: "main", only_path: "ofl/arsenal"
desc "Arsenal"
homepage "https://fonts.google.com/specimen/Arsenal"
def install
(share/"fonts").install "Arsenal-Bold.ttf"
(share/"fonts").install "Arsena... |
class User < ActiveRecord::Base
has_many :phone_numbers, dependent: :destroy
has_and_belongs_to_many :street_addresses
end
|
class CreateResources < ActiveRecord::Migration
def self.up
create_table :resources do |t|
t.string :name
t.references :category
t.references :sub_category
t.references :vehicle_model_type
t.string :status
t.string :resource_type
t.string :resource_no
t.text :locati... |
# == Schema Information
#
# Table name: school_groups
#
# id :bigint(8) not null, primary key
# name :string
# identifier :string
# created_at :datetime not null
# updated_at :datetime not null
#
require 'rails_helper'
RSpec.describe SchoolGroup, type: :model do
# === Relat... |
class CompanyWrapper
attr_accessor :score
def self.wrap_companies(companies)
wrapped_companies = []
companies.each do |company|
wrapped_companies << CompanyWrapper.new(company)
end
return wrapped_companies
end
def initialize company
@company = company
@score = 0
... |
require 'pry'
require 'rainbow/ext/string' # Gives access to rainbow gem
travelling = "Y"
def line_n
["Times Square", "34th", "28th N", "23rd N", "Union Square", "8th N"]
end
def line_l
["8th", "6th", "Union Square", "3rd", "1st"]
end
def line_6
["Grand Central", "33rd", "28th", "23rd", "Union Square", "Astor... |
require 'sinatra'
require 'sinatra/reloader' if development?
enable :sessions
helpers do
def store_guess(filename, string) # stores the guess in a file
string.downcase!
File.open(filename, "a+") do |file|
file.puts(string)
end
end
def read_guesses # gets the guesses back out of a file and sets... |
class CreateAddresses < ActiveRecord::Migration
def change
create_table :addresses do |t|
t.boolean :correct, default: false
t.string :country_code
t.string :city
t.string :address_1
t.string :address_2
t.string :address_3
t.string :postcode
t.string :county
t... |
# frozen_string_literal: true
require "spec_helper"
RSpec.describe Tikkie::Api::V1::AccessToken do
describe '#token' do
it 'returns the access token' do
token = Tikkie::Api::V1::AccessToken.new("12345", 0)
expect(token.token).to eq("12345")
end
end
describe '#expired?' do
it 'is not exp... |
class UsersController < ApplicationController
require 'happybirthday'
def index
@events = current_user.events.order(:department_id)
birthday = Happybirthday.born_on(current_user.birthday)
@birthday = birthday.age.years_old
end
def show
@user = User.find(params[:id])
@events = @user.events.... |
require "rails_helper"
RSpec.describe Api::V1::InvoiceItems::InvoicesController, type: :controller do
describe "GET #show.json" do
let(:json_response) { JSON.parse(response.body) }
let(:invoice_item) { create(:invoice_item) }
let(:invoice) { invoice_item.invoice }
it "responds with successful 200 HT... |
# Filters added to this controller will be run for all controllers in the application.
# Likewise, all the methods added will be available for all controllers.
class ApplicationController < ActionController::Base
include AuthenticatedSystem
before_filter :login_from_cookie
def current_playlist
return unles... |
class User < ActiveRecord::Base
has_many :boards, -> { order(:title) }, dependent: :destroy
has_and_belongs_to_many :subscriptions, class_name: "Board", join_table: "subscriptions"
# Include default devise modules. Others available are:
# :omniauthable
devise :database_authenticatable, :registerable,
... |
require 'spec_helper'
require 'rack/mock'
describe "Rack::Molasses" do
def mock_request(options={})
app = lambda {|env| [200, {"Content-Type" => "text/plain"}, ["Hello World"]]}
app = Rack::Molasses.new(app, options)
Rack::MockRequest.new(app)
end
def mock_request_with_cache_control(cache_control, ... |
class TodoItem < ApplicationRecord
belongs_to :todo_list
PRIORITIES = [
['Later', 1],
['Next', 2],
['Now', 3]
]
def completed?
!completed_at.blank?
end
end
|
class CalculatorsController < ApplicationController
def new
@calculator = Calculator.new
end
def index
@calculators = Calculator.all
end
def create
@calculator = Calculator.new(calculator_params)
if @calculator.save
flash[:notice] = "Your estimate was calculated."
redirect_to cal... |
class User < ActiveRecord::Base
has_many :keys
validates_presence_of :email , :on => :create
validates :email, presence: true
validates_format_of :email, :with => /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/
validates_uniqueness_of :current_token
# raise
before_create :create_api_token
validates :email, length: { m... |
require "./lib/interface/message.rb"
module Hoze
class TestMessage < Message
attr_reader :delay_received, :ack_received, :reject_received
def initialize payload,timestamp,metadata
@payload = payload
@timestamp = timestamp
@metadata = metadata
@delay_received = []
@ack_receive... |
class Kitsu::Anime
require 'open-uri'
BASE_URL = 'anime?filter[seasonYear]='.freeze
def scrap_anime
(2017..Date.current.year).each do |year|
@titles ||= anime(year)
raise StandardError.new(@titles.body['errors']) if @titles.body['errors'].present?
create_or_update_anime(@titles)
end
... |
class BookingsController < ApplicationController
before_action :find_studio, only: [ :new, :create]
def index
@bookings = Booking.all
@bookings = policy_scope(Booking)
@bookings = policy_scope(Booking).order(created_at: :desc)
end
def new
@booking = Booking.new
end
def create
@bookin... |
class PaymentsController < ApplicationController
before_action :set_payment, only: [:show, :edit, :update]
before_action :set_subscription
before_action :set_plan, only: [:create, :update]
before_action :check_last_pending, only: :new
def index
end
def show
end
def new
@payment = Payment.new
... |
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
def current_user
User.find(session[:user_id]) if session[:user_id]
end
helper_method :current_user
def current_user_admin?
current_user && current_user.admin?
end
helper_method :current_user_admin?
def requi... |
class TcTemplatesController < ApplicationController
before_filter :login_required
before_filter :template_presence_required, :only=>"settings"
before_filter :general_settings_required, :only=>"settings"
before_filter :find_template
filter_access_to :all
include TcTemplateGenerateCertificatesHelper
def set... |
module Typeable
public
def validType
raise "Not implemented"
end
end
class Parser
include Typeable
private
@config = nil
@argument = nil
public
def initialize config = Config.new
@config = config
end
def parse input = ""
arg = input.split
@argument = Argu... |
module Shoperb module Theme module Editor
module Mounter
class Server
class ExceptionHandler
def initialize(app)
@app = app
end
def call(env)
begin
@app.call env
rescue Exception => e
Error.report_rack(e, env)
raise ... |
class ModalitiesController < ApplicationController
before_action :authenticate_user!
def index
@modalities = Modality.all
end
def new
@modality = Modality.new
end
def show
@modality = Modality.find(params[:id])
end
def edit
@modality = Modality.find(params[:id])
end
def create
... |
class AddVoiceFieldsToCampaign < ActiveRecord::Migration
def change
add_column :campaigns, :voice_call_script, :text, default: nil
add_column :campaigns, :voice_call_number, :string, default: nil
end
end
|
class ServiceLengthsController < ApplicationController
# GET /service_lengths
# GET /service_lengths.xml
def index
@service_lengths = ServiceLength.all
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @service_lengths }
end
end
# GET /service_lengths/1... |
# :nodoc:
class Array
# Yields unique and distinct permutations of _self_ to the block.
# This method does NOT require that array elements are Comparable.
# rubocop:disable CyclomaticComplexity, AbcSize, MethodLength, PerceivedComplexity, LineLength
def distinct_permutation
return enum_for(:distinct_permuta... |
class RefinerycmsSnippets < Refinery::Generators::EngineInstaller
source_root File.expand_path('../../../', __FILE__)
engine_name "snippets"
end
|
class Shoe
attr_accessor :color, :size, :material, :condition #can we change these attriabutes? The answer should be YES
attr_reader :brand
def initialize(brand) #I have initialized a brand for class Shoe.
@brand = brand
end
def cobble
#@condition = "new"
puts "Your shoe is as good as new!"
self.condition = "ne... |
# https://github.com/muzfuz/CodeLessons/blob/master/binary_search/binary_search.rb
#Constructor for the individual nodes
class Node
# instance variables, value, left & right child
attr_accessor :value, :left_child, :right_child
# looks like each node will have a value & a left & right child (but both children a... |
require 'spec_helper'
describe "Viewing list of reviews" do
it "shows the reviews for a specified facility" do
facility1 = Facility.create!(facility_attributes(name: "CareFully"))
review1 = facility1.reviews.create!(review_attributes(name: "Ali S"))
review2 = facility1.reviews.create!(review_attributes(... |
# pseudo
# Swapping the first and last name
# - first split up the full name into first and last name
# - then move that first name ahead of the last name
# - then unsplitting it by joining it back together
# Changing all of the vowels (a, e, i, o, or u) to the next vowel in 'aeiou',
#and all of the consonants ... |
json.array!(@events) do |event|
json.extract! event, :id, :name, :price
json.start event.created_at
json.title "#{event.name}:#{event.price}円"
json.allDay true
json.url wasting_url(event)
end |
desc "Create basic user roles"
task seed_roles: :environment do
if Common::Role.count == 0
Common::Role.create!([
{ name: Constants::SUPER_ADMIN, built_in: true },
# { name: "Admin" },
# { name: "Book Keeper" },
# { name: "Business Manager" },
# { name: "Business Owner" },
# { ... |
require 'rails_helper'
RSpec.describe "Items", type: :request do
describe "GET /items" do
it "listing all items" do
create(:item)
create(:item)
get items_path
expect(response).to have_http_status(200)
end
it 'list one item' do
item = create(:item)
get "/items/#{item.i... |
class Destination < ApplicationRecord
has_many :posts
has_many :bloggers, through: :posts
def posts_about_me
self.posts.all
end
end
|
class InternetsController < ApplicationController
before_action :set_internet, only: [:show, :edit, :update, :destroy]
# GET /internets
# GET /internets.json
def index
@internets = Internet.all
end
# GET /internets/1
# GET /internets/1.json
def show
end
# GET /internets/new
def new
@int... |
module SelfieChain
class Wrapper < BasicObject
def initialize(subject)
@subject = subject
end
def method_missing(method, *args, &block)
if !@subject.nil? && @subject.respond_to?(method)
@subject = @subject.public_send(method, *args, &block)
end
self
end
# returns @subject or other, if the ... |
module CollectionHelper
def collection_items(options={})
items = Spree::Variant.where(is_master: true).joins(:images).uniq
return items unless options[:preview]
items.select{|v| v.product.showcased }
end
def collection_thumbnail(img_path)
image_tag img_path, title: "furniture collection pull... |
require 'set'
module VWorkApp
class Base
include ActiveModel::Serializers::JSON
include ActiveModel::Serializers::Xml
include ActiveModel::Validations
def initialize(attributes = {})
self.attributes = attributes
end
# -----------------
# Hattr Methods
# ----------------
d... |
require_relative '../acceptance_helper'
feature 'create answer' do
given!(:current_user) { create(:user) }
given!(:other_user) { create(:user) }
given!(:question) { create(:question, user: current_user) }
given!(:other_question) { create(:question, user: other_user) }
scenario 'guest tries to answer questi... |
class Podcast < ActiveRecord::Base
outpost_model
has_secretary
include Concern::Callbacks::SphinxIndexCallback
ROUTE_KEY = "podcast"
ITEM_TYPES = [
["Episodes", 'episodes'],
["Segments", 'segments'],
["Content", 'content']
]
SOURCES = ["KpccProgram", "ExternalProgram", "Blog"]
CONTENT_C... |
class CreateProviders < ActiveRecord::Migration
def change
create_table :providers do |t|
t.belongs_to :location, index: true
t.string :title
t.string :name
t.string :photo_url
t.string :profile_url
t.string :email
t.string :phone_number
t.boolean :sliding_scale, de... |
class AddItemDeliveryFeeToShop < ActiveRecord::Migration
def change
add_column :shops, :item_delivery_fee, :jsonb, default: {}
end
end
|
require 'test_helper'
class SpaceTest < Test::Unit::TestCase
def test_should_find_single_space
space = Podio::Space.find(1)
assert_equal 1, space['space_id']
assert_equal 'API', space['name']
end
def test_should_find_all_for_org
spaces = Podio::Space.find_all_for_org(1)
assert spaces.is_a?... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.