text stringlengths 10 2.61M |
|---|
class HostnameQuery
def initialize(options = {})
@including = options.fetch(:including, nil).to_s.split(',').map(&:strip)
@excluding = options.fetch(:excluding, nil).to_s.split(',').map(&:strip)
@page = options.fetch(:page, 1)
end
def call
#hostnames = Hostname.find_by_sql([sql_script])
hostn... |
class Company < ActiveRecord::Base
attr_accessor :coe,:ece,:ice,:it,:mpae,:bt,:is,:pc,:sp
before_save :combine_branches # or choose other callback type respectively
def combine_branches
self.branchesAllowed = ""
if coe=="COE"
self.branchesAllowed += "COE"
end
if ece=="ECE"
... |
class UserRating < ActiveRecord::Base
belongs_to :user
belongs_to :movie
after_save :calculate_average
def calculate_average
movie.update_attributes(average: movie.user_ratings.average(:rating))
end
end |
require 'sqlite3'
require 'singleton'
require_relative 'user'
require_relative 'reply'
require_relative 'question_follow'
require_relative 'question_like'
class QuestionsDatabase < SQLite3::Database
include Singleton
def initialize
super('questions.db')
self.type_translation = true
self.results_as_has... |
# controller
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
before_action :configure_permitted_parameters, if: :devise_controller?
protected
def configure_permitted_parameters
devise_parameter_sanitizer.permit(:sign_up,
keys: [
:first_name,
... |
class MessageRecipient < ActiveRecord::Base
belongs_to :message
belongs_to :messagable, :polymorphic => true
validates_presence_of :messagable_id, :messagable_type, :protocol
validates_uniqueness_of :message_id, :scope => [:messagable_id, :messagable_type]
after_destroy ... |
#
# Cookbook Name:: simple-python-app
# Recipe:: default
#
# Copyright (c) 2016 The Authors, All Rights Reserved.
appdir = node['simple-python-app']['app']['install_dir']
venvdir = "#{appdir}/venv"
appuser = node['simple-python-app']['app']['user']
appgroup = node['simple-python-app']['app']['group']
group appgroup
us... |
class Formulario < ActiveRecord::Base
validates :derecho, :presence=>true
validates :title, :presence=>true
has_many :accions
belongs_to :derecho
end
|
require 'authenticate'
require 'rails'
module Authenticate
#
# Authenticate Rails engine.
# Filter password, token, from spewing out.
#
class Engine < ::Rails::Engine
initializer 'authenticate.filter' do |app|
app.config.filter_parameters += [:password, :token]
end
config.generators do |g|... |
# frozen_string_literal: true
require 'test_helper'
class Admin::TicketsControllerTest < ActionDispatch::IntegrationTest
setup do
@admin_ticket = admin_tickets(:one)
end
test 'should get index' do
get admin_tickets_url
assert_response :success
end
test 'should get new' do
get new_admin_tic... |
# encoding: utf-8
require 'cases/sqlserver_helper'
require 'models/event'
class Event < ActiveRecord::Base
before_validation :strip_mb_chars_for_sqlserver
protected
def strip_mb_chars_for_sqlserver
self.title = title.mb_chars.to(4).to_s if title && title.is_utf8?
end
end
class UniquenessValidationTestSqls... |
class CategoriesController < ApplicationController
def index
@categories = Category.all
end
def new
@category = Category.new
end
def create
@category = Category.new(category_params)
if @category.save
flash[:notice] = "You created a new category!"
redirect_to categories_path
... |
class FaxDocumentsController < ApplicationController
load_and_authorize_resource :fax_account
load_and_authorize_resource :fax_document, :through => [:fax_account]
before_filter :spread_breadcrumbs
def index
@fax_documents = @fax_documents.order(:created_at).reverse_order
end
def show
respond... |
class ReportsController < ApplicationController
before_action :set_report, only: [:edit, :update, :destroy]
before_action :authenticate_user!, only: [:edit, :update, :destroy, :new, :create]
before_action :check_profile
before_action do
if !user_signed_in? && !tutor_signed_in?
flash[:notice] = 'ログインし... |
require_relative 'configuration/validatable'
require_relative 'configuration/queue_configuration'
require_relative 'configuration/redrive_policy_configuration'
module Ehonda
class Configuration
include Validatable
def initialize
@queues = {}
@queue_defaults = QueueConfiguration.new 'queue_defaul... |
class Restaurant
attr_accessor :name
@@all = []
def initialize(name)
@name = name
@reviews = []
@@all << self
end
def add_review(review)
@reviews<<review
end
def self.all
@@all
end
def self.find_by_name(name)
self.all.detect{|restaurant| restaurant.name == name }
end
... |
class Video < ApplicationRecord
include Name, Publishable, Slug
def path
"/videos/#{slug}"
end
def content_rendered
Kramdown::Document.new(
content,
input: content_format == "html" ? :html : :kramdown,
remove_block_html_tags: false,
transliterated_header_ids: true,
html_t... |
class Gst::Pipeline < Gst::Element
def initialize(name)
self.java_element = JavaGst::Pipeline.new(name)
end
def add(*elements)
java_elements = elements.collect { |element| element.java_element }
java_elements = java_elements.to_java(:java.org.gstreamer::Element)
java_element.add_many(java_el... |
class AddBicycleFootToTrails < ActiveRecord::Migration[5.0]
def change
add_column :trails, :bicycle, :boolean
add_column :trails, :foot, :boolean
end
end
|
require 'spec_helper'
module Stats
describe Math do
it "performs basic sums" do
numbers = [1, 2, 3]
Math.sum(numbers).should == 6
end
it "integrates linear functions" do
identity = lambda {|x| x }
Math.integrate(0..1, &identity).should == 0.5
end
it "integrates quadratic... |
require 'mysql'
require 'mysql2'
class MySQLHealthcheck
def self.connect
Mysql.connect(host='localhost', user="root", password='root')
end
def self.connectv2
Mysql2::Client.new(host: 'localhost', username: "root", password: 'root')
end
def self.status_check(client = nil)
client ||= self.connec... |
# frozen_string_literal: true
require 'stannum/constraints/hashes/indifferent_key'
require 'support/examples/constraint_examples'
RSpec.describe Stannum::Constraints::Hashes::IndifferentKey do
include Spec::Support::Examples::ConstraintExamples
subject(:constraint) { described_class.new(**constructor_options) }... |
# frozen_string_literal: true
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
before_action :authenticate_user!
before_action :configure_permitted_parameters, if: :devise_controller?
protected
def configure_permitted_parameters #allowing devise to accept type attr... |
class ImportPresenter < Presenter
delegate :created_at, :to_table, :target_dataset_id, :source_dataset_id, :to => :model
def to_hash
{
:execution_info => {
:to_table => to_table,
:to_table_id => target_dataset_id,
:started_stamp => created_at,
:completed_stamp =>... |
namespace :pages do
desc "Generate pages: Faq, Products, Contact, About and Checkout"
task :generate_pages => :environment do
puts "== Generating Pages \n"
Page.where(name: "About").first_or_create(name:"About",title:"About",body:"Content for about page")
Page.where(name: "Product").first_or_create(name... |
FactoryGirl.define do
factory :referral_contact do
open_lead false
reminder_count 1
phone_number "MyString"
user nil
end
end
|
class CreateIngredientsRecipesTable < ActiveRecord::Migration
def up
create_table :ingredients_recipes, id: false do |t|
t.integer :ingredient_id
t.integer :recipe_id
end
end
end
|
json.array!(@hairdevices) do |hairdevice|
json.extract! hairdevice, :id
json.url hairdevice_url(hairdevice, format: :json)
end
|
# Read about factories at https://github.com/thoughtbot/factory_girl
FactoryGirl.define do
factory :touch do
user nil
item nil
reaction_type "MyString"
reaction_id 1
end
end
|
class EventsController < ApplicationController
before_action :set_event, only: [:show, :update, :destroy]
before_action :check_password!, only: [:update, :destroy]
def show
render json: @event.as_json.merge({ participants: @event.participants })
end
def create
@event = Event.new(event_params)
sa... |
class SimpleSums
def initialize( number )
@number = number
end
def number
@number
end
def s1
@number % 2
end
def s2
sum_s2 = 0
@number.times do |num|
sum_s2 += num + 1
end
sum_s2
end
end
sum = SimpleSums.new(4)
p.sum.number |
require 'rails_helper'
RSpec.describe Student, type: :model do
# write your student model here
describe 'attributes' do
# it 'has a name' do
# end
# it 'has student_number' do
# end
# it 'has GPA' do
# end
#checks that the cloumn exists in the database?
it{ should respond_to... |
require "./lib/minitest/should_syntax/version"
Gem::Specification.new do |s|
s.name = "minitest-should_syntax"
s.version = MiniTest::ShouldSyntax.version
s.summary = "RSpec-like syntax for MiniTest."
s.description = "Lets you use a syntax similar to RSpec on your MiniTest tests."
s.authors = ["Rico Sta. Cruz"... |
require 'spec_helper'
describe Spree::EmailSenderController do
let(:product) { create(:product) }
before { controller.stub spree_current_user: nil }
it 'use EmailSenderController' do
expect(controller).to be_an_instance_of(Spree::EmailSenderController)
end
context '#send_mail' do
# can be differen... |
# frozen_string_literal: true
module Delegable
extend ActiveSupport::Concern
included do
scope :delegated, -> (user_id) { where('stewardships.user_id = ? OR organizations.created_by = ?', user_id, user_id) }
end
def owner_id
organization.created_by
end
end
|
module MAILAPI
#
# Class that helps to connect to the Mail API.
#
class Call
API_URL = (ENV["MAILAPI_URL"] ? ENV["MAILAPI_URL"] : MAILAPI::ENDPOINT)
# Point our client to the API end point.
#
def initialize(apikey)
@apikey = apikey
@server = XMLRPC::Client.new2(API_URL)
@se... |
# metaprogramming to the rescue!
#a
class Numeric
@@currencies = {'yen' => 0.013, 'euro' => 1.292, 'rupee' => 0.019, 'dollar' => 1}
def method_missing(method_id)
singular_currency = nomalizeCurrency method_id
if @@currencies.has_key?(singular_currency)
self * @@currencies[singular_currency]
else
... |
# added in release 1.5.8
module GroupDocs
class Document::Annotation::MarkerPosition< Api::Entity
#
# example
# marker = GroupDocs::Document::Annotation::MarkerPosition.new()
# marker.position = {:x => 100, :y => 100}
# marker.page = 1
# @attr [Array](x,y) position
attr_access... |
require 'test_helper'
class SobresControllerTest < ActionController::TestCase
setup do
@sobre = sobres(:one)
end
test "should get index" do
get :index
assert_response :success
assert_not_nil assigns(:sobres)
end
test "should get new" do
get :new
assert_response :success
end
tes... |
class AddFormatRefToStories < ActiveRecord::Migration
def change
add_reference :stories, :format, index: true
end
end
|
CarrierWave.configure do |config|
config.cache_dir = File.join(Rails.root, 'tmp', 'uploads')
config.storage = :fog
config.fog_credentials = {
:provider => 'AWS',
:aws_access_key_id => ENV['AWS_ACCESS_KEY_ID'],
:aws_secret_access_key => ENV['AWS_SECRET_ACCESS_KEY']
}
case Rail... |
module Notification
class Scale < Base
def body
"#{actor} scaled #{data['type']} to #{data['quantity']}:#{data['size']}"
end
end
end
|
# 合并 k 个排序链表,返回合并后的排序链表。请分析和描述算法的复杂度。
#
# 示例:
#
# 输入:
# [
# 1->4->5,
# 1->3->4,
# 2->6
# ]
# 输出: 1->1->2->3->4->4->5->6
# Definition for singly-linked list.
# class ListNode
# attr_accessor :val, :next
# def initialize(val)
# @val = val
# @next = nil
# end
# end
class ListNode
att... |
class Tag < ActiveRecord::Base
has_and_belongs_to_many :bookmarks
belongs_to :user
validates :name, presence: true
end
|
class Journey < ApplicationRecord
belongs_to :user
has_many :starting_points, class_name: 'StartingPoint'
has_many :destinations, class_name: 'Destination'
end
|
require 'spec_helper'
describe Tassadar::MPQ::MPQ do
let(:mpq) { Tassadar::MPQ::MPQ.read(File.read(File.join(REPLAY_DIR, 'patch150.SC2Replay'))) }
it "reads the user data size" do
expect(mpq.user_data_length).to eq(60)
end
it "has block_table entries" do
expect(mpq.block_table.blocks.size).to eq(10)
... |
class AddUserIdToAirloge < ActiveRecord::Migration[5.2]
def change
add_column :airloges, :user_id, :string
end
end
|
module DetectOrCreate
module ClassMethods
# Finds or creates an object, based on parameters provided
#
# @param args [Hash] Parameters to detect or create
# @option args [Hash] :by The parameters to use when finding a record
# @option args [Hash] :with The parameters to use to update or create th... |
ActiveAdmin.register Comment, :as => "PhotoComment" do
permit_params :photo_id, :content, :user_id
index do
selectable_column
column :id
column :photo
column "Album" do |comment|
comment.photo.album
end
column :user
column :created_at
column :updated_at
actions
end
end |
class RenameAddress < ActiveRecord::Migration
def change
rename_column :buildings, :address, :postalcode
end
end
|
class AnswersController < ApplicationController
def index
if params[:user_id]
@answers = Answer.where(user_id: params[:user_id])
else
@answers = Answer.all
end
end
def new
@answer = Answer.new(question_id: params[:question_id])
@question = @answer.question
end
def edit
@... |
require 'rails_helper'
feature "logout" do
before(:each) do
visit 'users/new'
fill_in "user_username", with: "Bobby Gilmore"
click_button "Sign In"
expect(current_path).to eq('/messages')
expect(page).to have_content "Post a Message"
end
scenario "logout succeeds" do
visit '/messages'
... |
require 'test_helper'
class DoExercisesControllerTest < ActionController::TestCase
setup do
@do_exercise = do_exercises(:one)
end
test "should get index" do
get :index
assert_response :success
assert_not_nil assigns(:do_exercises)
end
test "should get new" do
get :new
assert_respons... |
require 'rails_helper'
RSpec.describe 'On a Pet Applications show page a user', type: :feature do
it 'can see application info' do
user1 = User.create!(name: 'Dr. Evil',
address: '56774 FLower Ave.',
city: 'Smallville',
state: 'Alaska'... |
require "spec_helper"
describe I18nAccessors::Methods do
let(:base_model_class) do
Class.new do
def title(**_); end
def title?(**_); end
def title=(_value, **_); end
end
end
context "locales unset, uses I18n.available_locales" do
before do
@available_locales = I18n.available_... |
require "first_gem_anna/version"
# this adds functionality to the existing ruby String class
class String
def word_count
self.split.count
end
def unique_words
self.split.uniq
end
end
|
#require './perfil'
require_relative './blog'
#Clase que define un usuario de nuestros Blogs
class Usuario
attr_accessor :cuenta,:email,:perfil,:blogs
def initialize cuenta,email
@cuenta = cuenta
@email = email
end
def blog(id)
index = @blogs.index do |b|
b.id == id
end
blog = index.nil? ? nil : blogs[i... |
#==============================================================================
# ** Game_Event
#------------------------------------------------------------------------------
# This class handles events. Functions include event page switching via
# condition determinants and running parallel process events. Used with... |
FactoryGirl.define do
factory :title_type do
factory :official_type do
title_type_id 1
title_type "official"
end
factory :short_type do
title_type_id 2
title_type "short"
end
factory :popular_type do
title_type_id 3
title_type "popular"
end
end
end
|
# invites_controller_spec.rb
require 'rails_helper'
require 'spec_helper'
describe InvitesController do
describe "GET #new" do
# it "assigns a new Invite to @invite" do
# assigns(:invite).should eq(Invite.new)
# end
it "renders the :new view" do
get :new
expect(response).to render_templ... |
require 'spec_helper'
describe Spree::Upload do
before(:each) do
Spree::Upload.destroy_all
#puts File.expand_path("../../support/files/*.jpg", __FILE__)
@jpgs = Dir[File.expand_path("../../support/files/*.jpg", __FILE__)]
@pngs = Dir[File.expand_path("../../support/files/*.png", __FILE__)]
@gifs = ... |
class MultiLogger
attr_reader :loggers
def initialize(*args)
@loggers = args
end
def level=(level)
@loggers.each { |logger| logger.level = level }
end
def levels
@loggers.map(&:level)
end
def min_level
levels.min
end
def close
@loggers.map(&:close)
end
def add(level, *a... |
class CreatePublicationArticles < ActiveRecord::Migration[5.0]
def change
create_table :publication_articles do |t|
t.integer :publication
t.integer :article
t.string :status
t.boolean :active
t.integer :sequence
t.timestamps
end
end
end
|
class Publisher < ActiveRecord::Base
has_many :applications
validates :name, :presence => true
validates :address, :presence => true
# def applications
# Application.order('name ASC')
# end
end
|
# frozen_string_literal: true
module Comments
# Service to create a article
class CreateService
def initialize(request_params, comment_create_params, user)
@resource = request_params[1]
@id = request_params[2]
@comment_create_params = comment_create_params
@user = user
@comment = ... |
class AddCovid19RelatedToActivity < ActiveRecord::Migration[6.0]
def change
add_column :activities, :covid19_related, :integer, default: 0
end
end
|
FactoryGirl.define do
factory :spending_info, aliases: [:spending] do
person { SampleDataMacros::Generator.person }
has_business 'no_business'
credit_score do
min = CreditScore.min
max = CreditScore.max
min + rand(max - min)
end
end
end
|
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
before_action :authenticate_user!
before_action :initialize_pages_layout
def initialize_pages_layout
@navbar_categories = Category.all
end
end
|
# frozen_string_literal: true
require 'open-uri'
require 'nokogiri'
# Scrapes HTML of Square account that User inputs
# Square API recently changed, creating temp solution
# class Scraper < ApplicationRecord
# def self.scrape_square(merchant)
# doc = Nokogiri::HTML(open(merchant.links.last.url))
# img =... |
class Attendance < ApplicationRecord
after_create :new_participant_send
belongs_to :event
belongs_to :participant, class_name: "User"
def new_participant_send
UserMailer.new_participant(self).deliver_now
end
end
|
class Resource < ActiveRecord::Base
validates_presence_of :name
has_many :company_providers, :as => :provider, :dependent => :destroy
has_many :companies, :through => :company_providers, :source => :company
# Appointments associations
# TODO - what happens when the re... |
require 'wsdl_mapper/naming/default_namer'
module WsdlMapper
module Naming
# Namer implementation which puts the generated classes into different namespaces,
# according to their funtion: `Types` for types, `S8r` for serializers and `D10r`
# for deserializers.
class SeparatingNamer < DefaultNamer
... |
APP_ENV = 'test'
require File.expand_path(File.dirname(__FILE__) + "/../config/app")
require 'rack/test'
require 'database_cleaner'
RSpec.configure do |config|
config.treat_symbols_as_metadata_keys_with_true_values = true
config.run_all_when_everything_filtered = true
config.filter_run :focus
# Run specs in... |
class Build < Place
validates_presence_of :name
def self.icon
"home"
end
end
|
#
# Cookbook Name:: cubrid
# Attributes:: perl_driver
#
# Copyright 2012, Esen Sagynov <kadishmal@gmail.com>
#
# Distributed under MIT license
#
# Latest build numbers for each CUBRID Perl version in the form of 'version'=>'build_number'.
build_numbers = {'9.1.0' => '0002', '9.0.0' => '0001', '8.4.3' => '0001', '8.4.1... |
require 'rails_helper'
RSpec.describe ApplicationHelper, type: :helper do
describe "#mobile_device?" do
context "when mobile device" do
it "returns not nil" do
controller.request.user_agent = "Mobile/1.0"
expect(helper.mobile_device?).to_not be_nil
end
end
context "when deskt... |
#####################################################################
# tc_file.rb
#
# Test case for the Windows::File module.
#####################################################################
base = File.basename(Dir.pwd)
if base == 'test' || base =~ /windows-pr/
Dir.chdir '..' if base == 'test'
$LOA... |
RSpec.describe Batch::DailyBatch do
let (:config) { AppUtil.load_config }
subject (:batch) { Batch::DailyBatch.new(config) }
let (:stub_now) do
allow(AppUtil).to receive(:get_now) do
current_at.nil? ? Time.now : Time.parse(current_at)
end
end
let (:actual) do
get_actual.map { |row| row.se... |
class SeminarsController < ApplicationController
def new
@subject = Subject.find(params[:subject_id])
teacher_ids = Seminar.where(subject: @subject).pluck(:teacher_id)
@teachers = Teacher.where.not(id: teacher_ids).and(Teacher.where(approved: true))
@seminar = authorize Seminar.new
end
def creat... |
module One
class CreateUser < Operation
def process(_params)
add_user_to_group unless user_already_member_of_group?
add_user_as_group_admin if become_group_admin? && !user_already_admin_of_group?
end
private
def invite
@params.fetch(:invite)
end
def one_user
@one_use... |
# Write your code here.
katz_deli = []
def line(customers)
output = ""
if customers.empty? == false
output = "The line is currently:"
customers.each.with_index(1) do |person, index|
output << " #{index}. #{person}"
end
elsif customers.empty? == true
output = "The line is currently empty."
... |
$:.unshift(File.dirname(__FILE__) + '/lib')
require 'omnibus/version'
Gem::Specification.new do |s|
s.name = 'omnibus'
s.version = Omnibus::VERSION
s.platform = Gem::Platform::RUBY
s.has_rdoc = true
s.extra_rdoc_files = ["README.md" ]
s.summary = "Installer builder DSL"
s.description = s.summary
s.auth... |
#
# Copyright 2009 Huygens Instituut for the History of the Netherlands, Den Haag, The Netherlands.
#
# This file is part of New Women Writers.
#
# New Women Writers 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 Foundat... |
<<-doc
Write a program interactively, through the command line
Enter a blank line to evaluate.
Enter 'q' to quit.
doc
puts "You can write your program here"
puts "Enter a blank line to evaluate."
puts "Enter 'q' to quit."
program = ""
line = ""
loop do
print "--> "
line = gets
case line.strip
when ""
eval... |
require 'capybara/dsl'
class EventsPage
include Capybara::DSL
BUTTON = '.button'
LONDON_STUDENTS = '#london-students'
def visit_events_page
visit("/events")
end
def events_page_content
page.find(:css, '.events-index')
end
def list_events
page.find(:css, '.event')
page.find(:id, 'min... |
Vagrant.configure('2') do |config|
config.vm.box = 'ubuntu/trusty64'
config.vm.provider 'virtualbox' do |v|
v.memory = 2048
v.cpus = 1
end
config.vm.provision 'shell', inline: <<-eos
# install ruby2.0
apt-get -y install build-essential git python-software-properties;
apt-add-repos... |
json.array!(@posicos) do |posico|
json.extract! posico, :id, :nome, :tipo, :description
json.url posico_url(posico, format: :json)
end
|
# In the below exercises, write code that achieves
# the desired result. To check your work, run this
# file by entering the following command in your terminal:
# `ruby day_2/exercises/iteration.rb`
# Example: Write code that iterates through a list of animals
# and print each animal:
animals = ["Zebra", "Giraffe", "E... |
require "spec_helper"
describe ShowDefinitionPowerup do
let(:player) { Player.new }
let(:answer) { Answer.new("Batman") }
let(:game) { Game.new(player, answer) }
it "adds definition of word to game" do
end
it "costs 25% of final score to use" do
answer.stub(find_definition: "Testing Avengers")
g... |
class Vor < ActiveRecord::Base
# attr_accessor :elevation, :frq, :identifier, :lat, :lon, :name, :range, :slaved
belongs_to :user
before_save { |vor| vor.identifier = identifier.upcase }
validates :lat, presence: true, numericality: { greater_than_or_equal_to: -90, less_than_or_equal_to: 90 }
validates :lon,... |
module ApplicationHelper
# Authentication
def current_user
if session.has_key?(:user_id) and ( @current_user.nil? or (session[:user_id] != @current_user.id))
@current_user = User.find_by_id(session[:user_id])
end
@current_user
end
def set_return_redirect(meta = {})
if session[:redirec... |
class DNA
def initialize(file)
#read every line in the file
@dna = IO.readlines(file)
#get individual sizes
@sizes = @dna[0].split
#convert sizes into an integer
@sizes.each_index do |i|
@sizes[i] = @sizes[i].to_i
end
@dna = @dna[1, num_lines]
@dna.each_index d... |
class PeoplesController < ApplicationController
def new
@people = People.new
end
def create
@people = People.new(params[:people])
if @people.save
redirect_to :action => :show, :id => @people.id
else
render 'new'
end
end
def show
@people = People.find(params[:id])
end
def index
... |
class ProductsController < ApplicationController
before_action :set_product, except: [:index, :new, :create, :update, :order, :pay, :complete, :search]
def index
@products = Product.includes(:images).order('created_at DESC')
end
def new
@product = Product.new
@product.images.new
end
def cre... |
# ==============================================================================
# Required settings
# ==============================================================================
set :application, "mygreatapp.com"
set :repository, "ssh://mygitrepo.com/home/git/repos/mygreatapp.com"
set :deploy_to, "/var/www/#{appli... |
class MemberStatsController < ApplicationController
before_action :set_member_stat, only: [:show, :edit, :update, :destroy]
respond_to :html
def index
@member_stats = MemberStat.all
respond_with(@member_stats)
end
def show
respond_with(@member_stat)
end
def new
@member_stat = MemberSta... |
describe "Float#arg", ->
xdescribe 'ruby_bug "#1715", "1.8.6.369"', ->
it "returns NaN if NaN", ->
f = R.Float.NAN
expect(R(f).arg().nan() ).toEqual true
describe 'ruby_version_is "1.9"', ->
it "returns self if NaN", ->
f = R(R.Float.NAN)
expect(f.arg() == f).toEqual true
it "ret... |
# frozen_string_literal: true
module Quilt
VERSION = "3.5.1"
end
|
class Company < ApplicationRecord
has_many :jobs
has_secure_password
validates(:name, presence: true, uniqueness: true)
validates(:password, presence: true)
end
|
class PostHashtag < ApplicationRecord
belongs_to :post
belongs_to :hashtag
validates :post_id, presence: true
validates :hashtag_id, presence: true
end
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.