text stringlengths 10 2.61M |
|---|
require 'omf_base/lobject'
require 'rack/accept'
use ::Rack::ShowExceptions
#use ::Rack::Lint
use Rack::Accept
OMF::Web::Runner.instance.life_cycle(:pre_rackup)
options = OMF::Web::Runner.instance.options
auth_opts = options[:authentication] || {required: false}
require 'omf-web/rack/session_authenticator'
use OMF:... |
class Uphack::DashboardController < ApplicationController
def index
@categories = UphackJobCategory.where('parent_id IS NULL')
if params[:category_id].present?
@category = UphackJobCategory.find(id: params[:category_id])
@subcategories = UphackJobCategory.where('parent_id = ?', params[:category_id... |
class Post < ActiveRecord::Base
belongs_to :user
belongs_to :post
has_many :comments
before_save :record_published_at_if_published
validates :title, presence: true, length: { maximum: 100 }
validate :enforce_the_first_rule
scope :published, -> { where(published: true) }
scope :published_before, -> (... |
Ym4r::MapstractionPlugin::Marker.class_eval do
#Creates a GMarker object from a georuby point. Accepts the same options as the GMarker constructor. Assumes the points of the line strings are stored in Longitude(x)/Latitude(y) order.
def self.from_georuby(point,options = {})
Marker.new([point.y,point.x],options)... |
class Item
attr_reader :name, :price
def initialize(item)
@name = item[:name]
@price = item[:price].delete("$").to_f
end
end
|
class RenameColumnsForCategories < ActiveRecord::Migration[5.0]
def change
rename_column :categories, :middle_category_name, :middle
rename_column :categories, :large_category_name, :large
end
end
|
require 'travis/cli/setup'
module Travis
module CLI
class Setup
class Releases < Service
description "Upload Assets to GitHub Releases"
def run
deploy 'releases' do |config|
config['api_key'] = ask("GitHub Oauth Key(With repo or repo:public permission): ") { |q| q.ech... |
class Photo < ApplicationRecord
belongs_to :user
# belongs_to :album
has_many :comments
has_one_attached :image
end
|
# rspec ./spec/models/comment_spec.rb
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe Comment, type: :model do
let!(:user) { create(:user) }
let!(:admin) { create(:admin) }
let!(:item1) { build(:item1, user_id: admin.id, cordinate_id: cordinate1.id) }
let!(:cordinate1) { create(:cordinate1... |
# frozen_string_literal: true
require "rails_helper"
describe ScheduleGeneratorJob do
describe "#perform" do
subject(:job) { described_class.new }
let(:agenda) { create(:combined_agenda) }
let(:schedule_generator) { instance_double(ScheduleGenerator) }
before do
Timecop.freeze(2016, 1, 1)
... |
class User < ApplicationRecord
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :validatable, :omniauthable, omniauth_providers: [:facebook, :google_o... |
require 'rails_helper'
describe "the favoriting/unfavoriting a message process" do
it "allows a user the ability to mark a message as favorite and remove favorite status" do
user = FactoryGirl.create(:user)
message = FactoryGirl.create(:message)
visit user_session_path
fill_in 'Login', with: user.us... |
# exercise 1
# puts "How much do you weight in pound?"
# pound_user = gets.chomp.to_i
# def conversion(pound)
# result = pound / 2.2
# puts "You weight #{result} in kilos!"
# end
# conversion(pound_user)
# exercise 2
# puts "What's your word you want to reverse?"
# text_user = gets.chomp
# def reverser(text)
# p... |
class CreateUtilities < ActiveRecord::Migration[5.1]
def change
create_table :utilities do |t|
t.integer :flat_id, null: false
t.integer :category_id, null: false
t.integer :tariff_id, null: false
t.string :description
t.float :start_value_counter
t.float :last_value... |
require 'chemistry/element/atom'
module Chemistry
module Element
extend self
def define(name, &definition)
if block_given?
create_element_class(name).instance_eval &definition
else
raise ArgumentError, "`element` must be given a block"
end
end
private
def crea... |
class AddDefaultValueToLineItemsIsAccepted < ActiveRecord::Migration
def change
change_column :line_items, :is_accepted, :boolean, :default => false
end
end
|
class Item < ActiveRecord::Base
belongs_to :category
validates :category, presence: true
validates :title, presence: true
validates :price, presence: true
validates :description, presence: true
validates :image_path, presence: true
def self.search(search)
query = "%#{search}%"
self.where("title... |
require 'active_support/core_ext/module'
# Git module
#
# When included, you an persist(commit) any instance as long as it
# reponds to
#
# # file_path
# # name
# # content
#
# Normally you will include FileControl along with Git so that everything
# runs 'smoothly'.
#
# Do it as follows:
#
#
# class Album
# at... |
class Api::PlayerController < ApplicationController
before_action :user_authed
def index
render json: Player.all
end
def show
render json: Player.find(params[:id])
end
def find_by
render json: Player.where(player_params)
end
def find_teams
render json: Player.find(params[:id]).teams.... |
module RefParsers
NEWLINE_MERGER = ' '
class LineParser
def initialize
hash = {"@type_key" => @type_key, "@key_regex_order" => @key_regex_order, "@line_regex" => @line_regex,
"@value_regex_order" => @value_regex_order, "@regex_match_length" => @regex_match_length}
missing = hash.... |
class AddSomeColumnsToStudents < ActiveRecord::Migration
def change
add_column :students, :is_graduated, :boolean, :default => false
add_column :students, :jiu_ye_xie_yi_file_entity_id, :integer
add_column :students, :bi_ye_jian_ding_file_entity_id, :integer
end
end
|
require File.expand_path("../abstract_unit", __FILE__)
class RecognizeTest < RoutingTestCase
def setup
super
@routes = load_fixture(PathApp, "r1.txt")
end
def test_recognize
assert_recognize({:action => "index", :controller => "root"}, "/", :root)
assert_recognize({:action => "index", :controller => "n... |
require "spec_helper"
RSpec.describe "Test herencia - Paciente" do
before :each do
@paciente1 = Paciente.new("Lucas","Perez",45,1,85,1.78,70,95,0.12)
@paciente2 = Paciente.new("Kevin","Garcia",19,1,75,1.80,80,90,0.27)
@paciente3 = Paciente.new("Pepe","Lopez",25,1,100,1.67,95,92,0.54)
@paciente4 = Pacien... |
# frozen_string_literal: true
require 'pundit'
require_relative 'application_record'
class Base < ApplicationRecord
include Pundit
self.abstract_class = true
end
|
class ChangeWinnerLoserColumns < ActiveRecord::Migration
def self.up
rename_column :matches, :winner, :winner_id
rename_column :matches, :loser, :loser_id
end
def self.down
rename_column :matches, :winner_id, :winner
rename_column :matches, :loser_id, :loser
end
end
|
class LineItem < ActiveRecord::Base
belongs_to :booking
def total
unit_price_at_checkout
end
end
|
class RecipesController < ApplicationController
get '/recipes' do
@recipes = Recipe.all
if logged_in
erb :'/recipes/recipes'
else
redirect to '/login'
end
end
get '/recipes/new' do
if logged_in
@recipe = Recipe.new
erb :'/recipes/new'
else
redirect to '/logi... |
require File.dirname(__FILE__) + '/../test_helper'
class DevelopersControllerTest < ActionController::TestCase
def test_should_get_index
get :index
assert_response :success
assert_not_nil assigns(:developers)
end
def test_should_get_new
get :new
assert_response :success
end
def test_sho... |
require_relative 'piece'
class Queen < Piece
def to_s
@player.color == 'white' ? "\u2655" : "\u265B"
end
def update_available_moves
# TODO: finish this
@available_moves = []
end
end
# class Queen < Piece
#
# def to_s
# @player.color == 'white' ? "\u2655" : "\u265B"
# end
#
# def allowe... |
class CreateFitBitStats < ActiveRecord::Migration
def change
create_table :fit_bit_stats do |t|
t.integer :steps, default: 0
t.integer :floors, default: 0
t.timestamps null: false
end
end
end
|
class CreateBars < ActiveRecord::Migration[5.1]
def change
create_table :bars do |t|
t.string :name
t.text :description
t.string :address
t.string :phone_number
t.integer :avg_rating
t.integer :rating_id
t.integer :favorite_id
t.boolean :music
t.boolean :sport... |
module Playable
def hit(card)
cards << card
end
def total
cards.map(&:point).sum
end
def bust?
total > 21
end
end |
# frozen_string_literal: true
# Advent of Code 2020
#
# Robert Haines
#
# Public Domain
require 'test_helper'
require 'aoc2020/seating_system'
class AOC2020::SeatingSystemTest < MiniTest::Test
MAP = <<~EOMAP
L.LL.LL.LL
LLLLLLL.LL
L.L.L..L..
LLLL.LL.LL
L.LL.LL.LL
L.LLLLL.LL
..L.L.....
... |
class AddPublishedAtToPosts < ActiveRecord::Migration
def change
add_column :posts, :published_at, :datetime
Post.where(published: true).each do |post|
post.published_at = post.updated_at
post.save
end
end
end
|
require 'spec_helper'
describe "affiliations/edit" do
before(:each) do
mock_geocoding!
@location = FactoryGirl.create(:location)
@social_info = FactoryGirl.create(:social_info)
theStub = stub_model(Affiliation,
:name => "MyString",
:location => @location,
:social_info => @social_inf... |
# -*- coding: utf-8 -*-
class Teacher < ActiveRecord::Base
belongs_to :user
has_many :courses
scope :with_student, lambda {|student_user|
joins('inner join course_student_assigns on course_student_assigns.teacher_user_id = teachers.user_id').where('course_student_assigns.student_user_id = ?', student_user.... |
require 'gtk3'
#====== La classe BoutonNbTentes représente les boutons sur le côté de la grille de jeu pour remplir une ligne/colonne d'herbe
class BoutonNbTentes
#=Variable d'instance
# @bouton : Le bouton
# @coordI, @coordJ : Coordonnées du bouton
attr_accessor :clic
attr_reader :chemin
attr_accessor :bou... |
#author : Elihu Alejandro Cruz Albores
#version 1.0.2
##Estructura basica de almacenamiento para evitar arrays
class Information
@code #caracter que almacena
@times #Numero de veces encontraod el elemento
def initialize(code = "", times = 0)
@code = code
@times = times
end
... |
# == Schema Information
#
# Table name: tracks
#
# id :integer not null, primary key
# title :string(255) not null
# album_id :integer not null
# track_type :string(255) default("regular"), not null
# lyrics :text
# created_at :datetime
# updated_at :datetime
#
cla... |
module Larvata
module Signing
module ResourceRecordService
# @param [Object] form_data 申請單據物件
# @param [String] type 單據類型,如:Quotation
# @param [Integer] id 單據編號
# @param [String] doc_state 簽呈狀態(draft, signing, approved, rejected, suspended)
# @return [Doc] 對應的簽呈物件
def self.loa... |
# Confucius Says, Debugging, Ruby Basics, Exercises
def get_quote(person)
if person == 'Yoda'
'Do. Or do not. There is no try.'
elsif person == 'Confucius'
'I hear and I forget. I see and I remember. I do and I understand.'
elsif person == 'Einstein'
'Do not worry about your difficulties in Mathemati... |
# encoding: UTF-8
# Copyright 2012 Twitter, Inc
# http://www.apache.org/licenses/LICENSE-2.0
module TwitterCldr
module Shared
class Territory
attr_reader :code
def initialize(territory_code)
@code = territory_code
end
def contains?(territory_code)
TerritoriesContainmen... |
source 'https://rubygems.org'
gem 'rails', '4.2.5.1' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
# Databases
gem 'pg' # Use pg as the database for Active Record
#Tools
gem 'decent_exposure' ... |
require_relative '../../tictactoeruby.core/languages/message_generator.rb'
require_relative '../../tictactoeruby.core/exceptions/nil_reference_error.rb'
require_relative '../../tictactoeruby.core/exceptions/invalid_value_error.rb'
module TicTacToeRZ
module Validators
module PlayerSelectionValidator
def sel... |
source 'https://rubygems.org'
git_source(:github) do |repo_name|
repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
"https://github.com/#{repo_name}.git"
end
gem 'rails', '~> 5.0.1'
# Use Puma as the app server
gem 'puma', '~> 3.0'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use ... |
require 'nokogiri'
module JDict
class NokogiriDictionaryIndexer < JDict::DictionaryIndexer
def initialize(path)
super
end
def index(db_transaction, &block)
doc = File.open(path) do |f|
Nokogiri::XML(f) { |c| c.strict }
end
raw = doc/"./JMdict/entry"
total = raw.cou... |
class CreateRewards < ActiveRecord::Migration
def change
create_table :rewards do |t|
t.integer :project_id
t.string :description
t.integer :donation_amount
t.timestamps
end
add_column :donations, :reward_id, :integer
end
end
|
class Like < ApplicationRecord
# associations
belongs_to :user
belongs_to :product, counter_cache: true
# validations
validate :user_has_likes
# methods
def user_has_likes
if self.product.likes.exists?(user_id: self.user.id)
errors.add(:user, "has already like this product")
end
end
end
|
feature 'Hitpoints' do
scenario "player1 views player2's hitpoints" do
sign_in_and_play
expect(page).to have_content("Tommy 100hp")
end
end
|
class Location
include ApplicationRecord
# acts_as_cached version: 1, expires_in: 1.week
field :name, type: String
field :users_count, type: String, default: 0
has_many :users
# add field users_count automaticlly
# count_objects :users
scope :hot, -> { order_by(users_count: :desc) }
validates :na... |
module Sumac
# Use {LocalObject} to permit sharing of objects with the remote endpoint.
#
# Methods are exposed to the remote endpoint via specifying preferences.
#
# Normally you will include {LocalObject} in a class or module and call
# +#expose_method+ to add preferences for all of its instances.
# +#... |
Rails.application.routes.draw do
root 'home#public'
get 'public', to:'posts#all', as:'home'
# get '/', to:'home#public', as:'home'
get 'sign_in', to: 'sessions#new'
delete 'sign_out', to: 'sessions#destroy'
get 'signup', to: 'users#new'
resources :posts, only: [:all] do
resources :comments
en... |
ActiveAdmin.register CourtDateCSV do
permit_params :file
actions :all, except: %i[destroy edit]
form do |f|
f.inputs 'Upload CSV' do
f.input :file, as: :file
end
f.actions do
f.action :submit, label: 'Upload CSV'
end
end
show do
panel 'Court Reminder CSV Details' do
att... |
class ItemGroupsController < ApplicationController
before_action :set_item_group, only: [:show, :edit, :update, :destroy]
# GET /item_groups
# GET /item_groups.json
def index
@item_groups = ItemGroup.all
end
# GET /item_groups/1
# GET /item_groups/1.json
def show
end
# GET /item_groups/new
... |
class AddGenderJobToUsers < ActiveRecord::Migration
def change
add_column :users, :gender, :boolean
add_column :users, :job , :string
add_column :users, :postcode, :string
add_column :users, :detail_address, :string
add_column :users, :telphone, :string
end
end
|
# typed: true
# frozen_string_literal: true
require 'test_helper'
module Ffprober
module Parsers
class UrlParserTest < Minitest::Test
VALID_HTTP_URL = 'http://fakeurl.io/video.mp4'
VALID_FILE_URL = 'file:///localhost/video.mp4'
UNESCAPED_URL = 'file:///localhost/video name.mp4'
INVALID_U... |
class AddExpertToRecommendations < ActiveRecord::Migration
def change
add_reference :recommendations, :expert, index: true
end
end
|
class Lession < ActiveRecord::Base
belongs_to :category
has_many :quessions, dependent: :destroy
validates :content, presence: true , length: { maximum: Settings.max_content },
uniqueness: { case_sensitive: false }
def self.search(condition_search = '')
if "".eql?(condition_search)
return Lessio... |
module JobGet
class Controller < Ramaze::Controller
helper :xhtml, :user, :stack, :formatting, :paginate
engine :Haml
layout 'default'
map_layouts '/'
trait :user_model => User
# add sidebars in the view/xxx/sidebar.haml directories to override this.
def sidebar
''
end
pr... |
class CreateTagGroups < ActiveRecord::Migration
def change
create_table :tag_groups do |t|
t.string :group_name, :null => false
t.boolean :exclusive, :default => false
t.timestamps
end
add_index :tag_groups, :group_name, unique: true
add_reference :tags, :tag_group, index: tru... |
require 'spec_helper'
describe SplitIoClient::Cache::Stores::SegmentStore do
let(:metrics_repository) { SplitIoClient::Cache::Repositories::MetricsRepository.new(config.metrics_adapter, config) }
let(:metrics) { SplitIoClient::Metrics.new(100, config, metrics_repository) }
let(:segments_json) { File.read(File.ex... |
class CreateFlytes < ActiveRecord::Migration[5.1]
def change
create_table :flytes do |t|
t.integer :flyer_id
t.integer :listing_id
t.decimal :deposit_amount
t.date :flyer_depart
t.date :flyer_arrive
t.string :handover_method
t.datetime :item_received
t.datetime :ite... |
require 'poise'
require 'chef/resource'
require 'chef/provider'
module Bootstrap
class Resource < Chef::Resource
include Poise
provides :bootstrap
actions :go, :download, :delete
attribute :name, name_attribute: true, kind_of: String
attribute :fqdn, kind_of: String, required: true
attribu... |
require "spec_helper"
describe Merchant::MerchantStore do
before :each do
@merchant_store = Merchant::MerchantStore.new name: "test2", status: Merchant::MerchantStatus::ENTERING
@merchant_store.save!
@merchant_legal = Merchant::MerchantLegal.new :license_name => "1234"
@merchant_legal.merchant_store ... |
module Point
def Point.distance_to_line test_point, endpoint_a, endpoint_b
baseline_dx = (endpoint_a[:x] - endpoint_b[:x])
baseline_dy = (endpoint_a[:y] - endpoint_b[:y])
point_dx = (endpoint_a[:x] - test_point[:x])
point_dy = (endpoint_a[:y] - test_point[:y])
baseline_length = Math.sqrt(bas... |
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
# make vm
config.vm.define "vm-docker" do |node|
node.vm.box = "centos/7"
node.vm.provider "virtualbox" do |vb| # Máy ảo dùng nền tảng virtualbox, với các cấu hình bổ sung thêm cho provider
vb.name = "vm01"... |
# Puppet package provider for Python's `pip3` package management frontend.
# <http://pip.pypa.io/>
require 'puppet/provider/package/pip'
Puppet::Type.type(:package).provide :pip3,
:parent => :pip do
desc "Python packages via `pip3`.
This provider supports the `install_options` attribute, which allows command-... |
require File.expand_path(File.join(File.dirname(__FILE__), '..', "helper"))
module Nokogiri
module XML
class TestAttr < Nokogiri::TestCase
def test_content=
xml = Nokogiri::XML.parse(File.read(XML_FILE), XML_FILE)
address = xml.xpath('//address')[3]
street = address.attributes['stre... |
Rails.application.routes.draw do
root 'houses#index'
resources :houses, except: [:show]
resources :houses, only: [:show] do
resources :members
end
end
|
require_relative '../../app/models/client'
require_relative '../../app/models/server'
require_relative '../../app/models/repository'
require_relative '../../app/models/email'
require_relative '../../app/models/repositories/memory/emails'
require_relative '../../app/models/repositories/memory/user_email_references'
des... |
require "pry"
class Song
attr_accessor :artist_name, :song, :name
@@all = []
#instantiates and saves the song, and it returns the new song that was created
def self.create
title = self.new
@@all << title
title
end
# instantiates a song with a name property
def self.new_by_name(title)
son... |
class Post < ActiveRecord::Base
# set relationships of models
belongs_to :user
default_scope -> { order(created_at: :desc) }
# create validations requiring and restricting inputs
validates :user_id, presence: true
validates :content, presence: true, length: { maximum: 140 }
# validates_exclusion_of :forma... |
require 'set'
module Badgeable
class Config
class << self
attr_accessor :badge_definitions
def custom_attributes
@custom_attributes ||= Set.new([:icon, :description])
end
end
attr_reader :threshold, :klass, :conditions_array, :subject_proc
def initialize
... |
# == Schema Information
#
# Table name: areas
#
# id :integer not null, primary key
# stadium_id :integer
# name :string
# description :string
# slug :string
# change_price :decimal(, ) default(0.0)
# created_at :datetime
# updated_at :datetime
#
FactoryGirl.defin... |
class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
rescue_from ActiveRecord::RecordNotFound, :with => :record_not_found
def require_admin
redirect_to '/' un... |
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant::Config.run do |config|
config.vm.box = "precise64"
config.vm.box_url = "http://files.vagrantup.com/precise64.box"
config.vm.host_name = "djangocore"
config.vm.customize ['modifyvm', :id, '--memory', '2048']
config.ssh.forward_agent = true
# Shared folders... |
class Step < ApplicationRecord
has_many :drink_steps
has_many :drinks, through: :drink_steps
end
|
json.array!(@customer_service_item_ships) do |customer_service_item_ship|
json.extract! customer_service_item_ship, :id, :customer_id, :service_item_id
json.url customer_service_item_ship_url(customer_service_item_ship, format: :json)
end
|
class CreateContentContainers < ActiveRecord::Migration
def change
create_table :content_containers do |t|
t.integer :containable_id
t.string :containable_type
t.string :origin_type
t.string :src
t.text :meta
t.text :body
t.timestamps
end
add_index :conte... |
require 'io/console'
require 'yaml'
$data = YAML.load_file('../data/log.yaml')
###Creates list of programs using yaml keys###
key_list = Array.new
value_list = Array.new
$data.each_pair do |key, value|
key_list.push(key)
value_list.push(value)
end
###Gets log file from yaml###
def choose_log(choice)
$data.each... |
class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
def find_total
current_user.order.find_by(bought: false).total_conversion
end
def find_product
Product.f... |
# 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 rails db:seed command (or created alongside the database with db:setup).
#
# Examples:
#
secret = SecretCode.create({code: 'ADMIN'})
user = User.new({first_name: 'Admin', la... |
class AddActiveToProjects < ActiveRecord::Migration[5.1]
def change
add_column :projects, :hours_active, :boolean, default: false, null: false
add_column :projects, :site_active, :boolean, default: false, null: false
add_column :projects, :description_about_the_company, :text
add_column :projects, :de... |
class Hyper < Formula
desc "HTTP implementation for Rust"
homepage "https://github.com/hyperium/hyper"
url "https://github.com/hyperium/hyper/archive/v0.14.11.tar.gz"
sha256 "7b7ee07159843386f8489cacb3083f28b76bd604c36d0f5f5e7a34c6e2fd5f78"
head "https://github.com/hyperium/hyper.git"
depends_on "rust" => ... |
# transferred -> Impuestos trasladado
# detained -> Impuestos retenidos
# tax -> Nombre del Impuesto
# rate -> Tasa
# import -> Importe
#
module MCFDI
class Taxes < Base
attr_accessor :transferred, :detained
def initialize
@transferred = []
@detained = []
end
# return total of all trans... |
module Chanko
module Invoker
def self.included(obj)
obj.class_eval do
include InstanceMethods
mattr_accessor :defined_blocks
attr_accessor :attached_unit_classes
attr_accessor :__current_function
end
end
def method_missing(method_symbol, *args)
if block... |
require 'rails_helper'
RSpec.describe LineItemVisitsImporter do
it 'should inherit from DependentObjectImporter' do
line_item = double('line_item')
line_item_visits_importer = LineItemVisitsImporter.new(line_item)
expect(line_item_visits_importer).to be_a(DependentObjectImporter)
ex... |
# frozen_string_literal: true
class Comment < ApplicationRecord
belongs_to :post
belongs_to :user
has_many :commentlikes, dependent: :destroy
validates :text, presence: true
enum publishing_policy: { unlimited: 1, friend_limited: 2, self_limited: 3 }
def add_like(user)
commentlikes.create(user_id: ... |
class TweetsController < ApplicationController
def index
@tweets=Tweet.all
end
def new
end
def create
Tweet.create(tweet_params)
end
private
def tweet_params
params.permit(:name, :text, :image)
end
end
|
class AddLiberacaoFalta < ActiveRecord::Migration
def self.up
add_column :liberacao_etapas, :tipo_etapa, :string, :size => 1
end
end |
require_relative '../../spec_helper'
require_relative '../../../robot_app/models/robot'
require_relative '../../../robot_app/models/position'
require_relative '../../../robot_app/models/playground'
module RobotApp::Models
describe Robot do
describe :initialize do
before :each do
allow(RobotApp::C... |
class CoberturaVisitaInfinita
LIMITE = 1000
attr_accessor :cantidad, :copago
def initialize(copago)
raise PlanSinCopagoError if copago.nil?
raise PlanCopagoInvalido if copago.negative?
@cantidad = LIMITE
@copago = copago
end
def aplicar(visitas)
visitas.map do |visita|
visita.cos... |
require 'directory-TDD'
describe 'student directory' do
before(:each) do
allow(self).to receive(:puts)
end
let (:student) {{name: "Nicola", cohort: "June", nationality: "UK"}}
context 'prints out required text' do
it 'prints header' do
header = "The students of my cohort at Makers Academy\n=========... |
ActiveAdmin.register Comment do
permit_params :user_id, :photo_id, :content
includes :user, :photo
index do
selectable_column
id_column
column :content
column :user
column :photo
actions
end
filter :content
filter :user
filter :photo
form do |f|
f.inputs "Comment Details" ... |
class Contact < ActiveRecord::Base
validates :email, :uniqueness => {:scope => :user_id }
validates :name, :email, :user_id, presence: true
belongs_to :owner,
foreign_key: :user_id,
class_name: "User"
has_many :contact_shares
has_many :shared_users,
through: :contact_shares,
source: :user
... |
class AddFamilyIdToArchivedStudent < ActiveRecord::Migration
def self.up
add_column :archived_students, :family_id, :integer
end
def self.down
remove_column :archived_students, :family_id
end
end
|
module Drupal
class SessionStore
def self.stub(login)
self.class_eval <<-EOS
def initialize_with_stubbing(session, options = {})
user = Drupal::User.find_or_create_by_name("#{login}")
user.update_attributes!(:status => 1)
Drupal::Session.find_or_create_by_sid_and_ui... |
require 'csv'
require 'open-uri'
require 'nokogiri'
class Team
attr_accessor :location, :mascot
def initialize(row)
@location = row['location']
@mascot = row['name']
end
def name
[location, mascot].join ' '
end
end
team_data = CSV.open './data/teams.csv', headers: true
teams = team_data.map { ... |
class RegistrationsController < ApplicationController
def new
end
def create
@user = User.new(registration_params)
if @user.save
flash[:notice] = 'User was successfully registered.'
redirect_to root_url
else
flash[:notice] = "Error: "+@user.errors.messages.to_s
redirect_to :registrations
... |
Vagrant.configure(2) do |config|
(1..3).each do |i|
config.vm.define "node-#{i}" do |node|
node.vm.box = "puppetlabs/debian-7.6-64-puppet"
node.vm.hostname = "node-#{i}"
node.vm.network "private_network", ip: "172.16.0.#{i}"
node.vm.provision "puppet" do |puppet|
puppet.module_path = "m... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.