text stringlengths 10 2.61M |
|---|
class AuditProblem::MissingTopic < AuditProblem::Base
field :publication_date, :type => Date
field :entries_with_topics_count, :type => Integer
def self.run(options={})
problems = []
Entry.find_by_sql("select count(*) AS num_entries_with_topics, entries.publication_date
from entries
join topic_assignments... |
module Githubber
class PullRequests
include HTTParty
base_uri "https://api.github.com"
def initialize(auth_token)
@auth = {
"Authorization" => "token #{auth_token}",
"User-Agent" => "HTTParty"
}
end
def pull_request(owner, repo, number)
PullRequests.get("/repos/#{owner}/#{repo}/pulls/... |
# interface for users to display what our app does
require "colorize"
def logo
a = Artii::Base.new :font => 'rowancap'
a.asciify(' GIF A CAT').colorize(:light_red)
end
#----------------------SCREEN PRINT MESSAGES-----------------------
def welcome
puts " ______________________________________________".light_... |
module ReservationHelper
def self.all_dates
start = DateTime.now.beginning_of_day + 10.hour + 1.day
stop = DateTime.now.beginning_of_day + 15.hour + 1.day
time_range = start..stop
result = []
current_time = time_range.first
until current_time == time_range.last + 1.hour
result << current... |
class Company < ApplicationRecord
validates :name, presence: true,
length: { minimum: 2 }
validates :plan_level, inclusion: { in: %w(legacy custom basic plus growth
enterprise) }
has_many :lessons
end
|
# frozen_string_literal: true
require "kafka/protocol/message_set"
require "kafka/protocol/record_batch"
module Kafka
module Protocol
# A response to a fetch request.
#
# ## API Specification
#
# FetchResponse => ThrottleTimeMS [TopicName [Partition ErrorCode HighwaterMarkOffset LastStableO... |
# encoding: utf-8
#! /usr/bin/env ruby
##
#25/02/2014
#Projet Picross équipe CrakeTeam
#
#Ce fichier contient la classe Case, brique de base du jeu
#ici une description de la classe Case.
class Case
@etat
# Variable représentant l'état, un entier qui indique si la case a été noircie, cochée/marquée ou laissée bla... |
class AddResetToUsers < ActiveRecord::Migration[5.0]
def up
add_column :users, :reset_digest, :string
add_column :users, :reset_sent_at, :datetime
end
def down
end
end
|
require 'my_shows/the_pirate_bay_client'
module MyShows
class Episode
MAPPING_SHOW_NAMES = Hash.new { |hash, key| hash[key] = key }
MAPPING_SHOW_NAMES['Avatar: Legend of Korra'] = 'The Legend Of Korra'
@@jarow = FuzzyStringMatch::JaroWinkler.create(:native)
@@tracker = ThePirateBayClient.new
... |
class CreateTimesheets < ActiveRecord::Migration
def change
create_table :timesheets do |t|
t.integer :project_master_id
t.integer :project_task_id
t.integer :user_id
t.date :task_date
t.float :task_time
t.timestamps null: false
end
end
end
|
xml.page do
xml.title("WhereSay")
xml.link(here_path(:only_path => false))
xml.description("Tweets near #{@location[:lng]}, #{@location[:lat]}")
xml.content do
for tweet in @tweets
xml.text(tweet.text)
end
end
end
|
require 'open-uri'
class MrlParser
COLUMN_SEPARATOR = '<MRL_COL_END>'.freeze
ROW_SEPARATOR = '<MRL_ROW_END>'.freeze
attr_reader :headers
def initialize(header_row)
@headers = extract_headers header_row
end
def self.foreach(resource, &block)
parser = nil
resource.split(ROW_SEPARATOR).each do ... |
class AddCourseIdToCourseSubject < ActiveRecord::Migration
def self.up
add_column :course_subjects, :course_id, :integer
add_index :course_subjects, [:course_id]
end
def self.down
remove_column :course_subjects, :course_id
remove_index :course_subjects, [:course_id]
end
end |
# 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 =>... |
class Product < ApplicationRecord
# Relationships
has_and_belongs_to_many :orders
# Validations
validates_presence_of :name, :description, :price
end
|
class SessionsController < ApplicationController
before_action :require_no_user!
def new
render :new # creating the login form / rendering login page - register (sign up) page
end
def create # actually logs in the person
user = User.find_by_credentials(params[:user][:username], params[:user][:password]... |
module OrientdbBinary
module BaseProtocol
class DataclusterCount < BinData::Record
include OrientdbBinary::BaseProtocol::Base
endian :big
int8 :operation, value: OrientdbBinary::OperationTypes::REQUEST_DATACLUSTER_COUNT
int32 :session
int16 :cluster_count
array :cluster_ids... |
class Pokemon
attr_accessor :id, :name, :type, :hp, :db, :hp
def initialize(id:, name:, type:, db:, hp: 60)
@id, @name, @type, @db, @hp = id, name, type, db, hp
end
def self.save (name, type, database_connection)
database_connection.execute("INSERT INTO pokemon (name, type) VALUES (?, ?)",name, type)
end... |
require 'rails_helper'
RSpec.describe '/backend/graphql' do
let(:base_path) { '/backend/graphql' }
let(:query_string) { URI.encode('query={hello}') }
let(:parsed_response_body) { JSON.parse(response.body) }
before(:each) do
get "#{base_path}?#{query_string}"
end
it { expect(parsed_response_body).to ... |
# Load the module files.
require 'httparty'
require 'pp'
# Class that implements the "HTTP API" to "http://food2fork.com/api".
#
# It is responsible for representing business data and logic.
class Recipe
# Embed module in the class; import the "HTTParty" mixin.
include HTTParty
# Define a "base_uri" to use "htt... |
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
helper_method :logged_in?,:current_user
# rescue_from Exception,with: :error500
# rescue_from ActiveRecord::RecordNotFound,ActionController::RoutingError,with: :error404
private
def logged_in?
!!session[:user... |
class CreateMatches < ActiveRecord::Migration[5.2]
def change
create_table :matches, id: :uuid do |t|
t.datetime :starts_at
t.jsonb :casters
t.jsonb :data
t.uuid :away_team_id, null: false
t.uuid :home_team_id, null: false
t.uuid :loser_id
t.uuid :wi... |
## To start the database
##
## Database manipulation
## buildr eaa:start_database
## buildr eaa:stop_database
## buildr eaa:delete_database
repositories.remote << 'http://repo1.maven.org/maven2'
SERVLET = 'javax.servlet:servlet-api:jar:2.5'
HSQLDB = 'org.hsqldb:hsqldb:jar:2.3.2'
SQLTOOL = 'org.hsqldb:sqltool:j... |
require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'
require 'micronaut'
require 'micronaut/rake_task'
begin
require 'jeweler'
files = ["CHANGELOG", "LICENSE", "Rakefile", "README.rdoc", "VERSION.yml"]
files << Dir["examples/**/*", "laf/**/*", "lib/**/*", "tasks/**/*", "template/**/*"]
Jeweler::Ta... |
module Nipap
class Base
# Define methods that retrieve the value from an initialized instance variable Hash, using the attribute as a key
#
# @param attrs [Array, Set, Symbol]
def self.attr_reader(*attrs)
mod = Module.new do
attrs.each do |attribute|
define_method attribute do... |
#--------------------------------------------------------------------------
# Enemy Turn Count Fix
# Author(s):
# Lone Wolf
#--------------------------------------------------------------------------
# By default, enemy actions are determined at the start of the round but
# before the turn counter is increased. This m... |
class UserMailer < ActionMailer::Base
default from: "money@example.com"
def new_follower(follower, followed)
@follower = follower
@followed = followed
mail(to: @followed.email, subject: "You have a new follower!")
end
def password_reset(user)
@user = user
mail to: @user.email, subject: 'Pas... |
describe 'somar' do
context 'dois numeros' do
let(:resultado) {4 + 4}
#voce pode usar varios lets
let(:resultado1) {resultado + 4}
let(:resultado2) {4 + 4}
it 'does something' do
expect(resultado).to eq 8
expect(resultado1).to eq 12
end
e... |
class CreateBodies < ActiveRecord::Migration
def change
create_table :bodies do |t|
t.references :body_type, index: true
t.string :name
t.integer :position_from_sun
t.decimal :relative_diameter
t.integer :mass
t.integer :au_from_sun
t.integer :moons, default: 0
t.bo... |
class CreateCryptos < ActiveRecord::Migration[6.0]
def change
create_table :cryptos do |t|
t.string :name
t.float :buy_price
t.float :spot_price
t.float :sell_price
t.timestamps
end
end
end
|
# Use this file to easily define all of your cron jobs.
#
# It's helpful, but not entirely necessary to understand cron before proceeding.
# http://en.wikipedia.org/wiki/Cron
env :PATH, ENV['PATH']
env :GEM_PATH, ENV['GEM_PATH']
set :output, 'log/cron_log.log'
set :environment, ENV['RAILS_ENV'] || 'development'
ever... |
=begin
#qTest Manager API Version 8.6 - 9.1
#qTest Manager API Version 8.6 - 9.1
OpenAPI spec version: 8.6 - 9.1
Generated by: https://github.com/swagger-api/swagger-codegen.git
=end
require "uri"
module SwaggerClient
class TestcaseApi
attr_accessor :api_client
def initialize(api_clien... |
require "spec_helper"
feature "Signing up for an account" do
scenario "from the sign up page" do
user = login_as_tenant(
password: "password",
password_confirmation: "password"
)
visit edit_user_registration_path
fill_in "First name", with: "Oscar"
fill_in "Last name", with: "#{user.... |
require "application_system_test_case"
class SongInfosTest < ApplicationSystemTestCase
setup do
@song_info = song_infos(:one)
end
test "visiting the index" do
visit song_infos_url
assert_selector "h1", text: "Song Infos"
end
test "creating a Song info" do
visit song_infos_url
click_on "... |
require 'minitest/autorun'
require 'rack/test'
require_relative './mock-client'
class MockClientSpec < MiniTest::Test
include Rack::Test::Methods
def setup
MockClient.requests = []
end
def test_post
assert_equal 0, MockClient.requests.length
MockClient.post(
'https://google.com',
'b... |
require './db/setup'
describe '#search_by_day' do
it "should return Thursday shows" do
STDIN.stub(:gets).and_return("")
require_relative '../watchman'
shows = search_by_day('Thursday').map { |show| show.name }
expect(shows).to eq(['Community','Homeland'])
end
end
|
# == Schema Information
#
# Table name: campaigns
#
# id :integer not null, primary key
# name :string
# created_at :datetime not null
# updated_at :datetime not null
# description :text
# donation_deadline :date
# reminder_date :date
#... |
# encoding: utf-8
module Nls
class Package
attr_reader :id
attr_reader :slug
attr_accessor :default_glue_distance
attr_accessor :default_keep_order
def initialize(slug, opts = {})
@slug = slug
# default values
opts[:id] = UUIDTools::UUID.timestamp_create if !opts.has_key?(:i... |
namespace :onetime do
desc "copy detours to guidedtours"
task :guidedtours => :environment do
query1 = 'CREATE TABLE guidedtours LIKE detours'
ActiveRecord::Base.connection.execute(query1)
query2 = 'INSERT INTO guidedtours SELECT * FROM detours'
ActiveRecord::Base.connection.execute(query2)
end
... |
module Vcloud
module Core
module MetadataHelper
def extract_metadata vcloud_metadata_entries
metadata = {}
vcloud_metadata_entries.each do |entry|
next unless entry[:type] == Vcloud::Core::Fog::ContentTypes::METADATA
key = entry[:Key].to_sym
val = entry[:TypedV... |
module KnuckleCluster
class Task
def initialize(
arn:,
container_instance_arn:,
agent:,
definition:,
name:,
task_registry:
)
@arn = arn
@container_instance_arn = container_instance_arn
@agent = agent
@definition = definition
@name = name
... |
json.work_experiences do |work_exp|
json.array! @experiences do |work_exp|
json.id work_exp.id
json.company_name work_exp.company_name
json.job_title work_exp.job_title
json.job_functions work_exp.job_functions
json.job_description work_exp.job_description
json.employ... |
require 'rails_helper'
RSpec.describe Admin::MedifastVideosController, type: :controller do
render_views
let(:resource_class) { MedifastVideo }
let(:all_resources) { ActiveAdmin.application.namespaces[:admin].resources }
let(:resource) { all_resources[resource_class] }
let(:page) { Capybara::Node::Si... |
class ProcessEntitiesController < ApplicationController
before_action :set_process_entity, only: [:show, :edit, :update, :destroy,
:simple]
# GET /process_entities
# GET /process_entities.json
def index
@process_entities = ProcessEntity.all
end
# GET /process_entitie... |
class DestroyActorView
def render(actor)
if actor.nil?
view = ActorNotFound.new
view.render
else
actor.delete
puts "You have deleted #{actor.name} from your database"
end
end
end |
module Merchant
class MerchantParentCategory < ActiveRecord::Base
attr_accessible :merchant_store, :parent_category
validates_presence_of :merchant_store, :parent_category
belongs_to :merchant_store
belongs_to :parent_category, :class_name => Merchant::Baseinfo::ParentCategory
end
end
|
FactoryBot.define do
factory :detail do
factory :detail_kirk do
tracking_no { 6502 }
employee_number { 1701 }
employee_name { "Jim Kirk" }
employee_rank { 3 }
customer_number { 42 }
customer_name { "Utopia Planitia" }
street_no { 23 }
street { "Elm" }
xstreet ... |
class ChangeVerifiedDefault < ActiveRecord::Migration[5.0]
def up
change_column :users, :verified, :boolean, default: false
end
def down
change_column :users, :verified, :boolean, default: nil
end
end
|
# 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... |
class CreatePatientListPatients < ActiveRecord::Migration
def change
create_table :patient_list_patients do |t|
t.integer :patient_list_id
t.integer :patient_id
t.timestamps null: false
end
add_index :patient_list_patients, :patient_list_id
add_index :patient_list_patients, :patient... |
require 'spec_helper'
RSpec.describe Bsale::DteCode do
before do
Bsale.configure do |config|
config.access_token = ENV['BSALE_KEY']
end
end
context '#new' do
it 'returns an instance class' do
dte_code = described_class.new
expect(dte_code).to be_a_kind_of(described_class)
end
... |
class Post < ApplicationRecord
belongs_to :student
belongs_to :topic
end
|
class ReviewsController < ApplicationController
before_action :logged_in_user, only: %i(new update edit)
before_action :load_review, only: %i(show update edit)
before_action :check_liked, only: :show
def show
@comment = Comment.new
@comments = Comment.includes(:user).select_comments(params[:id])
... |
# 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 'json'
class Field
attr_accessor :name, :type
def initialize(name,type)
self.name = name
self.type = type
end
end
class Table
attr_accessor :name
attr_accessor :fields
def initialize(name)
self.name = name
end
end
class Article < Table
def initialize
super "Article_#{ARGV[0]}"
self.... |
class HeroStatistics
attr_reader :name, :wins, :losses
def initialize(name, wins, losses)
@name = name
@wins = wins
@losses = losses
end
def add(hero)
@wins += hero.wins
@losses += hero.losses
end
def games
return @wins + @losses
end
def winRatio
return @wins.to_f / games... |
class Review < ActiveRecord::Base
belongs_to :spot
belongs_to :visitor, :class_name => 'User'
has_one :owner, :class_name => 'User', :through => :spot
def self.max_stars
5
end
def blank_stars
Review.max_stars - self.rating
end
end
|
require 'formula'
class Bissnp < Formula
homepage 'http://sourceforge.net/projects/bissnp'
version '0.82.2'
url 'http://sourceforge.net/projects/bissnp/files/BisSNP-0.82.2.jar'
sha1 'c3c0a48070675fda1d3dd4b7bc239876113cad77'
def install
java = share / 'java' / 'bissnp'
java.install Dir['*.jar']
... |
class CreateMatches < ActiveRecord::Migration
def change
create_table :matches do |t|
t.references :championship, index: true, null: false
t.integer :bracket, null: false
t.integer :player1_id
t.integer :player2_id
t.references :game, index: true
t.integer :winners_match_id
... |
class ApplyNow < ActiveRecord::Base
belongs_to :category
validates :headline, presence: true, length: { maximum: 50 }
validates :button_text, length: { maximum: 15 }
validates :button_url, presence: true
end
|
class PagesController < ApplicationController
skip_before_action :authenticate_user!, only: [ :home ]
def home
@spaces = Space.where.not(latitude: nil, longitude:nil)
@markers = @spaces.geocoded.map do |space|
{
lat: space.latitude,
lng: space.longitude,
info_window: render_to... |
# -*- encoding : utf-8 -*-
class RemoveUserNameIndex < ActiveRecord::Migration
def change
remove_index(:users, column: :name)
end
end
|
# -*- encoding: utf-8 -*-
require File.expand_path('../lib/motion-awesome/version.rb', __FILE__)
Gem::Specification.new do |gem|
gem.name = 'motion-awesome'
gem.version = MotionAwesome::VERSION
gem.authors = ['Fernand Galiana']
gem.email = ['fernand.galiana@gmail.com']
gem.summar... |
class AddUniquenessToQuestionTags < ActiveRecord::Migration
def change
add_index :question_tags, [:question_id, :tag_id], unique: true
end
end
|
class UserSerializer
include FastJsonapi::ObjectSerializer
attributes :name, :email, :closet_id
attribute :closet do |object|
ClosetSerializer.new(object.closet)
end
end
|
INSTRUCTION_MATCHER = /(?<instruction>\w+) (?<value>\d+)/
INSTRUCTIONS = INPUT.split("\n").map do |line|
match = line.match(INSTRUCTION_MATCHER)
[match[:instruction].to_sym, match[:value].to_i]
end.freeze
x = 0
y = 0
INSTRUCTIONS.each do |instruction, value|
case instruction
when :forward then x += value
wh... |
class UsersController < ApplicationController
before_filter :load_user, :only => [:show]
def show
@all_stanzas = Stanza.by_user(@user).order('title ASC')
@all_stanzas = @all_stanzas.public.published unless current_user == @user
end
private
def load_user
begin
@user = User.find(params[:... |
# frozen_string_literal: true
require 'sidekiq/api'
module Sidekiq
module Instrumental
module Middleware
# Shared base code for measuring stats for server and client sidekiq
class Base
attr_reader :config
def initialize(config)
@config = config
end
def cal... |
module FlickrHelper
def user_photos(user_id, photo_count = 12)
FlickRaw.api_key = File.read("config/flickr.yml").split[1]
FlickRaw.shared_secret = File.read("config/flickr.yml").split[3]
flickr.photos.search(:user_id => user_id).to_a.map(&:to_hash).values_at(0..(photo_count-1))
end
def render_flickr_sid... |
class Event < ApplicationRecord
belongs_to :user
has_many :rehearsals, dependent: :destroy
validates :name, :venue, presence: true
end
|
class Site < ActiveRecord::Base
has_many :urls#, :dependent => :destroy
validates :site_name, presence: true, uniqueness: true
scope :site_select, -> sites {
where(id: sites) if sites.present?
}
end
|
module Cli
class Distribution < Thor
include Formattable
desc "ls", "List available distributions"
option :raw, type: :boolean, default: false
def ls
puts Api::Distribution.list(format)
end
end
end
|
require 'spec_helper'
describe "admin_people/new.html.erb" do
before(:each) do
assign(:admin_person, stub_model(AdminPerson,
:UserID => 1,
:lessonID => 1
).as_new_record)
end
it "renders new admin_person form" do
render
# Run the generator again with the --webrat flag i... |
require 'rails'
module Alchemy
# Utilities for Alchemy's mount point in the host rails app.
#
class MountPoint
MOUNT_POINT_REGEXP = /mount\sAlchemy::Engine\s=>\s['|"](\/\w*)['|"]/
class << self
# Returns the path of Alchemy's mount point in current rails app.
#
# @param [Boolean] rem... |
require 'rspec'
require_relative '../lib/board'
describe Board do
let(:small_board){ [ ['X','X','X'],
['0','0','0'] ] }
let(:small_board_transposed){ [ ['X','0'],
['X','0'],
['X','0'] ] }
let(:hor... |
# frozen_string_literal: true
module Decidim
module Opinions
# A command with all the business logic when a user updates a collaborative_draft.
class UpdateCollaborativeDraft < Rectify::Command
include HashtagsMethods
# Public: Initializes the command.
#
# form - A form objec... |
class Message < ActiveRecord::Base
belongs_to :user
#user_id:接收消息的用户的id
#messagetype定义:
#0:未定义
#1:帖子新评论
#2:评论回复
#3:用户入队申请
#4:加入队伍邀请
#5:@
#6:私信
#content:根据消息类别不同的消息内容的id
#1:评论id
#3:申请入队用户id
#4:发邀队伍id
#5:被@的评论id
#6:发信人id
#read:是否已读
#text:附加信息
#6:信息内容
end
|
class MylistDetailsController < ApplicationController
# GET /mylist_details
# GET /mylist_details.json
def index
@mylist_details = MylistDetail.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @mylist_details }
end
end
# GET /mylist_details/1
# GET... |
class PieceHistoricSituation < ActiveRecord::Base
belongs_to :piece
belongs_to :user
belongs_to :observation
belongs_to :old_piece_situation, :class_name => 'PieceSituation'
belongs_to :new_piece_situation, :class_name => 'PieceSituation'
validates_presence_of :user_id, :piece_id, :old_piece_situation_id, :new_p... |
class CreateNewTablesForNormalisation < ActiveRecord::Migration
def self.up
rename_table :employments, :person_employment_status
end
def self.down
rename_table :person_employment_status, :employments
end
end
|
class ProjectsController < ApplicationController
before_action :set_project, only: [:show, :edit, :update, :destroy]
before_action :authenticate_user!
before_action :check_membership!, only: [:show, :edit, :update, :destroy]
def index
#as projects have many users through memberships, i can use user.projects
... |
# == Schema Information
#
# Table name: users
#
# id :integer not null, primary key
# name :string
# email :string
# created_at :datetime not null
# updated_at :datetime not null
# password_digest :string
#
class User < ActiveRecord::Base
bef... |
class CreateChangeLogs < ActiveRecord::Migration[5.2]
def change
create_table :change_logs do |t|
t.belongs_to :subscription, index: true
t.string :event_id
t.string :change_type
t.timestamps null: false
end
end
end
|
class RemoveTotalFromBankRegisters < ActiveRecord::Migration
def change
remove_column :bank_registers, :total
end
end
|
class SectionsController < ApplicationController
before_action :set_section, only: [:show, :edit, :update]
before_action :authenticate_instructor!
before_action :require_same_instructor, except: [:show]
def index
@course = Course.find(params[:course_id])
@sections = @course.sections
end
def new
@c... |
require 'spec_helper'
describe "events/index" do
before(:each) do
assign(:events, [
stub_model(Event,
:name => "Name",
:place => "Place",
:image => "Image",
:url => "Url"
),
stub_model(Event,
:name => "Name",
:place => "Place",
... |
# Copyright 2014 Square Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed ... |
require 'uri'
require 'net/https'
require 'cassy/models'
require 'cassy/utils'
# Encapsulates CAS functionality. This module is meant to be included in
# the Cassy::Controllers module.
module Cassy
module CAS
class Error
attr_reader :code, :message
def initialize(code, message)
@code =... |
class AddGradeAndBirthdateToStudents < ActiveRecord::Migration[5.2]
def change
add_column :students, :grade, :integer
add_column :students, :birthdate, :string
end
end
#Active Record Method add_column
# grade column integer, birthdate column string,
|
class CreateDailyFoods < ActiveRecord::Migration[5.0]
def change
create_table :daily_foods do |t|
t.integer :daily_id
t.integer :food_id
t.integer :price
t.text :review
t.integer :star
t.integer :user_id
t.timestamps
end
end
end
|
class NiftyAuthenticationsController < ApplicationController
# GET /nifty_authentications
# GET /nifty_authentications.xml
def index
@nifty_authentications = NiftyAuthentication.all
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @nifty_authentications }
e... |
require 'rake/clean'
require 'redcarpet'
CLOBBER.include('site')
def markdown_convert(source_file, dest_file)
markdown = Redcarpet::Markdown.new(
Redcarpet::Render::XHTML,
autolink: true)
html = markdown.render(open(source_file).read)
open(dest_file,'w').print(html)
end
directory 'site'
MARKDOWN_FILES... |
class User < ApplicationRecord
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable, :validatable, :recoverable
devise :database_authenticatable, :registerable,
:rememberable, :trackable, :omniauthable
has_one :family_membership
has_one :family, through: :... |
class AddIndexToFridgeFriends < ActiveRecord::Migration
def change
add_index :fridge_friends, [:user_id, :friend_id]
end
end
|
require "spec_helper"
require_relative '../lib/mediatype_directory/mediatype_directory'
# Overriding FakeFS' File.expand_path
# because it delegates to the same class
# method in the REAL file system
module FakeFS
class File
def self.expand_path(*args)
args[0].gsub(/~/,'/home/xavier')
end
end
# Sta... |
#
# Author:: Matt Eldridge (<matt.eldridge@us.ibm.com>)
# © Copyright IBM Corporation 2014.
#
# LICENSE: MIT (http://opensource.org/licenses/MIT)
#
Shindo.tests("Fog::Compute[:softlayer] | Server model", ["softlayer"]) do
pending unless Fog.mocking?
tests("success") do
vm_opts = {
:flavor_id => 'm1.sm... |
class ProfileController < ApplicationController
before_filter :authenticate_user!, :except => [:public_profile, :index]
before_filter :find_user, :except => [:public_profile, :index]
layout "public"
def index
@users = User.all
end
def profile
@first_time_in_profile = (@user.signing_up? and @user.a... |
class CardTemplate < ActiveRecord::Base
has_many :card_attributes, dependent: :destroy
has_many :cards, dependent: :destroy
end
|
class Game < ActiveRecord::Base
has_many :posts
def to_s
name
end
def games_picture
fetch_games_picture || "http://placehold.it/600x500"
end
def fetch_games_picture
game = name.gsub(/[ ':]/, '-').downcase
pvs1 = "plants-vs-zombies-garden-warfare-2e561d33-2b92-408a-92f2-ec79ddcc6c2b"
diablo3 = "di... |
require 'rails_helper'
RSpec.describe Product, type: :model do
let(:product) { build(:product) }
describe "product name validation" do
context "when product name is empty" do
it "is invalid" do
product.product_name = ""
expect(product).to be_invalid
expect(product.errors[:product... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.