text stringlengths 10 2.61M |
|---|
class CheckoutController < ApplicationController
before_action :warning, only: [:show]
before_action :load_cart
def show
load_items_from_cart
@token = Braintree::ClientToken.generate
end
def payment
load_items_from_cart
create_order_from_items
result = Braintree::Transaction.sale(
... |
class Post < ActiveRecord::Base
validates :title, presence: true
validates :description, presence: true
has_many :votes
belongs_to :user
end |
class CartsController < ApplicationController
before_action :load_cart, only: %i(show plus minus)
def show
if @cart
@products = []
@product_ids = @cart.collect{|key,value| key }
@products = Product.by_product_id(@product_ids)
else
flash[:danger] = t("controller.carts.cart_not_found"... |
class BoilerHints < Hobo::ViewHints
children :appearances
end
|
Sequel.migration do
up do
create_table(:centros) do
primary_key :id
String :name
end
end
down do
drop_table(:centros)
end
end
|
# frozen_string_literal: true
class GuruLetter
include ActiveModel::Model
EMAIL_FORMAT = /\A[^@\s]+@[^@\s]+\z/.freeze
attr_accessor :name, :email, :message
validates :name, :message, presence: true
validates :email, format: EMAIL_FORMAT
end
|
require 'test_helper'
class JadwalsControllerTest < ActionDispatch::IntegrationTest
setup do
@jadwal = jadwals(:one)
end
test "should get index" do
get jadwals_url
assert_response :success
end
test "should get new" do
get new_jadwal_url
assert_response :success
end
test "should cre... |
class ReferencesMigration < ActiveRecord::Migration[6.0]
def change
#Table Licence
create_table :licences
#Nom de la licence
add_column(:licences, :nom, :string, null: false)
#Id du propriétaire de la licencer
add_column(:licences, :licencer_id, :integer)
#=========================================... |
class InvitationDecorator
STATUS_MAPPER = {
'sent' => 'dark',
'refused' => 'danger',
}
def initialize(invitation)
@invitation = invitation
end
def boostrap_color_class
STATUS_MAPPER[@invitation.status]
end
delegate :email, to: :@invitation
end |
class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
before_filter :prepare_auth
def twitter
connect(:twitter)
end
private
def prepare_auth
@auth = request.env["omniauth.auth"]
end
def connect(provider_type)
social_provider = SocialProvider.find_for_oauth(@aut... |
# add acknowledged columns
class AddAcknowledgedToFailures < Rails.version < '5.1' ? ActiveRecord::Migration : ActiveRecord::Migration[4.2]
def change
add_column :failures, :acknowledged, :boolean, default: false
add_column :failures, :acknowledged_user_id, :integer
end
end
|
# Facebook is now versioning their API. # If you don't specify a version, Facebook
# will default to the oldest version your app is allowed to use. Note that apps
# created after f8 2014 *cannot* use the v1.0 API. See
# https://developers.facebook.com/docs/apps/versions for more information.
#
# You can specify version... |
class MachineSnack < ApplicationRecord
belongs_to :machine
belongs_to :snack
end
|
#!/usr/bin/env ruby
require 'rubygems'
require 'bundler/setup'
$:.unshift(File.dirname(__FILE__))
require 'TestSetup'
require 'date'
# Much of Select is tested in the "roundtrip" test.
class SelectTest < Test
include SqlPostgres
include TestUtil
def test
makeTestConnection do |connection|
connectio... |
# frozen_string_literal: true
module QueryHelpers
def where_id(collection_ids)
where('_id' => { '$in' => collection_ids })
end
def paginate(per_page, page_number)
offset = (page_number.to_i - 1) * per_page.to_i
limit(per_page).offset(offset)
end
end
|
require 'test_helper'
class Users::RegistrationsControllerTest < ActionController::TestCase
include Devise::TestHelpers
setup do
@admin = users(:alice)
@user = users(:bob)
@request.env["devise.mapping"] = Devise.mappings[:user]
end
test "should not get own profile when logged out" do
get :show
assert_... |
class AddAttributesToPost < ActiveRecord::Migration
def change
add_column :posts, :post_type, :string
add_column :posts, :author, :string
add_column :posts, :introduction, :text
end
end
|
class Piece
attr_reader :pos
def initialize(color, board, pos)
@color = color
@board = board
@pos = pos
end
def to_s
end
def empty?
end
def valid_moves
possible_moves = []
x, y = self.pos
move_diffs.each do |(dx, dy)|
new_pos = [x + dx, y + dy]
if new_pos.all? {... |
class Events::CreateOrUpdateService
def create_or_update(event:, user:)
if (local_event = ::Event.find_by_google_id(event.id)).present?
local_event.update!(
input_params(event, user)
)
local_event
else
event = ::Event.create!(
input_params(event, user)
)
end
... |
class CreateNationWonders < ActiveRecord::Migration
def change
create_table :nation_wonders, :id => false do |t|
t.integer :nation_id
t.integer :wonder_id
t.timestamps
end
end
end
|
include_recipe "homebrew"
package "pow"
execute "pow --install-local" do
user node[:homebrew][:user]
not_if "pow --install-local --dry-run"
end
execute "sudo pow --install-system" do
user node[:homebrew][:user]
not_if "pow --install-system --dry-run"
end
|
Before do
WebMock.stub_request(:get, 'https://co-up.cobot.me/api/navigation_links')
.to_return(body: '[]')
WebMock.stub_request(:post, 'https://co-up.cobot.me/api/navigation_links')
.to_return do |request|
request_body = JSON.parse(request.body, symbolize_names: true)
# we pr... |
require 'rails_helper'
RSpec.describe CollectiblesController, :type => :controller do
context "logged-in users" do
before(:each) do
@user = FactoryGirl.create(:user)
sign_in @user
end
describe "GET show" do
it "assigns the requested collectible as @collectible" do
collecti... |
module Chartup
class Measure
attr_accessor :chords, :starts_with_repeat, :ends_with_repeat, :index, :line
# Builds a new Measure.
# @param string [String] the string of chords to be parsed.
# @param index [Fixnum] the index of this Measure in its parent Line.
# @param line [Line] the parent line.... |
###
# Environment:
# name: Environment name
# type: in-external-single-select
# external_resource: rlm_environments
# position: A1:B1
# required: yes
# Property:
# name: Property name
# position: E1:F1
# type: in-external-single-select
# external_resource: rlm_environment_properties
# required: yes
... |
class UsersController < ApplicationController
layout 'layouts/login_layout', :only => [:login, :authenticate,:registration,:create,:show]
def login
end
def registration
@user = User.new
end
def create
@user = User.new(user_permitted_params)
if @user.valid?
flash[:notice] ... |
Rails.application.routes.draw do
mount ServiceAuth::Engine => "/service_auth"
end
|
# name_searchable.rb
# mix this into your class using
# extend NameSearchable
module NameSearchable
def search_by_prefix (prefix)
self.where("lower(name) LIKE '#{prefix.downcase}%'")
end
end |
class LoginTest
def initialize(pages)
@pages = pages
end
def load_login_page
@pages.page_home.load
@pages.page_home.visible?
@pages.page_home.open_login
end
def enter_login_details(user)
@pages.page_home.login_input_email user.email
@pages.page_home.login_input_password user.passwo... |
class RunInstanceState
# Directory Structure
# ./run_instances
# ./1580258
# log.txt
# config.json
# state.json
#
def initialize(id, config)
@id = id
@config = config
Dir.make_dir(base_dir)
write_config(config)
end
def base_dir
"./run_instances/#{id.to_s}"... |
# encoding: UTF-8
# Copyright 2012 Twitter, Inc
# http://www.apache.org/licenses/LICENSE-2.0
module TwitterCldr
module Tokenizers
autoload :Base, 'twitter_cldr/tokenizers/base'
autoload :Token, 'twitter_cldr/tokenizers/token'
autoload :Tokenizer, ... |
class AddAFewToRedeemable < ActiveRecord::Migration
def change
add_column :redeemables, :company, :string
end
end
|
class Lot < ActiveRecord::Base
attr_accessible :lot_number, :comments, :item_master_id
attr_accessible :lot_versions_attributes
belongs_to :item_master
has_many :lot_versions, dependent: :destroy, order: :version
accepts_nested_attributes_for :lot_versions, allow_destroy: true
validates :item_master_i... |
class Notification < ApplicationRecord
belongs_to :user
validates_presence_of :notification_type
after_create :deliver
def self.types
User.notification_types.collect {|t| t.gsub('_notifications','')}
end
def self.available_types
self.types.select {|t| !I18n.t("notification.types.#{t}.short"... |
class AddStripResponseToOrders < ActiveRecord::Migration
def change
add_column :orders, :strip_response, :string
end
end
|
# frozen_string_literal: true
ActiveRecord::Schema.define do
create_table "users", force: :cascade do |t|
# devise - database_authenticable, registerable
t.string "email", default: "", null: false
t.string "encrypted_password", default: "", null: false
# devise - recoverable
t.string "reset_passw... |
def input_students
puts "Please enter the names of the students and their details"
puts "To finish, just hit return twice"
# create an empty array
students = []
# gets the first name
name = gets.chomp
puts "Where was #{name} born?"
country_of_birth = gets.chomp
puts "What does #{name} like doing?"
h... |
# class Customer
# def initialize (bank_account,lastname="")
# @bank_account = bank_account
# @lastname = lastname
# end
# def set (firstname, street,city)
# @firstname = firstname
# @street = street
# @city = city
# # set_street(@street)
# # set_firstname(@firstname)
# # set_city(@city)
# end
... |
class FindFacility
prepend SimpleCommand
attr_reader :args
def initialize(args = {})
@args = args
end
def call
query_facility
end
private
def query_facility
facility = Facility.where(@args).first
if facility.nil?
errors.add :not_found, 'Record Not Found'
nil
else
... |
require 'phantom-static/config'
require 'phantom-static/builder'
require 'phantom-static/runner'
require 'json'
require 'open3'
require 'tempfile'
require 'active_support/all'
module PhantomStatic
def self.config
@config ||= Config.new
@config
end
def self.config=(val)
@config = val
end
def ... |
class UsersController < ApplicationController
before_filter :authenticate_user!
before_filter :survey_says, :only => [:show]
def new
redirect_to survey_path
end
def show
@user = User.find( params[:id] )
if @user = current_user
render :show
else
redirect_to root_path
end
end... |
require 'rails_helper'
describe 'shared/_navigation.html.haml' do
let(:cv) { create(:curriculum_vitae) }
before do
assign(:cv_url, cv.file.url)
render partial: 'shared/navigation'
end
it 'renders the website logo' do
expect(rendered).to match(/<a class="navbar-brand mattrayner-logo ir"/)
end
... |
# coding: utf-8
class Diary < ActiveRecord::Base
#my change point
validates_presence_of :title #title not null
validate :date_isvalid? #check diary date
private
def date_isvalid?
if date < (DateTime.now -1)
errors.add(:date, '1日以上前の日記を作成・修正することはできません。')
end
end
# end my change point
end... |
module Sumac
module Messages
# Representes a _Sumac_ +call_request+ message.
# @api private
class CallRequest < Message
# Build a new {CallRequest} message.
# @param id [Integer] the id of the call
# @param object [#origin#id] reference of object whose method is to be called
# @p... |
module RiotMongoMapper
class HasPluginAssertion < Riot::AssertionMacro
register :has_plugin
def evaluate(model, plugin)
assert = model.respond_to?(:plugins) ? model.plugins.include?(plugin) : model.class.plugins.include?(plugin)
if assert
pass("#{model} has plugin #{plugin.inspect}")
... |
class AddTaxonPropsToTaxons < ActiveRecord::Migration[5.2]
def change
add_column :spree_taxons, :taxon_props, :text
end
end
|
class RemovePositionColumnToLocations < ActiveRecord::Migration
def change
remove_column :locations, :position, :int
end
end
|
module Robbie
class Artist < BaseModel
attr_accessor :id, :name, :is_group, :genres, :albums
class << self
def search(q)
Parsers::Search.search(q).keep_if{ |item| item.instance_of?(Robbie::Artist) }
end
def find_by_name(name)
search(name).first
end
def find(id)... |
require 'spec_helper'
describe Susanoo::ServerSync::Worker do
describe "メソッド" do
subject { Susanoo::ServerSync::Worker.new }
let(:retry_interval) { Susanoo::ServerSync::Worker.retry_interval }
before do
allow(Settings.export).to receive(:sync_enable_file_path).and_return(__FILE__)
end
de... |
class OrderSerializer < ActiveModel::Serializer
attributes :id, :user_id, :total_points, :total_price, :completed
# has_many :order_items
# has_many :products, through: :order_items
end
|
require 'pry'
class Deck
RANKS = (2..10).to_a + %w(Jack Queen King Ace).freeze
SUITS = %w(Hearts Clubs Diamonds Spades).freeze
def initialize
reset
end
def reset
card_arr = RANKS.product(SUITS).shuffle
@deck = card_arr.map { |rank, suit| Card.new(rank, suit) }
end
def draw
reset if @d... |
#! /usr/bin/ruby
require 'optparse'
require 'ostruct'
require 'rbconfig'
require 'git-bro'
require 'git-bro/commands'
module GitBro
TARGET_OS = Config::CONFIG['target_os']
end
class GitBroApp
attr_reader :options
def initialize(arguments)
@valid_commands = ['serve']
@arguments = arguments
@options... |
#!/usr/bin/ruby
def parse_line(line)
address, code = line.split(":")
code = code.split('#')[0] #filter out comments
asm.strip!
hex.strip!
return hex, asm
end
|
require 'spec_helper'
describe 'nexus', :type => :class do
on_supported_os.each do |os, facts|
context "on #{os}" do
let(:facts) do
facts
end
let(:params) {
{
'version' => '3.6.0'
}
}
context 'no params set' do
let(:params) {{}}
i... |
class CreateCards < ActiveRecord::Migration
def change
create_table :cards do |t|
t.integer :game_id
t.string :name
t.string :card_type
t.string :front_img
t.string :back_img
t.integer :width
t.integer :height
t.float :default_z
t.text :shape
t.text :loc... |
class WritingsController < ApplicationController
before_action :logged_in_user, except: [:show, :index]
before_action :set_writing, only: [:show, :edit, :update, :destroy]
before_action :get_curatorial_years
before_action :get_writing_years
def new
@user = current_user
@writing = @user.writings.buil... |
class Building
attr_accessor :address, :style, :has_doorman, :is_walkup, :num_floors, :apartments
def initialize(address, style, has_doorman, is_walkup, num_floors)
@address = address
@style = style
@has_doorman = has_doorman
@is_walkup = is_walkup
@num_floors = num_floors
@apartments = {}
... |
class AddParentClusterToClusters < ActiveRecord::Migration
def change
add_column :clusters, :parent_cluster_id, :integer, :after => :user_id
end
end
|
require 'rspec/core/rake_task'
desc "Run an IRB session with Hutch pre-loaded"
task :console do
exec "irb -I lib -r hutch"
end
desc "Run the test suite"
RSpec::Core::RakeTask.new(:spec) do |t|
t.pattern = FileList['spec/**/*_spec.rb']
t.rspec_opts = %w(--color --format doc)
end
task default: :spec
#
# Re-gene... |
require 'spec_helper'
RSpec.describe Tuxedo::ActionView::Helpers do
let(:helper_class) { Struct.new(:helper) { include Tuxedo::ActionView::Helpers } }
let(:helper) { helper_class.new }
describe 'presenter_for' do
subject { helper.presenter_for(Dummy.new) }
context 'when providing instance' do
spec... |
module GHI
module Commands
class Help < Command
def self.execute args, message = nil
new(args).execute message
end
attr_accessor :command
def options
OptionParser.new do |opts|
opts.banner = 'usage: ghi help [--all] [--man|--web] <command>'
opts.separa... |
class LicensesController < ApplicationController
before_action :require_admin, except: [:new, :create, :show]
before_action :set_license, only: [:edit, :update, :show]
before_action :require_same_user, only: [:show]
def index
@licenses = License.all
@approved = License.where(approved: true).order("creat... |
class Address < ApplicationRecord
self.table_name = "address"
has_one :customer
accepts_nested_attributes_for :customer
belongs_to :city
scope :sorted, lambda { order("address ASC")}
validates :address, presence: true, length: { maximum: 50 }
validates :district, :phone, presence: true, length: { maximum: 2... |
source "https://rubygems.org"
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
ruby "2.4.5"
# Bundle edge Rails instead: gem "rails", github: "rails/rails"
# Gói đường ray cạnh thay thế: gem "rails", github: "rails / rails"
gem "rails", "~> 5.2.3"
# Use mysql as the database for Active Record
# Sử dụng... |
class CreateStockInfoChangeMails < ActiveRecord::Migration[5.0]
def change
create_table :stock_info_change_mails do |t|
t.string :user_id
t.string :stock_code
t.string :stock_name
t.integer :end_rate_mny
t.string :change_type
t.string :stock_message
t.date :target_date
... |
[PHYSICAL_FRONT, READ_AND_REACT, BLANKET_COVERAGE, TOUGHNESS].each do |chemistry|
ed_reed = PlayerCard.create do |card|
card.first_name = 'Ed'
card.last_name = 'Reed'
card.overall = 98
card.team_chemistry_id = Chemistry.by_team_city(:baltimore).first.id... |
module Cells
# Setup your special needs for Cells here. Use this to add new view paths.
#
# Example:
#
# Cells.setup do |config|
# config.append_view_path "app/view_models"
# end
#
def self.setup
yield(Cell::Rails)
end
end
require 'cell'
require 'cell/rails'
require 'cells/rails'
requir... |
class AddDefaultValueToQuantityInOrderedAmounts < ActiveRecord::Migration[6.0]
def change
change_column :ordered_amounts, :quantity, :float, :default => 0.00
end
end
|
require "spec_helper"
describe Puzzle do
describe "#full_name" do
let(:subject) { Puzzle.new(:name => "3x3x3") }
before do
subject.stub(:kind => kind)
end
context "no kind name available" do
let(:kind) { stub(:kind, :short_name => "") }
it "returns only '3x3x3'" do
expect... |
# Abstract class for batch-loading ActiveRecord records by key, with optional
# where + includes + references args
module GraphQLServer::BatchLoaders
class BaseRecordLoader < BaseLoader
def initialize(model, column: model.primary_key, scope: nil, where: nil, includes: nil, references: nil)
@model = model
... |
# copyright: 2015, Vulcano Security GmbH
require "shellwords"
class Lines
attr_reader :output
def initialize(raw, desc)
@output = raw
@desc = desc
end
def lines
output.split("\n").map(&:strip)
end
def to_s
@desc
end
end
class PostgresSession < Inspec.resou... |
require "rails_helper"
module UnsFeeder
RSpec.describe RiverBrowserController, type: :routing do
routes { UnsFeeder::Engine.routes }
describe "routing" do
it "routes to #show" do
expect(:get => "/river_browser/1").to route_to("uns_feeder/river_browser#show", :id => "1")
end
end
en... |
Puppet::Type.newtype(:nexus_access_privilege) do
@doc = "Manages Nexus Access Privileges through a REST API"
ensurable
newparam(:name, :namevar => true) do
desc 'Unique Privilege identifier; once created cannot be changed unless the Privilege is destroyed. Nexus UI will append method names to the end of thi... |
#
# Cookbook:: cloudwatch-logs
# Recipe:: default
if node['ec2'].nil?
log('Refusing to install CloudWatch Logs because this does not appear to be an EC2 instance.') { level :warn }
return
end
if node['cwlogs']['region'].nil?
log('AWS Region is necessary for this cookbook.') { level :error }
return
end
# Inst... |
class Project < ActiveRecord::Base
belongs_to :client
belongs_to :staff
has_many :posts
end
|
class PostTableIntoUtf8 < CamaManager.migration_class
def change
if table_exists? CamaleonCms::User.table_name
add_column(CamaleonCms::User.table_name, :email, :string) unless column_exists?(CamaleonCms::User.table_name, :email)
add_column(CamaleonCms::User.table_name, :username, :string) unless colum... |
class Bear
#attr_accessor's are the "getters" and "setters"
attr_accessor :name, :type, :tummy
def initialize(name, type)
#within class @ is available everywhere.
@name = name
@type = type
@tummy = []
end
def roar()
return "Rawr!"
end
def take_fish_from_river( river )
if river.fish_count ... |
class OwnersController < ApplicationController
before_filter :admin_user
def new
@supplier = Supplier.find(params[:supplier_id])
@machines_quantity_hash = @supplier.machines_quantity_hash
@machines = Machine.all.sort_by{ |m| [m.manufacturer,m.name] }
end
def create
supplier = Supplier.find(par... |
class Cuba
module TextHelpers
def markdown(str)
require "bluecloth"
BlueCloth.new(str).to_html
end
def truncate(str, length, ellipses = "...")
return str if !str || str.length <= length
sprintf("%.#{length}s#{ellipses}", str)
end
def nl2br(str)
str.to_s.gsub(/\n|\... |
# frozen_string_literal: true
require "spec_helper"
describe "Explore versions", versioning: true, type: :system do
include_context "with a component"
let(:component) { create(:opinion_component, organization: organization) }
let!(:opinion) { create(:opinion, body: "One liner body", component: component) }
le... |
class CreateArmors < ActiveRecord::Migration[5.0]
def change
create_table :armors do |t|
t.string "marca"
t.string "protecao"
t.date "fabricacao"
t.date "vencimento"
t.integer "capas"
t.string "genero"
t.string "tamanho"
t.string "modelo"
t.string "num_serie"
... |
require 'rake'
require 'rake/rdoctask'
task :default => :todo
desc "Show all TODO tasks from the source code to help with improvements of the project"
task :todo do
# gather todo items from source
@all_todos = Hash.new()
files = Dir["**/*.rb"]
files.each do |filename|
File.readlines(filename).each do |li... |
class ScrapeMediaAutocOne
def self.get(count = nil)
# オートックワンの「新型車」記事スクレイピング
media_category = MediaCategory.find_by(name: '新型車')
links = []
thumbs = []
next_url = "http://autoc-one.jp/launch/"
get_links_thumbs(links,next_url,count)
get_article(links,media_category)
end
private
def ... |
class AddLinkToDemos < ActiveRecord::Migration
def change
add_reference :demos, :link, index: true
add_reference :demos, :youtube_link, index: true
add_reference :demos, :html5_link, index: true
add_reference :demos, :source_link, index: true
end
end
|
feature 'Viewing peeps' do
scenario 'I can see exisiting peeps on the peeps page' do
Peep.create(peeps: 'this is a test', time: '22/10/15 10:59am')
visit '/peeps'
expect(page.status_code).to eq 200
within 'ul#peeps' do
expect(page).to have_content 'this is a test'
end
end
end
|
class ScriptSerializer < ActiveModel::Serializer
attributes :title, :cuid, :id, :editors
has_many :versions
def editors
object.editors.uniq.map do |editor|
EditorSerializer.new(editor)
end
end
end
|
FactoryGirl.define do
factory :client do
name "Maria"
phone "11 99999-9999"
address "Av. Paulista, 1200"
end
factory :invalid_client, class: Client do
name nil
phone "11 99999-9999"
address "Av. Paulista, 1200"
end
end
|
Incuba::Application.routes.draw do
resources :slides
resources :downloads
resources :grades
resources :topics
resources :articles
resources :categories
resources :contents
resources :notices
devise_for :members, controllers: {registrations: 'registrations'}
get '/members/sign_in' => 'members#sign... |
class DukeAPIJob < ApplicationJob
queue_as :default
def perform
Dam.destroy_all
Lake.destroy_all
DamReleasesAPIService.new.call
ArrivalRecessionsAPIService.new.call
LakeLevelsAPIService.new.call
end
end
|
class AddOperatorRefToPoints < ActiveRecord::Migration
def change
#dodanie powiazania
#rails g migration AddOperatorRefToPoints operator:references
#dodaje kolumne operator_id do Point z indexem _id
add_reference :points, :operator, index: true
end
end
|
# frozen_string_literal: true
module Mobile
module V0
module Adapters
# This class adapts Community Care appointments to a common schema that
# is shared with the VA appointment types.
#
# @example create a new instance and parse incoming data
# Mobile::V0::Adapters::CommunityCare... |
# BasicEnemy.rb
#
# Copyright 2015 Kmar <kmar@kmar-Kubuntu>
#
# 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 version 2 of the License, or
# (at your option) any later version.
... |
# Helper function to pluck array into hash
class Array
def pluck_to_hash(keys)
pluck(*keys).map { |pa| Hash[keys.zip(pa)] }
end
end
# Convert string into BSON::ObjectId
class String
def to_bson_id
BSON::ObjectId.from_string(self)
end
end
class NilClass
def to_bson_id
self
end
end
# When call ... |
# frozen_string_literal: true
SC::Billing.configure do |config| # rubocop:disable Metrics/BlockLength
config.stripe_api_key = ENV.fetch('STRIPE_API_KEY')
config.stripe_webhook_secret = ENV.fetch('STRIPE_WEBHOOK_SECRET')
config.user_model_name = 'User'
config.registration_source[:follow?] = true
config.regis... |
class TargetMuscleGroupsController < ApplicationController
# GET /target_muscle_groups
# GET /target_muscle_groups.xml
def index
@target_muscle_groups = TargetMuscleGroup.all
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @target_muscle_groups }
end
end... |
class API::PostsController < API::ApplicationController
before_action :authenticate_user_from_token!
def index
@posts = current_user.posts
render json: @posts
end
def create
@post = current_user.posts.build(post_params)
if @post.save
render json: @post, status: :created
else
... |
Rails.application.routes.draw do
resources :labels
resources :rates
resources :shipper_accounts
root to: 'shipper_accounts#index'
end
|
class Contest < ActiveRecord::Base
belongs_to :user
has_many :participants
has_many :users, through: :participants
has_many :problem_in_contests
has_many :problem, through: :problem_in_contests
validates :contestName, presence: true, uniqueness: {scope: :startDateTime, message: "Another contest of same name... |
require 'ship'
require 'board'
describe 'Features' do
let(:board) { Board.new }
let(:ship) { Ship.new(1) }
describe 'Board' do
describe '#place' do
it { expect(board).to respond_to(:place).with(3).argument }
it 'ships on the board' do
board.place(ship, "A", 1)
expect(board.ga... |
class CreateStickers < ActiveRecord::Migration[6.1]
def change
create_table :stickers do |t|
t.string :img_id
t.integer :xpos
t.integer :ypos
t.datetime :created_at, precision: 6, null: false
t.datetime :updated_at, precision: 6, null: false
t.string :url
end
end
end
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.