text stringlengths 10 2.61M |
|---|
class SchedulesController < ApplicationController
before_action :find_truck
skip_after_action :verify_authorized
def new
@schedule = Schedule.new
end
def create
@schedule = Schedule.new(schedule_params)
@schedule.truck = @truck
existing_schedule = @truck.schedules.find {|schedule| schedule.d... |
class SessionsController < ApplicationController
# GET /login
def new
flash.now.alert = warden.message if warden.message.present?
end
# POST /login
def create
warden.authenticate!
redirect_to root_url
end
# GET /logout
def destroy
warden.user #this is a bug in warden; https://githu... |
FactoryBot.define do
factory :school do
name { "#{FFaker::NameMX.first_name} School" }
end
end
|
class PagesController < ApplicationController
skip_before_filter :authenticate_user!
before_filter :ADMIN!, :only => :deleteQuestion
@@categories = ["Politics", "Philosophy", "Entertainment", "Business", "Social Justice", "Education", "Science", "Tutoring", "Sports", "Miscellaneous"]
def home
@title = "Vid... |
class Api::V1::CommentsController < ApplicationController
def index
comments = Comment.all.sort_by {|comment| comment.created_at}
render json: comments
end
def create
comment = Comment.create!(com_params)
render json: comment
end
def update
comment... |
require 'test_helper'
class StationsControllerTest < ActionDispatch::IntegrationTest
test 'find round trips' do
test_cases = [
{ origin: 'C', destination: 'C', maximum: 3, type: 'max_stops', answer: 2, status: 200 },
{ origin: 'A', destination: 'C', maximum: 4, type: 'exact_stops', answer: 3, statu... |
describe Models::Keyboard, type: :model do
it { is_expected.to belong_to(:user) }
end
|
class WinesController < ApplicationController
def new
@dish = Dish.find(params[:dish_id])
@wine = Wine.new
end
def create
@wine = Wine.new(wine_params)
@dish = Dish.find(params[:dish_id])
@wine.dish = @dish
@wine.save
redirect_to restaurant_path(@dish.restaurants.first)
end
priv... |
require 'rails_helper'
RSpec.describe "Root endpoint", type: :request do
describe "GET /" do
before { get root_path }
let(:json_body) { JSON.parse(response.body).with_indifferent_access }
it "uses JSON API content type" do
expected = "application/vnd.api+json; charset=utf-8"
content_type = r... |
# frozen_string_literal: true
require 'bolt_setup_helper'
test_name "Configure Windows Profile" do
extend Acceptance::BoltSetupHelper
step "Configure a Windows Profile that contains will write to a file every time it is loaded" do
if bolt['platform'] =~ /windows/
execute_powershell_script_on(bolt, <<-P... |
RSpec.describe DotenvSecrets do
it "has a version number" do
expect(DotenvSecrets::VERSION).not_to be nil
end
describe "#[]" do
let(:path) { File.join(File.dirname(__FILE__), "secrets.env") }
subject(:secrets) { DotenvSecrets.new(path: path) }
context "looking for a key that is in the file" do
... |
Pi=3.14
puts Pi
# 代入された値が表示される
# 変数との違い:値を書き換えることができない
Pi=100
puts Pi
# 上記に続いて実行するとエラーが出力される
# 原則warning=正しくないという意味
# !!!書き換えが必要な場合は変数を使用!!!
# 今回のエラー内容
# constant.rb:5: warning: already initialized constant Pi
# 意味:既に定義された定数が使用
# onstant.rb:1: warning: previous definition of Pi was here
# これより前にPiが定義されているのは1行目となる |
# Utility class for the entity design in this project
# Nothing more than an extended container
# TODO: Replace this at some point with a hash-structure
# TODO: Generalize this for other applications
module SDC
class SpecialContainer
def initialize
@values = []
end
def add(element, index = nil)
if ind... |
class Categorium < ApplicationRecord
has_attached_file :imagen, styles: {large: "600x600>", medium: "300x300>", thumb: "100x100>"}, validate_media_type: false
validates_attachment_content_type :imagen, content_type: /\Aimage\/.*\z/
def imagen_url_medium
imagen.url(:medium)
end
def imagen_url_th... |
require 'yaml'
require 'fileutils'
require 'shellwords'
module Cloudpad
class Cloud
def initialize(env)
@env = env
@nodes = []
@containers = []
end
def nodes
@nodes
end
def hosts
@nodes.select {|n| n.has_role?(:host)}
end
def containers
@containers... |
source 'https://rubygems.org'
group :development, :test, :production do
gem 'rails', '4.1.8'
gem 'sqlite3'
gem 'sass-rails', '~> 4.0.3' # Use SCSS for stylesheets
gem 'uglifier', '>= 1.3.0' # Use Uglifier as compressor for JavaScript assets
gem 'jquery-rails' # Use jquery as the Ja... |
# 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 'spec_helper'
describe "VisitPages" do
describe "VisitPagesFromGuest" do
it "visit main page from guest" do
#user = FactoryGirl.create(:user)
visit main_index_path
current_path.should eq(main_index_path)
end
it "visit account page from guest" do
visit accounts_path
... |
default['textexpander']['appname'] = 'TextExpander.app'
if node['platform_version'].split('.')[1].to_i == 6
default['textexpander']['version'] = '3.4.2'
default['textexpander']['checksum'] = '87859d7efcbfe479e7b78686d4d3f9be9983b2c7d68a6122acea10d4efbb1bfa'
elsif node['platform_version'].split('.')[1].to_i > 6
d... |
class AddColumnToMessages < ActiveRecord::Migration
def change
add_column :messages, :author_id, :integer
add_column :messages, :user_read, :integer
add_column :messages, :admin_read, :integer
end
end
|
class FeedController < ApplicationController
def show
@post = Post.new
@posts = FeedPostFetcher.new(current_user: current_user).run
end
end
|
require 'net/http'
require 'json'
# we need to call BigOvenService.new() as an instance of this service object upon a get request
# being received by the rails api.
# An instance variable of the service should be able to take in the input data created by the
# post request to API from React front end --> database entr... |
class IndirizzimacsController < ApplicationController
before_action :logged_in_employee, only: [:create, :destroy]
before_action :correct_employee, only: [:destroy,:update]
def create
@indirizzimac = current_employee.indirizzimacs.build(indirizzimac_params)
if @indirizzimac.save
flash[:success]... |
require 'spec_helper'
describe Person do
before(:each) do
@attr = { :firstname => "John", :lastname => "Doe", :position => Person::POSITIONS.values.last,
:birth_date => "02/10/1978", :nationality => "USA",
:birth_city => "Austin", :birth_nation => "USA", :height => 20, :created_by_id => 1, :updated_by_id... |
class MarkdownHint
def self.example
%Q{
###### Headers
```
# This is an <h1> tag
## This is an <h2> tag
###### This is an <h6> tag
```
###### Text styles
```
*this text is italic*
_this text is italic too_
**this is bold text**
__this is bold text too__
```
###### Links
```
[Link Text](http://example.com/link-h... |
class Checkout
def initialize(promotional_rules)
@promotional_rules = promotional_rules
@basket = []
end
def promotional_rules
@promotional_rules
end
def scan(item)
@basket.push(item)
end
def basket
@basket
end
def total
# Clone the basket so we don't alter it whenever we run the total method.
... |
module Roark
module Aws
module Ec2
class AmiState
def initialize(connection)
@connection = connection
end
def state(ami_id)
@connection.ec2.images[ami_id].state
end
def exists?(ami_id)
@connection.ec2.images[ami_id].exists?
end
... |
module Browser
class AbstractBrowserService
def initialize(entity)
@entity = entity
end
def process
return unless ready_for_processing
end
private
def ready_for_processing
return false unless @entity.enabled?
return false unless @entity.time_frame.include?(Time.now.h... |
class ChangeFeedIndexColumn < ActiveRecord::Migration[4.2]
def change
remove_index :feeds, :column => [:url]
add_index :feeds, :feed_url, :unique => true, :length => 1024
end
end
|
class Reservation < ActiveRecord::Base
has_many :devices
belongs_to :engineer
end
|
class AppDelegate < ProMotion::Delegate
def application(application, didFinishLaunchingWithOptions:launchOptions)
open HomeScreen.new(nav_bar: true)
true
end
end
|
class Admin::Match < ActiveRecord::Base
translates :name
validates :name, presence: true
validates :ordinal, presence: true, uniqueness: true
default_scope -> { order('ordinal') }
has_many :videos, class_name: 'Admin::MatchVideo', foreign_key: 'match_id', dependent: :restrict_with_exception
end
|
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.0'
use_frameworks!
inhibit_all_warnings!
def common_pods
pod 'RealmSwift', '3.7.4'
end
target "careem_test" do
common_pods
#UI components
pod 'PYSearch', '0.9.0'
#Promise & future
pod 'PromiseKit'#, '6.0.1'
... |
require 'benchmark'
# array = (1..100_000).map {rand}
def shuffle(array)
length = array.length - 1
index = rand(0..length)
end
Benchmark.bm do |x|
# x.report("reverse:") {array.reverse}
x.report("shuffle:") {array.shuffle}
end
def graph
generate_graph = Gchart.new(
:type => 'line',
:size => '450... |
class Article < ActiveRecord::Base
#TODO uncomment after friendly id will support rails 4
#extend FriendlyId
#friendly_id :title, use: :slugged
has_and_belongs_to_many :rubrics
belongs_to :origin, :class_name => Article # On front list of clones
validates :title, :body, :language, :presence => true
vali... |
#! /usr/bin/env ruby
#
require 'pathname'
require 'openssl'
require 'yaml'
module CVE20113872
class ScanCerts
attr_accessor :puppet
attr_accessor :cadir
attr_accessor :yamldir
attr_accessor :nodes
def initialize(options = {})
@puppet = options[:puppet] = "puppet"
if ! options[:yamld... |
require_relative 'abstract_chatroom'
class Chatroom < AbstractChatroom
def initialize
@participants = {}
end
def register(participant)
@participants[participant.name.to_sym] = participant if
@participants[participant.name.to_sym].nil?
participant.chatroom = self
end
def send_message(from,... |
# frozen_string_literal: true
require 'active_support/concern'
module FilterSearchable
extend ActiveSupport::Concern
included do
filter :search do |rel, _op, value|
rel.search(value)
end
end
end
|
class FamilyCreatorForm
include ActiveModel::Model
include ActiveRecord::AttributeAssignment
attr_accessor :user_id,
:creator_id,
:relation_id,
:creator_name,
:creator_date_of_birth,
:creator_gender_id
def save
creator = Creato... |
class PeriodicExpensesController < ApplicationController
authorize_resource
def index
@periodic_expenses = PeriodicExpense.all
end
def new
setup
@periodic_expense = PeriodicExpense.new
end
def create
setup
@periodic_expense = PeriodicExpense.new(periodic_expense_params)
if @period... |
class AddStatusToGatewayRequest < ActiveRecord::Migration
def self.up
add_column :gateway_requests, :status, :boolean, :default=>false
add_index :gateway_requests, [:transaction_reference, :status], :name => 'index_on_reference'
end
def self.down
remove_column :gateway_requests, :status
remove_in... |
module Safely
DEFAULT_EXCEPTION_METHOD = proc do |e, info|
begin
Airbrake.notify(e, info) if defined?(Airbrake)
if defined?(Appsignal)
if Appsignal::VERSION.to_i >= 3
Appsignal.send_error(e) do |transaction|
transaction.set_tags(info)
end
else
... |
# frozen_string_literal: true
require 'rails_helper'
describe Api::V1::EventSerializer, type: :model do
describe '#as_json' do
subject { described_class.new(event).as_json }
let(:event) { create :event }
it { is_expected.to eq(amount: event.amount) }
end
end
|
module Sprockets
# Internal: Bundle processor takes a single file asset and prepends all the
# `:required_paths` to the contents.
#
# Uses pipeline metadata:
#
# :required_paths - Ordered Set of asset filenames to prepend
# :stubbed_paths - Set of asset filenames to substract from the
# ... |
class NanniesController < ApplicationController
before_action :authenticate_user!
before_action :user_should_be_registered ,:except=>[:new,:create]
before_action :set_nanny, only: [:edit, :update, :destroy,:data]
# GET /nannies
# GET /nannies.json
def index
@nannies = Nanny.all
end
# GET /nannies... |
class Anagram
def initialize(word)
@input_word = word
end
def match(match_list)
match_list.select do |w|
w.downcase != @input_word.downcase &&
letters_of(w) == letters_of(@input_word)
end
end
private
def letters_of(word)
word.downcase.each_char.sort
end
end
module BookKee... |
class CreateIdentities < ActiveRecord::Migration
def self.up
create_table :identities do |t|
t.integer :user_id
t.string :identity_name
t.string :first_name
t.string :last_name
t.string :company_name
t.string :title
t.string :country
t.string :state
t.string :... |
class Api::V1::ContextsController < Api::V1::ApiController
before_action :set_context, only: %i[show update]
def index
@contexts = current_user.contexts
end
def show; end
def update
if @context.update(context_params)
render 'show', status: :ok
else
render 'show', status: :unprocessa... |
require "rails_helper"
RSpec.describe PropertiesController, :type => :controller do
before :each do
@user = FactoryGirl.create(:user)
sign_in @user
end
describe "GET index" do
it "renders the properties list" do
get :index
expect(response).to render_template(:index)
end
end
desc... |
module MongoDBLogging
def self.included(base)
base.class_eval do
around_filter :enable_mongo_logging
end
end
protected
def mongo_ignore_request?
return false if request.ssl? || request.xhr?
return false if logged_in?
user_agent = request.headers["USER_AGENT"]
return false if cont... |
# frozen_string_literal: true
class Comment < ApplicationRecord
belongs_to :avatar
belongs_to :user
validates :avatar_id, presence: true
validates :user_id, presence: true
validates :content, presence: true, length: { maximum: 40 }
default_scope -> { order(created_at: :desc) }
end
|
class ChangeColumnDisplayCountOnFeeds < ActiveRecord::Migration
def change
change_column :feeds, :display_count, :integer, :null => false, :default => Feed::DEFAULT_DISPLAY_COUNT
end
end
|
class AdsController < ApplicationController
before_action :authenticate_user!, except: [:index, :show, :search]
before_action :find_user, only: [:new, :create]
before_action :find_ad, only: [:show]
def index
if params[:query]
@ads = Ad.search(params[:query])
else
@ads = Ad.all
end
end... |
class User < ApplicationRecord
has_secure_password
validates_presence_of :email
validates_uniqueness_of :email
has_many :movies
end
|
module Effect
class Activated
attr_reader :name
attr_accessor :parent
def initialize(parent, costs = nil, name = nil, targets = Array.new([:self]))
@parent = parent
@targets = targets
@costs = Hash.new{|hash, key| 0}
unless costs === nil
costs.each do |cost, delta|
@costs[cost.to_sym] = de... |
require_relative 'card'
class Deck
def self.all_cards
cards = []
Card.values.each do |value|
Card.suits.each do |suit|
cards << Card.new(suit, value)
end
end
cards
end
attr_accessor :cards
def initialize(cards = self.class.all_cards)
@cards = cards
end
def count... |
module UsersHelper
def header_icon_image_present?(account)
if account&.icon_image.present?
image_tag account.icon_image.url, class: "user__mypage--icon"
else
image_tag "member_photo_noimage.png", class: "user__mypage--icon"
end
end
def evaluations_user_icon_image(account)
if account&.... |
module Babushka
class DepError < StandardError
end
class Dep
class BaseTemplate
def self.suffixed?; false end
def self.definer_class; BaseDepDefiner end
def self.runner_class; BaseDepRunner end
end
module Helpers
def Dep spec, opts = {}; Dep.for spec, opts end
de... |
class GenresResponse
attr_reader :genres
def initialize(genres)
self.genres = genres
end
def body
{ infer_resource_name => to_hash }.to_json
end
def infer_resource_name
genres.class == Array ? 'genres' : 'genre'
end
private
attr_writer :genres
def to_hash
if genres.class == Arra... |
require "rails_helper"
describe "Show authors page", type: :feature do
it "should render without an error" do
visit authors_path
end
it "should display the names of the authors" do
FactoryBot.create :author
visit authors_path
expect(page).to have_text("Alan Turing")
end
it "should link to t... |
# frozen_string_literal: true
FactoryBot.define do
factory :resource_connection_topic, class: 'Resource::Connection::Topic' do
resource { nil }
topic { nil }
end
end
|
class AddFieldsToReleasePlannings < ActiveRecord::Migration
def change
add_column :release_plannings, :sc_start, :date
add_column :release_plannings, :sc_end, :date
add_column :release_plannings, :delay_type, :integer
end
end
|
#!/usr/bin/ruby
age = 5
puts case age
when 0..2
'baby'
when 3..6
'little child'
when 7..12
'child'
when 13..18
'youth'
else
'adult'
end
|
class ModifyProjectsForDescriptions < ActiveRecord::Migration
def self.up
change_table :projects do |t|
t.rename :full_description, :desc_col1
t.string :desc_col2
t.string :desc_col3
end
end
def self.down
change_table :projects do |t|
t.rename :desc_col1, :full_description
t.remove :desc_... |
# Describe the difference between ! and ? in Ruby.
# And explain what would happen in the following scenarios:
# 1. what is != and where should you use it?
# 2. put ! before something, like !user_name
# 3. put ! after something, like words.uniq!
# 4. put ? before something
# 5. put ? after something
# 6. put !! befor... |
class CreateCandidacies < ActiveRecord::Migration[5.1]
def change
create_table :candidacies do |t|
t.references :user, foreign_key: true
t.references :campaign, foreign_key: true
t.string :workflow_state
t.string :string
t.boolean :profil_incomplet
t.boolean :mauvaise_zone
... |
# coding: utf-8
Given /^I'm in ([^"]*)$/ do |arg1|
visit route_to_path(arg1)
end
Given /^there is (\d+) pokers for this campaign$/ do |arg1|
@pokes = []
arg1.to_i.times do
@pokes << Poke.make!(campaign: @campaign, user: User.make!)
end
end
Given /^there is a campaign called "([^"]*)"$/ do |arg1|
@campai... |
class AddReviewedToOffers < ActiveRecord::Migration[5.1]
def change
add_column :offers, :reviewed, :boolean
end
end
|
class ProductSerializer < ActiveModel::Serializer
attributes :id, :name, :description, :category, :shipping_description, :stock, :price, :is_used, :created_at, :updated_at, :user#, :picture_id, :origin_id, :user_id
# belongs_to :user
belongs_to :cover
belongs_to :origin
# has_many :comments
has_many... |
require 'tty'
require File.join CopyPeste::Require::Path.base, 'copy_peste/modules.rb'
require File.join CopyPeste::Require::Path.public, 'tmp_logo'
%W{ parser console_display }.each do |file|
require File.join(
CopyPeste::Require::Path.graphics,
'console_mode',
file
)
end
%W{ analysis_requests core_r... |
#!/usr/bin/env ruby
require_relative '../../../framework/Context'
class Emergency
@@name = :emergency
@@context = Context.new(@@name)
def self.get
@@context
end
def self.name
@@name
end
end |
# frozen_string_literal: true
module Api::V1::Users
CreateSchema = Dry::Validation.Params(BaseSchema) do
required(:first_name).filled(:str?)
required(:last_name).filled(:str?)
required(:email).filled(:email?)
required(:password).filled(min_size?: 6).confirmation
end
end
|
class CreateBundleTable < ActiveRecord::Migration
def change
create_table :bundles do |b|
b.string :name
b.text :description
b.integer :user_id
end
end
end
|
# frozen_string_literal: true
# Naturally many of the various resources which are scoped to accounts all need
# to be appropriately locked down in order to ensure that unauthorized users
# can not access them. This is where those concerns live
module AccountAuthentication
extend ActiveSupport::Concern
included do... |
#--
# Copyright (c) 2010-2013 Michael Berkovich, tr8nhub.com
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, mod... |
require 'simple_spec_helper'
class MyClass
def self.value(value=nil)
@value=value if value
@value
end
attr_accessor :name
def initialize
self.run(:after_init)
end
def save
self.run(:before_save)
end
end
class Counter
def self.set(val)
@value=val
end
def self.get
@value
... |
class User < ActiveRecord::Base
attr_accessible :user_id, :friend_id
serialize :friend_id, Array
validates_uniqueness_of :user_id
has_many :msgs
end
|
class OrderNotifier < ActionMailer::Base
default from: 'Rossetti Coffee - Dublin' "conor@acument.ie"
# Subject can be set in your I18n file at config/locales/en.yml
# with the following lookup:
#
# en.order_notifier.received.subject
#
def received(order)
@order = order
mail to: order.email, sub... |
# frozen_string_literal: true
module Vedeu
module Cells
# Provides the character/escape sequence to draw one cell of the
# bottom horizontal border with a custom value, colour and style.
#
# @api private
#
class BottomHorizontal < Vedeu::Cells::Horizontal
# @return [Symbol]
def... |
require 'spec_helper'
describe PageDesc::Browser do
context 'session' do
let(:app) { Object.new }
before do
app.extend PageDesc::Browser
end
it 'should be a PageDesc session' do
app.browser.should be_a(PageDesc::Session)
end
it 'is stored as a lazily initialized attribute' do
... |
class Tweet < ApplicationRecord
belongs_to :user
mount_uploader :image, ImageUploader
validates :message, presence: true, if: proc { |t| t.image.blank? }
validates :message, length: { maximum: 140 }
end
|
# Filters added to this controller apply to all controllers in the application.
# Likewise, all the methods added will be available for all controllers.
class ApplicationController < ActionController::Base
include AuthenticatedSystem
helper :all # include all helpers, all the time
filter_parameter_logging ... |
require File.expand_path("../api/version", __FILE__)
require File.expand_path("../api/configuration", __FILE__)
require File.expand_path("../api/client", __FILE__)
module Audience::Api
extend Configuration
def self.client(options={})
Audience::Api::Client.new(options)
end
# Delegate to Audience::Api::Cli... |
require "spec_helper"
RSpec.describe KnuckleCluster::Configuration do
let(:file) { File.join(File.dirname(__FILE__), 'fixtures', 'test_data')}
let(:profile) { 'platform' }
it "generates correct output using inheritance" do
expect(
KnuckleCluster::Configuration.load_parameters(profile: profile, pro... |
class CreatePatients < ActiveRecord::Migration
def self.up
create_table :patients do |t|
t.string :name, :limit => 150, :null => false
t.string :cpf, :limit => 20
t.string :rg, :limit => 20
t.date :burned_date
t.string :phone1, :limit => 30
t.string :phone2, :limit => 30
... |
FactoryBot.define do
factory :attendance do
participant { FactoryBot.create(:user) }
event { FactoryBot.create(:event) }
stripe_customer_id { Faker::IDNumber.valid }
end
end |
class FontFiraMonoForPowerline < Formula
head "https://github.com/powerline/fonts.git", branch: "master", only_path: "FiraMono"
desc "Fira Mono for Powerline"
homepage "https://github.com/powerline/fonts/tree/master/FiraMono"
def install
(share/"fonts").install "FuraMono-Bold Powerline.otf"
(share/"font... |
require_relative '../../itamae_helper'
REPOSITORY_PATH = homedir_path + 'var' + 'repo' + 'private' + 'dotfiles'
RC_FILES = %w(bashrc gitconfig pryrc rbtclk tmux.conf vimperatorrc vimrc)
directory_recursive homedir_path, *%w(var repo private) do
owner user_name
group group_name
mode '744'
end
git REPOSITORY_PAT... |
class Api::UserResource < JSONAPI::Resource
attributes :name, :cellphone, :nickname, :birthday
has_many :todos
filter :name, :cellphone
end
|
class Ad < ActiveRecord::Base
belongs_to :user
has_many :adimages
end
|
xml.instruct! :xml, version: '1.0'
xml.rss version: '2.0' do
xml.channel do
xml.title @post_type.the_title
xml.description @post_type.the_excerpt
xml.link @post_type.the_url
xml.guid @post_type.the_id
xml.items @posts.size
@posts.decorate.each do |post|
xml.item do
xml.title pos... |
class PagesController < ApplicationController
def home
@title = "Home"
if user_signed_in?
@problems = current_user.problems
end
end
def contact
@title = "Contact"
end
def about
@title = "About"
end
def help
@title = "Help"
end
def error
@title = "Page Not F... |
require 'specials'
class Game < ActiveRecord::Base
has_many :players, dependent: :destroy
has_many :supplies, dependent: :destroy
has_many :cards, dependent: :destroy
has_many :events, dependent: :destroy
has_many :dialogs, dependent: :destroy
has_many :card_play_states, dependent: :destroy
belongs_to :trash, c... |
# -*- coding: utf-8 -*-
=begin
O cardápio de uma lanchonete é o seguinte:
Especificação Código Preço
Cachorro Quente 100 R$ 1,20
Bauru Simples 101 R$ 1,30
Bauru com ovo 102 R$ 1,50
Hambúrguer 103 R$ 1,20
Cheeseburguer 104 R$ 1,30
Refrigerante 105 R$ 1,00
Faça um programa que lei... |
require_relative 'lib/gsa_edi'
using Stupidedi::Refinements
file_path = "IO/EDI/non_printing.txt"
config = Stupidedi::Config.contrib
reader = Stupidedi::Reader.build(File.binread(file_path))
while (result = reader.read_segment).defined?
segment_tok = result.fetch
reader = result.remainder
pp segment_tok... |
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
before_filter :load_owner
decorates_assigned :owner
def load_owner
@owner = Owner.new
end
end
|
class CreateDropboxFiles < ActiveRecord::Migration
def change
create_table :dropbox_files do |t|
t.integer :user_id
t.column :path_hash, "char(8)"
t.text :path
t.string :rev
t.integer :size
t.string :state
t.timestamps
end
add_index :dropbox_files, [:user_id, :pa... |
class FavoritesController < ApplicationController
def index
@user = current_user
@favorites = @user.gifs
end
def create
@gif = Gif.find(params[:gif_id])
@user = current_user
@favorites = @user.gifs << @gif
redirect_to user_favorites_path
end
end
|
require './tree.rb'
class BoundaryTraversal < Tree
def print_tree(ptr=@root)
return unless ptr
printLeftBoundary(ptr)
printLeafNodes(ptr)
printRightBoundary(ptr.right)
end
def printLeftBoundary(ptr)
return unless ptr
print ptr.data, " " unless leaf_node?(ptr)
if (ptr.left)
pri... |
class Photo < ActiveRecord::Base
has_many :comments, as: :commentable
belongs_to :fan
belongs_to :concert
mount_uploader :image, ImageUploader
end
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.