text stringlengths 10 2.61M |
|---|
class DevController < ApplicationController
before_filter :require_authentication
permit 'developer'
helper :layout, :cobrand
def index
end
def email
@mail_types = {
:new_fan => "/email_contents/new_fan?cobrand=#{cobrand.short_name}&uid=3&fid=1",
:welcome => "/email_contents... |
class AddDefaultThumbImageToPortfolios < ActiveRecord::Migration[5.0]
def change
change_column_default :portfolios, :thumb_image, "http://placehold.it/350x200"
end
end
|
class DateTime
# http://stackoverflow.com/questions/15414831/ruby-determine-season-fall-winter-spring-or-summer#answer-15416170
def season
day_hash = month * 100 + mday
case day_hash
when 101..401 then :winter
when 402..630 then :spring
when 701..930 then :summer
when 1001..1231 then... |
if ENV['GITHUB_TOKEN'].nil?
puts 'GITHUB_TOKEN must be set. Create one here: https://github.com/settings/tokens'
exit
end
require 'graphql/client'
require 'graphql/client/http'
require 'open-uri'
HTTPAdapter = GraphQL::Client::HTTP.new('https://api.github.com/graphql') do
def headers(_context)
{ 'Authorizat... |
module Hippo::TransactionSets
module HIPAA_837
class L2000C < Hippo::TransactionSets::Base
loop_name 'L2000C' #Patient Hierarchical Level
#Patient Hierarchical Level
segment Hippo::Segments::HL,
:name => 'Patient Hierarchical Level',
:minimum ... |
# frozen_string_literal: true
module SystemCtl
class Driver
def self.create
commandline = SystemCtl::Commandline.new(which('systemctl'))
new(
SystemCtl::PlistToServiceFileConverter.new,
# SystemCtl::StandardRunInfoGenerator.new(commandline),
SystemCtl::ExperimentalRunInf... |
class Knight < Piece
include SteppingPiece
VECTORS = [[1, 2], [1, -2], [2, 1], [2, -1], [-1, -2], [-1, 2], [-2, 1], [-2, -1]]
SYMBOLS = {white: "\u2658", black: "\u265e"}
def initialize(current_pos, color, board)
super(current_pos, color, board)
@symbol = SYMBOLS[color]
end
end |
# frozen_string_literal: true
RSpec.describe SC::Billing::Stripe::Invoices::CreateOperation, :stripe do
describe '#call' do
subject(:call) do
described_class.new.call(stripe_invoice, extra_params)
end
let!(:stripe_invoice) do
plan = stripe_helper.create_plan
item = ::Stripe::InvoiceIte... |
class Recipe
@@all = []
attr_accessor :name
def initialize(name)
@name = name
@@all << self
end
def self.all
@@all
end
def user_cards
RecipeCard.all.select {|element| element.recipe == self}
end
# def most_popular_helper
# Allergen.all.select do |instance|
# instance.ing... |
# Prepend
# Available since Ruby 2, prepend is a bit less known to Rubyists than its
# two other friends. It actually works like include, except that instead
# of inserting the module between the class and its superclass in the chain,
# it will insert it at the bottom of the chain, even before the class itself.
# sourc... |
class BidsController < ApplicationController
before_filter :authenticate_user!
def index
@bids = Bid.all
end
def show
@bid = Bid.find(params[:id])
if @bid.bidder != current_user
render text: 'Cannot see the details of other users bid', status: :unauthorized
end
end
def new
@bi... |
require 'test_helper'
class PostsInterfaceTest < ActionDispatch::IntegrationTest
#include Devise::Test::IntegrationHelpers #Deviseヘルパーをインクルードしないとダメ
include Warden::Test::Helpers
def setup
Warden.test_mode!
@user = users(:taro)
login_as(@user, :scope => :user)
@post = posts(:one)
@post2 = posts(... |
class Question < ActiveRecord::Base
extend FriendlyId
friendly_id :title, use: :slugged
has_many :answers
has_many :favorite_questions
belongs_to :user
has_reputation :votes,
source: :user,
aggregated_by: :sum
has_reputation :favorite_question,
source: :user,
aggregated_by: :sum
... |
require "application_system_test_case"
class StargateManualOverridesTest < ApplicationSystemTestCase
setup do
@stargate_manual_override = stargate_manual_overrides(:one)
end
test "visiting the index" do
visit stargate_manual_overrides_url
assert_selector "h1", text: "Stargate Manual Overrides"
end... |
RSpec.feature "Users can create an actual" do
context "when the user belongs to BEIS" do
let(:user) { create(:beis_user) }
before { authenticate!(user: user) }
after { logout }
scenario "the form only shows relevant fields" do
activity = create(:programme_activity, :with_report, organisation: ... |
module SemanticNavigation
module Renderers
module MixIn
module ActsAsList
def render_navigation(object)
return '' unless object.render_if
navigation(object) do
object = first_rendering_object(object)
if !is_leaf?(object) && show_object?(object)
... |
class GameFunction
def play_game
raise NotImplementedError, 'Subclasses must override'
end
def stop_game
raise NotImplementedError, 'Subclasses must override'
end
def delete_game
raise NotImplementedError, 'Subclasses must override'
end
def game_details
raise NotImplementedError, 'Subc... |
require 'rails_helper'
RSpec.describe ApplicationController do
controller(ApplicationController) do
def index; end
end
context 'without an API token' do
it 'returns an unauthorized status' do
get :index
expect(response).to have_http_status(:unauthorized)
end
end
context 'with an in... |
module EasyPatch
module SafeAttributesClassMethodsPatch
def self.included(base)
base.class_eval do
def delete_safe_attribute(attr_name)
@safe_attributes.delete_if{|k, v| k == [attr_name]}
@safe_attributes.each{|k, v| k.delete_if{|n| n == attr_name}}
end
end
... |
class Admin::DisciplineAssociationsController < Admin::BaseController
before_action :_set_discipline, only: %i[new create]
before_action :_set_discipline_association, except: %i[new create]
def new
@discipline_association = @discipline.discipline_associations.new
render partial: 'form', layout: false
e... |
require 'active_support/core_ext/module/aliasing'
module Recliner
module Properties
module Map#:nodoc:
extend ActiveSupport::Concern
included do
Recliner::Property.send(:include, PropertyWithMapDefault)
end
module ClassMethods
# Creates a new Map class with t... |
class DesignByContract::Interface
def initialize(method_specifications)
@method_specifications = method_specifications.reduce({}) do |ms, (name, raw_signature)|
ms.merge(name => DesignByContract::Signature.new(raw_signature))
end
end
def implemented_by?(implementator_class)
@method_specificatio... |
# frozen_string_literal: true
class SignatureMatcher
# Envoyé depuis mon iPhone
# Von meinem Mobilgerät gesendet
# Diese Nachricht wurde von meinem Android-Mobiltelefon mit K-9 Mail gesendet.
# Nik from mobile
# From My Iphone 6
# Sent via mobile
# Sent with Airmail
# Sent from Windows Mail
# Sent fr... |
require File.dirname(__FILE__) + '/../../spec_helper'
describe "System::String#include?" do
before(:each) do
@str = "string".to_clr_string
end
it "takes System::Strings" do
@str.include?("rin".to_clr_string).should be_true
end
it "takes Ruby Strings" do
@str.include?("rin").should be_true
end... |
require 'terraform_tool/common'
require 'terraform_tool/generate'
require 'terraform_tool/global_commands/validate'
require 'terraform_tool/context_management/context'
require 'terraform_tool/context_management/helpers'
require 'terraform_tool/templates/template_binding'
require 'terraform_tool/templates/partial'
modu... |
require File.dirname(__FILE__) + '/../test_helper'
class AccountTypeTest < Test::Unit::TestCase
fixtures :account_types
def test_is_account_type_free
freebie = account_types(:free)
assert freebie.is_free?
not_freebie = account_types(:not_free)
assert !not_freebie.is_free?
end
end
|
require 'rails_helper'
RSpec.describe User, type: :model do
let(:user) { build(:user) }
it 'has a username' do
expect(user.username).to be_a(String)
end
it 'has an email address' do
expect(user.email).to be_a(String)
end
it 'has a password' do
expect(user.password).to be_a(String)
end
end
|
# frozen_string_literal: true
module Bridgetown
module Builders
class DocumentBuilder
attr_reader :site
def initialize(site, path)
@site = site
@path = path
@data = HashWithDotAccess::Hash.new
end
def front_matter(data)
@data.merge!(data)
end
... |
#!/usr/bin/ruby
require 'rubygems'
require 'mysql'
require "yaml"
require 'rubygems'
require 'webrick'
require "json"
class Areas < WEBrick::HTTPServlet::AbstractServlet
def do_GET(request, response)
status, content_type, body = print_result(request)
response.status = status
response['Content-Type'] =... |
Rails.application.routes.draw do
resources :students
get '/all', to: 'students#index', as: 'all'
end
|
class UpdateContacts < ActiveRecord::Migration[7.0]
def change
change_table :contacts do |t|
t.column :nickname, :text
t.column :raw, :jsonb
t.column :apple_contact_id, :text
end
end
end
|
class PaymentsController < ApplicationController
def new
if @invoice = Invoice.find_by_token(params[:invoice_token])
@payment = @invoice.payments.build :payer_name => @invoice.name
@no_banner = true
else
flash[:error] = "Invalid link."
redirect_to root_url
end
end
def create
... |
json.fields @fields do |field|
json.name field.name
json.lat field.latitude
json.lng field.longitude
json.events field.events do |event|
json.id event.id
json.name event.name
json.start event.start_datetime
end
end |
# frozen_string_literal: true
# rubocop:todo all
require 'spec_helper'
describe Mongo::Operation::CreateIndex do
require_no_required_api_version
let(:context) { Mongo::Operation::Context.new }
before do
authorized_collection.drop
authorized_collection.insert_one(test: 1)
end
describe '#execute' d... |
class SessionsController < ApplicationController
def new; end
def create
user = User.where(name: params[:session][:name]).first if params[:session][:name]
if user
session[:user_id] = user.id
flash[:notice] = 'Successfully logged in'
redirect_to user_path(user)
else
flash[:alert]... |
require 'fileutils'
require 'activefolder/metal/errors'
module ActiveFolder
module Metal
module Adapters
class Local
def initialize(config)
@config = config
end
def read(path)
File.read full_path(path)
rescue Errno::ENOENT => e
raise NotFoundE... |
class Array
def shuffle
shuffled_arr = []
while self.length > 0
item = self.sample
shuffled_arr << item
self.delete(item)
end
return shuffled_arr
end
end
class Integer
def factorial
total = 1
factor = self
raise "Please enter a positive integer" if s... |
# 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 'rails_helper'
RSpec.describe User, type: :model do
let(:first_user){ create(:user) }
let(:second_user){ create(:user) }
let!(:review){ create(:review, reviewee: second_user) }
let!(:group){ create(:group, administrator: second_user) }
it "should respond true to User?" do
expect(first_user.user?... |
class RiskLevel < ActiveRecord::Base
has_many :plans
has_many :users, through: :plans
validates_uniqueness_of :name
end |
# == Schema Information
#
# Table name: data_configs
#
# id :bigint not null, primary key
# index_name :string
# keywords :string is an Array
# created_at :datetime not null
# updated_at :datetime not null
#
# Works with TwitterConfsController to govern the creation o... |
class Person
def initialize(name, age)
@name = name
@age = age
end
def name
@name
end
def age
@age
end
def birthday
@age += 1
end
def change_name(name)
@name = name
end
end
class User
def initialize(login, password)
@login = login
@password = password
end... |
class Gift < ActiveRecord::Base
validates_presence_of :name
validates_uniqueness_of :name
validates_format_of :gifter, :allow_nil => true,
:with => /^.{2,20}$/i,
:message => "must be between 2 and 20 characters long. It is not case-sensitive, i.e. it doesn't matter if you have the caps lock on/off."
H... |
# アクセサ
class User
def initialize(name)
@name = name
end
=begin
# アクセサ
# getter
def name
@name
end
# setter
def setName(newName)
@name = newName
end
=end
# getter/setterを自動生成してくれる構文
attr_accessor :name
# attr_reader :name # getterのみ定義したい場合
# attr_writer :name # setterのみ定義したい場合
d... |
# This controller handles the login/logout function of the site.
class SessionsController < ApplicationController
include UserSessionHelper
def new
@user = User.new
respond_to do |format|
format.html
end
end
def create
logout_keeping_session!
# set session return_to valu... |
require 'puppet/provider/f5'
Puppet::Type.type(:f5_node).provide(:f5_node, :parent => Puppet::Provider::F5) do
@doc = "Manages f5 node"
mk_resource_methods
confine :feature => :ruby_savon
defaultfor :feature => :ruby_savon
def initialize(value={})
super(value)
@property_flush = {}
end
def sel... |
require 'osx/cocoa'
class MenuController < OSX::NSObject
include OSX
ib_outlet :menu
ib_outlet :syncNowMenuItem
ib_outlet :lastSyncStatusMenuItem
SYNC_BUNDLE_IDENTIFIER = 'com.floehopper.installdSync'
PREF_PANE_PATH = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..', '..', '..'... |
require 'test_helper'
class ValuationsControllerTest < ActionController::TestCase
setup do
@valuation = valuations(:one)
end
test "should get index" do
get :index
assert_response :success
assert_not_nil assigns(:valuations)
end
test "should get new" do
get :new
assert_response :succ... |
require 'spec_helper'
describe 'Venue' do
describe 'creation' do
context 'valid attributes' do
it 'should be valid' do
venue = FactoryGirl.build(:venue)
expect(venue).to be_valid
end
end
context 'invalid attributes' do
it 'should not be valid' do
venue = ... |
class TagTopic < ApplicationRecord
validates :topic, presence: true, uniqueness: true
has_many(
:taggings,
class_name: "Tagging",
foreign_key: :topic_id,
primary_key: :id
)
has_many(
:urls,
through: :taggings,
source: :url
)
def popular_links
# urls.group(:id).order(:num_c... |
require 'dry/validation/deprecations'
module Dry
module Validation
Message = Struct.new(:rule, :predicate, :text) do
def to_s
text
end
def signature
@signature ||= [rule, predicate].hash
end
def eql?(other)
other.is_a?(String) ? text == other : super
... |
class AddHashtag3ToMicroposts < ActiveRecord::Migration[5.0]
def change
add_column :microposts, :hashtag3, :string
end
end
|
class Music < ActiveRecord::Base
has_many :music_detail
scope :with_detail, -> { joins(:music_detail) }
scope :by_id, -> id { where(id: id) if id.present? }
scope :by_attr, -> attr { where(attr: attr) if attr.present? }
scope :at_random, -> { where( 'id >= ?', rand( first.id..last.id ) ).first }
end
|
namespace :dev do
#加入 :environment 可以讓你的 Rake 與專案的 Model 和資料庫互動
task fake_restaurant: :environment do
Restaurant.destroy_all
500.times do |i|
Restaurant.create!(
name: FFaker::Name.first_name,
opening_hours: "11:00",
tel: FFaker::PhoneNumber.short_phone_number,
address... |
class ConnectionsController < ApplicationController
before_action(:find_connection, {only: [:edit, :destroy] })
def create
@connection = Connection.create(connection_params)
@connection.user_id = params[:user_id]
@connection.save
flash[:notice] = "#{@connection.name} has been added as ... |
module Budgets
def self.table_name_prefix
'budgets_'
end
end
|
class MyContactsController < ApplicationController
def index
@contacts = current_user.contacts.page(params[:page])
respond_to do |format|
format.html
format.csv {send_data @contacts.to_csv}
format.xls #{send_data @contacts.to_csv(col_sep: "\t")}
end
end
end |
namespace :pandorica do
desc 'load transcripts into the database'
task :load => :environment do
directory = Rails.root + Rails.application.config.transcript_directory
unless File.directory?(directory)
puts "Error: #{directory} not a directory."
return
end
Dir.foreach(directory) do |fi... |
class AddSpouseNameToContacts < ActiveRecord::Migration
def change
add_column :contacts, :spouse_name, :string
end
end
|
# RubIRCd - An IRC server written in Ruby
# Copyright (C) 2013 Lloyd Dilley (see authors.txt for details)
# http://www.rubircd.rocks/
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either ver... |
class Project < ApplicationRecord
has_many :milestones, dependent: :destroy
validates :name, presence: true
validates :short_description, presence: true
end
|
class TasksController < ApplicationController
before_action :authenticate_user!, except: [:index, :show]
before_action :set_assignment
before_action :set_task, except: [:create, :index]
def index
@user = current_user
@tasks = @user.tasks.all
respond_with(@tasks)
end
def create
@task = @as... |
class WorkerBase
include Sidekiq::Worker
def perform
raise 'should override method'
end
end |
class FamilyDetail < ApplicationRecord
has_paper_trail
belongs_to :personel_detail
mount_uploader :photo, PhotoUploader
rails_admin do
create do
field :type , :enum do
enum do
[['Wife','Wife'],['Kid', 'Kid'], ['OtherRelation', 'OtherRelation']]
... |
class TasksController < ApplicationController
before_action :authenticate_user!, only:[:new, :create, :edit, :update, :destroy]
def show
board = Board.find(params[:board_id])
@task = board.tasks.find(params[:id])
@comments = @task.comments.all
end
def new
board = Board.find(params[:board_id... |
module Drivable
def drive
puts "It can drive"
end
end
class Vehicle
@@number_of_vehicles = 0
attr_accessor :color
attr_reader :year
def intialize
@@number_of_vehicles += 1
end
def self.number_of_vehicles
puts "There are #{@@number_of_vehicles} vehicles"
end
def initialize(year, colo... |
module UsersHelper
def is_author?(article)
current_user == article.user
end
def avatar_for(user, size)
#gravatar_id = Digest::MD5.hexdigest(user.email.downcase)
#"http://gravatar.com/avatar/#{gravatar_id}.png?s=#{size}&d=404"
"//api.adorable.io/avatars/#{size}/#{user.username}.png"
end
end
|
class QuickActionsController < ::ActionController::Base
include AuthHelper
include QuickActionsHelper
helper_method :current_user, :user_signed_in?
layout "quick_actions"
before_action :redirect_to_login
private
def redirect_to_login
redirect_to login_path if current_user.blank?
end
end
|
class SlackInvite < ActiveRecord::Base
validates :email, presence: true, uniqueness: { case_sensitive: false }, format: /@/
validates :username, presence: true, uniqueness: { case_sensitive: false }
scope :uninvited, -> { where(invited: false) }
scope :invited, -> { where(invited: true) }
scope :newest, ... |
class Learning < AbstractModel
belongs_to :learnable, polymorphic: true
def name
summary
end
def show_fields
[
{name: :summary, type: :text_field, options: {}},
{name: :description, type: :text_area, options: {class: :wysihtml5, autofocus: true}},
{name: :learnable_typ... |
class Rover
attr_accessor :xbound, :ybound, :direction
#Directions designated as 0..3 (N..W)
def initialize(xbound, ybound, direction) #initializes new objects (rovers) with its states (x, y, direction)
@xbound = xbound
@ybound = ybound
@direction = direction
end
def read_instructions
thirdline = ge... |
class TwilioOutbound
include Sidekiq::Worker
def perform(number, body)
twilio = Twilio::REST::Client.new(Figaro.env.twilio_account_sid,
Figaro.env.twilio_auth_token)
twilio.messages.create(
from: Figaro.env.twilio_number,
to: PhoneNumber.new(number).e164,
... |
# frozen_string_literal: true
require 'rails_helper'
describe Agent do
describe "RDF type" do
subject { described_class.new.type }
it { is_expected.to include(AICType.Agent, ::RDF::Vocab::FOAF.Agent) }
end
describe "terms" do
subject { described_class.new }
AgentPresenter.terms.each do |term|
... |
description 'Asset manager'
class ::Olelo::Application
@assets = {}
@scripts = {}
class << self
attr_reader :assets, :scripts
end
attr_reader? :disable_assets
hook :script, 1 do
js = Application.scripts['js']
if js && !disable_assets?
path = build_path "_/assets/assets.js?#{js.first.to... |
class AddLinkToFotocopium < ActiveRecord::Migration
def change
add_column :fotocopia, :link, :text
end
end
|
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe Country, type: :model do
context 'when creating a new country' do
it 'is valid with description' do
country = create(:country)
expect(country).to be_valid
end
end
end |
require 'pry'
class Author
attr_accessor :name
@@all = []
def initialize(name)
@name = name
@@all << self
end
def self.all
@@all
end
def add_post(post)
post.author = self
end
def add_post_by_title(title)
post = Post.new(title)
post.author = self
end
def posts
Post.all.select { |post| post.a... |
module Thetoolbox
module SlugFinders
def find_by_slug(*args)
record = find(*args)
if record and record.respond_to? :slug
return nil unless record.slug == args.first
end
record
end
def find_by_slug!(*args)
find_by_slug(*args) or raise ActiveRecord::RecordNotFound
... |
Rails.application.routes.draw do
#データベースにテーブルがあるかないかで表記方法変える!
#要するにテーブルあるならresource使えてないならget "a", to コントローラ名#アクション名 ってやること。
#下の解説にもよく目を通すこと。
#
# to: に書いてある内容
# コントローラー名#アクション名に飛ばしてるよ
#絶対この名前のコントローラーがあるよ。
#ログイン機能のやつ(テーブルないからresources使ってない)
#ログインのnewとかcreateとかdestroyとか意味わからんやん,テーブルがないから
#... |
require_relative( '../db/sql_runner' )
class Animal
attr_reader(:id)
attr_accessor( :name, :adopt_status, :type, :breed, :admis_date, :good_with_kids, :good_with_other_pets, :need_attention)
def initialize(details)
@id = details['id'].to_i if details['id']
@name = details['name']
@adopt_status = d... |
class CreatePcAustattungs < ActiveRecord::Migration
def change
create_table :pc_austattungs do |t|
t.string :typ
t.string :modell
t.string :service_tag
t.string :mac_wlan
t.string :mac_lan
t.string :kommentar
t.string :team_viewer_id
t.string :status
t.timest... |
# added in release 2.0.0
module GroupDocs
class Document::TemplateEditorFieldOption < Api::Entity
# @attr [String] name
attr_accessor :name
# @attr [GroupDocs::Document::Rectangle] rect
attr_accessor :rect
end # Document::TemplateEditorFieldOption
end # GroupDocs
|
class CreateIdentifications < ActiveRecord::Migration
def change
create_table :identifications do |t|
t.string :foid_type
t.string :foid
t.string :notes
t.references :profile, index: true
t.timestamps
end
end
end
|
class Attack < ActiveRecord::Base
has_many :attack_links
has_many :pokemons, through: :attack_links
end
|
require 'rails_helper'
RSpec.describe "subclassifications/new", type: :view do
before(:each) do
assign(:subclassification, Subclassification.new(
classification: nil,
name: "MyString",
description: "MyString"
))
end
it "renders new subclassification form" do
render
assert_sele... |
gem 'minitest', '~> 5.0'
require 'minitest/autorun'
require 'minitest/pride'
require_relative 'date_night'
class NodeTest < Minitest::Test
def test_node_has_title
dark_night = Node.new(80, "Dark Night")
assert_equal "Dark Night", dark_night.title
end
def test_node_can_have_different_title
batman_begi... |
class User < ApplicationRecord
has_secure_password
has_many :sent_invites, foreign_key: :sender_id, class_name: :Invite
has_many :received_invites, foreign_key: :receiver_id, class_name: :Invite
has_many :contacts, foreign_key: :user_1, class_name: :Contact
belongs_to :meeting_room, foreign_key: :meeting_id,... |
class User < ActiveRecord::Base
EMAIL_LENGTH_MAX = 100
PASSWORD_LENGTH_MAX = 16
has_secure_password
has_many :orders
has_many :addresses
validates :first_name, :last_name, presence: true
validates :email, presence: true, confirmation: true, uniqueness: true
validates :email_confirmation, presence: t... |
# Just to silence the linter
class User < ApplicationRecord
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
has_many :groups
has_man... |
# X) Hashes: Key/Value pairs
# Hash is a mapping from a key to a value
#
# Example:
#
# a vending machine maps a location code to
# the food in that slot:
#
# Note: This is called a "Hash Rocket": =>
vending_machine = {
'A1' => 'Doritos',
'A2' => 'Cool Ranch Doritos',
'B1' => 'Cheetos',
'B2' => 'Snickers'
}
... |
{
"kind": "customsearch#search",
"url": {
"type": "application/json",
"template": "https://www.googleapis.com/customsearch/v1?q={searchTerms}&num={count?}&start={startIndex?}&lr={language?}&safe={safe?}&cx={cx?}&sort={sort?}&filter={filter?}&gl={gl?}&cr={cr?}&googlehost={googleHost?}&c2coff={disableCnTwTranslatio... |
class Product < ActiveRecord::Base
#belongs_to :category
has_many :orders
has_many :buyers, through: :orders, source: :user
#has_many :users, through: :orders
# has_many :korisnika, through: :orders, source: :user
has_many :reviews
validates :price, numericality: true
... |
module ESearchy
module UI
module CommandParser
#
# Command: Meta_cmd
# Description: This is the meta handler for all commands.
#
def run_cmd(method, arguments)
if self.respond_to?("cmd_"+ method)
self.send("cmd_"+ method, arguments || [])
else
Display.error "Command #{method.spl... |
class HomeController < ApplicationController
def index
@posts = Post.order(id: :desc).page(params[:page]).per Settings.per_page
end
end
|
class Web::Admin::OrganizersController < Web::Admin::ApplicationController
add_breadcrumb :index, :admin_organizers_path
def index
@organizers = Organizer.asc_by_order_at
end
def new
@organizer = Organizer.new
add_breadcrumb :new, new_admin_organizer_path
end
def create
@organizer = Organ... |
require 'spec_helper'
describe "opendata_agents_nodes_url_resource", dbscope: :example, http_server: true,
doc_root: Rails.root.join("spec", "fixtures", "opendata") do
def create_url_resource(dataset, license, original_url)
url_resource = dataset.url_resources.new(
name: "test",
... |
get '/questions/:question_id/edit' do
@question = Question.find(params[:question_id])
if authorized?(@question.survey_id)
@answers = @question.answers.order("id")
erb :'/surveys/edit_question'
else
get_failure
erb :index
end
end
post '/questions/:question_id/answers/new' do
question = Quest... |
# frozen_string_literal: true
class Course < ApplicationRecord
acts_as_commontable dependent: :destroy
has_one_attached :cover_picture
has_many :course_lecture
has_many :user_course
has_many :course_certificates
belongs_to :course_category
validates :name,
presence: true,
lengt... |
class CreateStores < ActiveRecord::Migration[6.0]
def change
create_table :stores do |t|
t.string :store_name, null: false
t.string :adress
t.string :store_phonenumber, null: false
t.string :store_description
t.references :store_manager
t.timestamps
end
end
end
|
include DataMagic
When(/^I navigate to the Login page$/) do
## When using local.yml, we use the local_login_url: variable, otherwise use login_url: variable.
begin
login_url = FigNewton.local_login_url
rescue
login_url = on(LoginPage).login_page_url
end
## when running locally, the first time to go... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.