text stringlengths 10 2.61M |
|---|
class Score < ApplicationRecord
belongs_to :user
belongs_to :review
validates_presence_of :user
validates_presence_of :review
#add int constraint for review_score
end |
require 'spec_helper'
%w[render_serializer have_rendered_serializer].each do |serializer_expectation|
describe serializer_expectation do
let(:response) { ActionController::TestResponse.new }
context 'given a hash' do
it 'delegates to assert_serializer' do
expect(self).to receive(:assert_serial... |
require 'spec_helper'
module Refinery
module Caststone
describe Product do
let(:product){FactoryBot.create(:product, name: 'Refinery CMS')}
describe "validations" do
context "when created with required fields" do
it "is a valid object" do
expect(product).to be... |
class ApplicationController < ActionController::Base
protect_from_forgery except: :create
rescue_from StandardError do |e|
render json: {error: "Internal Server Error"}, status: 500
end
end
|
class Backend::DashboardsController < ApplicationController
before_action :authenticate_admin!
layout 'backend_layout'
def index
@welcome_msg = "Welcome to backend"
end
end
|
# This file contains the fastlane.tools configuration
# You can find the documentation at https://docs.fastlane.tools
#
# For a list of all available actions, check out
#
# https://docs.fastlane.tools/actions
#
# For a list of all available plugins, check out
#
# https://docs.fastlane.tools/plugins/available-pl... |
class AddExtremaBetField < ActiveRecord::Migration
def up
add_column :predictions, :is_extreme_bet, :boolean, :default => false
end
def self.down
remove_column :predictions, :is_extreme_bet
end
end
|
class AddProfileToPayments < ActiveRecord::Migration[5.1]
def change
add_reference :payments, :profile, foreign_key: true
end
end
|
#!/usr/bin/ruby
require 'pry'
tape =
Hash[
*
"
children: 3
cats: 7
samoyeds: 2
pomeranians: 3
akitas: 0
vizslas: 0
goldfish: 5
trees: 3
cars: 2
perfumes: 1
"
.gsub(/:/, '')
.split
.map.with_index(1) do |e, i|
(i % 2).zero? ? e.... |
module Cultivation
class QueryBatchStageLocation
prepend SimpleCommand
def initialize(batch, phase)
@batch = batch
@phase = phase
end
def call
plan = ::Cultivation::TrayPlan.find_by(
batch_id: @batch.id,
phase: @phase,
)
if plan.present?
tray = :... |
FactoryGirl.define do
factory :idea do
title { Faker::Lorem.words(4) }
description { Faker::Hacker.say_something_smart }
end
end
|
# frozen_string_literal: true
require 'evss/response'
module EVSS
module PCIU
class PhoneNumberResponse < EVSS::Response
attribute :country_code, String
attribute :number, String
attribute :extension, String
attribute :effective_date, String
def initialize(status, response = nil)
... |
class PlaylistSong < ApplicationRecord
belongs_to :playlist
belongs_to :song
validates_presence_of :index
after_save :update_playlist
scope :index_asc, ->{order index: :asc}
private
def update_playlist
playlist.update updated_at: Time.now
end
end
|
class ShopProduct < ActiveRecord::Base
belongs_to :shop, :counter_cache => true
belongs_to :product, :counter_cache => true
has_many :product_orders,:dependent => :delete_all
validates_presence_of :name
validates_presence_of :url
# validates_presence_of :content
validates_presence_of :shop_id
valid... |
class Post < ActiveRecord::Base
validates :title, presence: true
validates :content, presence: true
acts_as_taggable
belongs_to :user
def author_date
self.created_at.strftime("%d %m %Y")
end
def preview
content[0..25] + "..."
end
end
|
class InitializeCmsGenerator < Rails::Generators::Base
source_root File.expand_path('../templates', __FILE__)
def copy_files
copy_file 'helpers/webinius_cms/pages_helper.rb', 'app/helpers/webinius_cms/pages_helper.rb'
copy_file 'views/layouts/webinius_cms/sites.html.erb', 'app/views/layouts/webinius_cms/si... |
class CreateDiagnoses < ActiveRecord::Migration[6.0]
def change
create_table :diagnoses do |t|
t.string :coding_system
t.string :code
t.text :description
t.references :owner, polymorphic: true
t.timestamps
end
end
def down
drop_table :diagnoses
end
end
|
class AddGorodasortToAllsettings < ActiveRecord::Migration
def change
add_column :allsettings, :gorodasort, :integer
end
end
|
class UserMailer < ActionMailer::Base
default from: "info@satak.in"
def token_email(user)
@user = user
@token = @user.current_token
mail(to: @user.email, subject: 'Your Token Key ' )
end
end
|
# frozen_string_literal: true
module Boring
module Twilio
class InstallGenerator < Rails::Generators::Base
desc "Adds Twilio to the application"
source_root File.expand_path("templates", __dir__)
def add_twilio_ruby_gem
say "Adding Twilio gem", :green
Bundler.with_unbundled_env... |
module MapUtil
def self.tiles(node, selector)
# 'visible: false' because leaflet fails to load the tiles and therefore keeps them hidden
node.all("#{selector} img.leaflet-tile", visible: false)
end
def self.spatial(page)
page.evaluate_script('edsc.models.page.current.query.spatial()')
end
end
RSpe... |
# frozen_string_literal: true
FactoryGirl.define do
factory :lesson do
association :course, strategy: :build
association :time_frame, strategy: :build
end
end
|
require "spec_helper"
require "tempfile"
require "thor"
RSpec.describe Dctl::Main do
describe "#define_custom_commands" do
it "defines a command on the passed class" do
config = <<~CONFIG
org: jutonz
project: dctl_rb
custom_commands:
single: pwd
multiple: ["pwd",... |
class TournamentsController < ApplicationController
before_action :authenticate_user!, :except => [:show, :information]
before_action :find_tournament_and_rating_period_and_player, :only => [:edit, :update, :destroy, :join]
before_action :require_owner!, :only => [:edit, :update, :destroy]
layout 'tournament_t... |
class Api::ListingsController < ApplicationController
def create
@listing = Listing.new(listing_params)
if @listing.save
render json: @listing
else
render json: @listing.errors.full_messages, status: :unprocessable_entity
end
end
def index
render json: Listing.all
end
def sea... |
module Nitron
class StaticTableViewController < ViewController
def setValue(value, forKey: key)
if key == "staticDataSource"
@_dataSource = value
else
super
end
end
def tableView(tableView, didSelectRowAtIndexPath:indexPath)
cell = tableView.cellForRowAtIndexPath(i... |
# 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 MakeAuthorIdNotNull < ActiveRecord::Migration
def up
change_column :posts, :author_id, :integer, :null => false
end
def down
change_column :posts, :author_id, :integer, :null => true
end
end
|
class AddIsDoubleBetColumToMatches < ActiveRecord::Migration
def up
add_column :predictions, :is_double_bet, :boolean, :default => false
end
def self.down
remove_column :predictions, :is_double_bet
end
end
|
class DiscogsClient
def search(artist_name:)
# Empty search for now since we just wanna query for albums by artist
result = discogs_client.search('', :per_page => 20, type: :master, format: 'album', artist: artist_name)
# For some reason,this doesn't raise as a 401. Seems like a bug in their API
if r... |
class AddCategoriesToListings < ActiveRecord::Migration[5.0]
def change
add_column :listings, :categories, :text
add_column :listings, :url, :string
add_column :listings, :project_image, :json
end
end
|
# require gems
require 'sinatra'
require 'sqlite3'
db = SQLite3::Database.new("students.db")
db.results_as_hash = true
# write a basic GET route
# add a query parameter
# GET /
get '/' do
"#{params[:name]} is #{params[:age]} years old."
end
# write a GET route with
# route parameters
get '/about/:person' do
pers... |
class Author < ActiveRecord::Base
has_and_belongs_to_many :positions
def name
firstname + " " + lastname
end
end
|
# frozen_string_literal: true
require "spec_helper"
describe Decidim::Opinions::Permissions do
subject { described_class.new(user, permission_action, context).permissions.allowed? }
let(:user) { opinion.creator_author }
let(:context) do
{
current_component: opinion_component,
current_settings: ... |
require 'rails_helper'
RSpec.describe Admins::CampaignsController, type: :controller do
describe 'POST #create' do
it 'should create campaign' do
http_login
post :create, params: { name: 'New campaign' }
expect(response).to redirect_to(edit_admins_campaign_path(Campaign.first))
expect(Cam... |
class GeoNoteSerializer < ActiveModel::Serializer
attributes :id,
:latitude,
:longitude,
:note_text,
:popularity,
:note_image_url,
:upvoted,
:downvoted
def note_image_url
object.note_image.url
end
def popularity
... |
describe Numeric do
before {
CACHE[:numeric_class] ||= begin
Class.new {
include Datoki
field(:id) { primary_key }
field(:age) { smallint 1, 150 }
... |
require 'pp'
class User
attr_accessor :username, :grant_option
def initialize(attrs)
self.username = attrs.fetch(:username).upcase
self.grant_option = attrs.fetch(:with_grant) { false }
end
def ==(other)
self.username == other.username
end
def eq?(other)
self.username == other.username
... |
# helloメソッドをもつモジュール
module Greeter
def hello
'hello'
end
end
# # 不可
# greeter = Greeter.new
# # これもだめ
# module AwesomeGreeter < Greeter
# end |
require 'rails_helper'
describe "Answer", type: :feature do
let(:user) { User.create!(first_name: "Nando", last_name: "Hasselhoff", email: "nando@example.com", password: "walrus123") }
let(:question) { user.questions.create!(title: "How do I farm goats?", body: "Seriously, though") }
it "displays on a question... |
class Travelport::Model::Price
attr_accessor :currency, :amount
def initialize(price_with_currency=nil)
parse_price(price_with_currency) unless price_with_currency.nil?
end
def parse_price(price_with_currency)
@currency = price_with_currency[0..2]
@amount = price_with_currency[3..-1].to_f
end... |
#!/usr/bin/env ruby
verbose = ARGV.delete("-v")
branch_to_recreate = ARGV.first
raise "Should specify branch to recreate: usage: #{$0} [-v] <branch>" if branch_to_recreate.nil?
require File.expand_path('./kernel_override', File.dirname(__FILE__)) unless verbose.nil?
branches = `git branch`.split("\n")
current_branch... |
# Advent of Code 2019 Day 11 Part Two https://adventofcode.com/2019/day/11#part2
# Space Police: Intcode-driven painting robot
# Provide Intcode input indicating current paint color of panel robot is on,
# Listen for two outputs:
# First a color the robot will paint (0=black, 1=white)
# Next a direction to turn (0=left... |
class User < ActiveRecord::Base
has_secure_password
validates :name, presence: true
validates :email, uniqueness: true
has_many :reviews
has_many :products, through: :reviews
end
|
class Product < ApplicationRecord
belongs_to :category
has_many :carts, dependent: :destroy
has_many :user_feedbacks
belongs_to :users
has_many :rating_reviews
has_many :users, through: :user_feedbacks
ratyrate_rateable "review"
mount_uploader :image, ImageUploader
def display_price
res... |
class VimmerStub
def installed_plugins
bundle_path.entries.map do |entry|
next if entry.to_s =~ /^\.\.?$/
entry = bundle_path.join(entry)
if entry.directory?
entry.split.last.to_s
end
end.compact
end
def plugin_store
if plugin_store_file.exist?
YAML.load_file(... |
module Sunspot
#
# Date facets are retrieved by passing a :time_range key into the
# DSL::FieldQuery#facet options. They are only available for Date and Time
# type fields. The #value for date facet rows is a Range object encapsulating
# the time range covered by the row.
#
class DateFacet < Facet
def... |
require 'rails_helper'
RSpec.describe Item, type: :model do
before do
@user = FactoryBot.create(:user)
@item = FactoryBot.build(:item, user_id: @user.id)
@item.image = fixture_file_upload('public/images/test_image.png')
end
describe '商品の保存ができる場合' do
context "商品が保存できる場合" do
it "必須項目を記入すると商品... |
class Product < ActiveRecord::Base
attr_accessible :description, :image_url, :price, :title
validates :description, :image_url, :title, presence: true
validates :price, numericality: {greater_that_or_equal_to: 0.01}
validates :title, uniqueness: true
validates :title, length: {minimum: 10}
validates :image... |
# frozen_string_literal: true
class Rogare::Commands::My
extend Rogare::Command
command 'my'
usage [
'`!%` - Show yourself!',
'`!% nano <nanoname>` - Register your nano username against your Discord user.',
'`!% tz <timezone e.g. Pacific/Auckland>` - Set your timezone (for counts, goals, etc).'
]
... |
class HomeController < BaseController
layout 'web_v1'
def index
@site_name = "小批量化学品代采代销-网化商城_Whmall.com - whmall.com"
@description = '网化商城是全球领先的小批量化学品B2B交易平台.以代采代销切入用户需求,提供”找原料”、”卖产品”、”AI路线设计”、”实单竞标”等服务,致力于优化供需资源匹配,加快商品流通速度,营造健康的化学品在线交易生态圈.'
@keywords = '小批量,小量,化学品,化工,化工原料,化合物,有机合成,定制合成,海外订单,化学试剂,精细化工... |
class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
layout 'admin'
protect_from_forgery with: :exception
before_action :set_model_partial
before_action :set_this,only: [:show,:new,:edit,:create,:update,:d... |
class Page < ApplicationRecord
extend ActsAsTree::TreeWalker
has_paper_trail only: [:title, :navigation_title, :lead, :content, :notes]
accepts_pasted_images_for :content, :notes
acts_as_tree order: :position, dependent: :restrict_with_error
acts_as_list scope: [:parent_id]
belongs_to :creator, class_nam... |
class AddColumnViaCaracteristic < ActiveRecord::Migration
def change
add_reference :via_caracteristics, :rodovia, index: true
end
end
|
class Answer < ActiveRecord::Base
belongs_to :question
belongs_to :assessment
attr_accessible :value, :correct
def correct?
self.question.correct_choice.letter == self.value.to_s.downcase
end
end
|
module Single
class ExternalIteratorExperiment < BaseExperiment
def run
count = 0
File.open(file) do |file|
while line = file.gets do
count += line.to_i
end
end
count
end
end
end
|
require 'colorize'
require_relative 'cursor'
require_relative 'board'
class Display
attr_reader :board, :cursor
def initialize(board)
@board = board
@cursor = Cursor.new([0, 0], board)
end
def background_color(pos)
if pos == cursor.start_pos
:light_blue
elsif pos == cursor.cursor_pos
... |
class AddSchoolId < ActiveRecord::Migration
def self.up
add_column :app_frames,:school_id,:integer
add_index :app_frames,:school_id
end
def self.down
remove_index :app_frames,:school_id
remove_column :app_frames,:school_id
end
end
|
class ExerciseListsController < ApplicationController
skip_before_action :confirm_authentication
def index
exercise_lists = ExerciseList.all
render json: exercise_lists, each_serializer: ExerciseListSerializer
end
def create
new_exercise = ExerciseList.create(exercise_list_pa... |
describe Rating do
it { should validate_presence_of :number }
it { should belong_to :recipe }
end
|
require 'spec_helper'
describe Post do
it "has a valid factory" do
FactoryGirl.create(:post).should be_valid
end
it "is invalid without a body" do
FactoryGirl.build(:post, body: nil).should_not be_valid
end
it "is invalid with a short body" do
FactoryGirl.build(:post, body: "a").should_not be_val... |
class ProjectsController < ApplicationController
before_action :project, only: [:show, :edit, :update, :destroy]
layout "project", only: [:show, :show_export]
add_breadcrumb "Home", :root_path
add_breadcrumb "Projects", :projects_path
def index
@projects = current_user.projects.order(:name).page(params... |
require 'rails_helper'
describe AlbumFromApi do
describe '#band_name' do
it "returns band's name without ID" do
album = AlbumFromApi.new('Hybrid Theory', 'rock', 'Linkin Park 1')
expect(album.band_name).to eq('Linkin Park')
end
end
end
|
# Numbers to Commas Solo Challenge
# I spent [1] hour on this challenge.
# 0. Pseudocode
# The Input will be a positive integer (1000000)
# The output will be a string of that integer with commas ('1,000,000')
# This looks like 3 if statements that will work on the length of the input
# if length <= 3 then... |
require_relative '../helpers/n_choose_k'
require 'prime'
require 'set'
class OEIS
def self.a268681(rows = 51)
primes = Prime.each(rows**0.5).to_a
unique_values = SortedSet.new([1] + rows.times.flat_map do |n|
(1..n/2).map { |k| n.choose(k) }
end)
unique_values.select { |i| primes.all? { |p| i... |
class ModelGenerator < BaseScaffold
def build
define_source_paths
template("model.erb", Configuration.main_class_path(Configuration.models_package, "#{class_name}.java"))
template("model_test.erb", Configuration.test_class_path(Configuration.models_package, "#{test_class_name}.java"))
map_orm_class i... |
class Item < ApplicationRecord
belongs_to :user
has_one_attached :image
has_one :purchase
extend ActiveHash::Associations::ActiveRecordExtensions
belongs_to :category
belongs_to :condition
belongs_to :postage
belongs_to :sender_area
belongs_to :required_time
with_options presence: true do
vali... |
class CreateBookedSeats < ActiveRecord::Migration
def change
create_table :booked_seats do |t|
t.references :theatre_seat
t.references :booking, index: true, foreign_key: true
t.string :status_of_booked_seat
t.boolean :is_deleted
t.timestamps null: false
end
end
end
|
class BoardCase
attr_reader :content
def initialize(position)
# Ici on initialise une case du plateau
@position = position
@content = " "
end
def change_content(value)
@content = value
end
def change_color
@content = @content.colorize(:green)
end
end
|
require 'spec_helper'
describe Admin::UsersController do
render_views
include_context 'Admin signed in'
describe '#index' do
let!(:writer) { create(:writer) }
let(:call_request) { get :index }
context 'after request' do
before { call_request }
it { expect(assigns(:users)).to eq [admin,... |
# Copyright (C) 2007 Teskal
class MessageObserver < ActiveRecord::Observer
def after_create(message)
# send notification to board watchers
# recipients = message.board.watcher_recipients
# Mailer.deliver_message_posted(message, recipients) unless recipients.empty?
end
end
|
require_relative 'vocabulary_operator'
module ConceptQL
module Operators
# A StandardVocabularyOperator is a superclass for a operator that represents a criterion whose column stores information associated with a standard vocabulary.
#
# If that seems confusing, then think of CPT or SNOMED criteria. Tha... |
class CreateAssignments < ActiveRecord::Migration
def change
create_table :assignments do |t|
t.string :title
t.integer :user_id
t.integer :category_id
t.integer :circle_id
t.string :typies
t.integer :timelimit
t.datetime :validate
t.datetime :invalidate
t.tex... |
class User < ApplicationRecord
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
has_many :orders
has_many :addresses
has_many :pac... |
class Event < ApplicationRecord
validates :notes, presence: true
end
|
module Ironwood
Floor = Struct.new :treasures, :guards, :finished_at
class Score
attr_reader :floor, :floors, :time
attr_accessor :smokebombs
def initialize time
@time = time
@floor = 0
@floors = [Floor.new(0, 0, 0)]
@smokebombs = 0
new_floor
end
def new_floor
floors[@floor].finis... |
# classe principal dos testes da aplicacao
require 'faker'
class MainPage
attr_accessor :driver
# Onde e realizado o Page object da pagina para melhor manutencao
def initialize
@driver = $driver
@rock_text = 'lfr-ddm-form-page-description'
@submit_button = '/html/body/div[1]/div... |
RSpec.describe WellFormed::Validations do
describe "#valid?" do
it "returns false if a validation fails" do
form = StationForm.new
expect(form).to_not be_valid
end
it "returns true if all validations pass" do
form = StationForm.new(build(:station, address: build(:address)))
expe... |
# == Schema Information
#
# Table name: users
#
# id :integer not null, primary key
# email :string(255) default(""), not null
# encrypted_password :string(255) default(""), not null
# reset_password_token :string(255)
# reset_password_sent_at :datetime... |
class CreateFood < ActiveRecord::Migration
def change
create_table :food do |t|
t.string :name
t.boolean :liquid, default: false
t.decimal :wv_ratio
end
end
end
|
require 'spec_helper'
require 'rails_helper'
describe Review do
user = FactoryGirl.build(:user)
game = FactoryGirl.build(:game)
it { should have_valid(:rating).when("1", "2", "3", "4", "5") }
it { should_not have_valid(:rating).when(nil, '', '0', '6') }
it { should have_valid(:user).when(user) }
it { sho... |
module DeviseSinglePageHelper
# def devise_error_messages_for_same_page(given_resource)
# return "" if given_resource.errors.empty?
#
# messages = given_resource.errors.full_messages.map { |msg| content_tag(:li, msg) }.join
# sentence = I18n.t("errors.messages.not_saved",
# count: ... |
# frozen_string_literal: true
module Minutely
##
# An abstract class for defining custom parsers.
#
# @!attribute [r] value
# @return [Object]
class Parser
attr_reader :value
##
# Initialize the parser.
#
# @param value [Object]
def initialize(value)
@value = value
end
... |
class QuestionsController < ApplicationController
before_action :set_question, only: [ :show, :edit, :destroy ]
before_action :authorize, only: [ :create, :edit, :destroy, :new, :update ]
# before_action :authorize, only: [ :edit, :destroy ]
def index
@questions = Question.find_with_reputation(:votes, :all... |
require "rails_helper"
describe "Api::V1::Schedules", type: :request do
context "GET schedules" do
let(:url) { "/api/v1/schedules" }
let!(:schedules) { create(:schedule) }
it "returns all Adresses" do
get url, params: schedules, xhr: true
expect(body_json['schedules']).to contain_exactly sch... |
module Snmp2mkr
module EngineThreads
class Timer
Entry = Struct.new(:interval, :hook, :last)
def initialize(logger: Logger.new($stdout))
@shutdown = false
@entries = []
@logger = logger
@thread = nil
end
attr_reader :entries, :logger, :thread
def ad... |
module Faire
module Error
RequiredParametersMissing = Class.new(StandardError)
CoercionError = Class.new(StandardError)
end
end
|
class CertificateType < ActiveRecord::Base
has_many :vehicle_certificates
validates_presence_of :name
validates_uniqueness_of :name, :case_sensitive => false
before_destroy :check_dependencies
named_scope :active, :conditions => {:is_active => true}
named_scope :inactive, :conditions => {:is_act... |
class RenameUserIdIndexOnPhotos < ActiveRecord::Migration
def up
add_index :photos, [:user_id, :cluster_id, :is_visible, :position], :name => :cluster_photo_fetch
remove_index :photos, :name => :user_id
end
def down
end
end
|
require 'netrc'
require 'open-uri'
module HerokuCloudBackup
class Auth
class << self
attr_accessor :credentials
def user
get_credentials[0]
end
def password
get_credentials[1]
end
def running_on_windows?
RUBY_PLATFORM =~ /mswin32|mingw32/
end
... |
class GimpLisanet < Cask
url 'http://downloads.sourceforge.net/gimponosx/Gimp-2.8.10-Mavericks.dmg'
homepage 'http://gimp.lisanet.de'
version '2.8.10'
sha1 '026d1fb3eb9ebdc1365bfc71fb8d66f943731bd9'
link 'GIMP.app'
end
|
require_relative 'map_formulae_to_ruby'
class CompileToRuby
attr_accessor :settable
attr_accessor :worksheet
def self.rewrite(*args)
self.new.rewrite(*args)
end
def rewrite(input,sheet_names_file,output,defaults = nil)
self.settable ||= lambda { |ref| false }
mapper = MapFormulaeToRuby.n... |
class CreateTitles < ActiveRecord::Migration
def self.up
create_table :titles do |t|
t.string :name
t.date :release_date
t.string :source
t.string :director
t.text :cast
t.integer :runtime
t.string :rating
t.text :premise
t.timestamps
end
end
def sel... |
class SubsFilterNginxModule < Formula
desc "regular expression and fixed string substitutions"
homepage "https://github.com/yaoweibin/ngx_http_substitutions_filter_module"
url "https://github.com/yaoweibin/ngx_http_substitutions_filter_module/archive/v0.6.4.tar.gz"
version "0.6.4"
sha256 "ed4ddbcf0c434f4a1e97... |
require_relative 'module/instance_counter.rb'
require_relative 'module/train_find.rb'
require_relative 'module/firmwares.rb'
require_relative 'module/valid.rb'
class Train
NUMBER_FORMAT = /^\w{3}-?\w{2}$/i
include Firmware
include TrainFind
include InstanceCounter
include ValidCheck
attr_reader :name, :t... |
# -*- encoding : utf-8 -*-
module AuthenticateHelper
protected
def self.included(base)
base.send :helper_method, :current_user, :logged_in?
end
def logged_in?
current_user != :false
end
def current_user
@current_user = (session[:user_id] && User.find_by_id(session[:user_id])) || :false
end
... |
class EventPlanner < ActiveRecord::Base
belongs_to :user
belongs_to :event_series
belongs_to :appointer, :class_name => 'User'
validates_presence_of :user, :event
end
|
class Post < ApplicationRecord
has_rich_text :content
acts_as_votable
belongs_to :user
has_many :comments, as: :commentable
has_many :post_tags
has_many :tags, through: :post_tags
before_validation :set_default_status
validates :title, presence: true
validates :content, presence: true
validate... |
require File.join(File.dirname(__FILE__), '../../lib/sequel_core')
require File.join(File.dirname(__FILE__), '../spec_helper.rb')
unless defined?(POSTGRES_DB)
POSTGRES_DB = Sequel.connect(ENV['SEQUEL_PG_SPEC_DB']||'postgres://postgres:postgres@localhost:5432/reality_spec')
end
POSTGRES_DB.drop_table(:test) if POSTG... |
class NewsController < ApplicationController
def index
@categories = Category.all
if params[:category]
@current_category = params[:category]
@news_items = NewsItem.where(:category => params[:category]).order(:publishedDate.desc)
else
@news_items = NewsItem.order(:published_date)
end
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.