text stringlengths 10 2.61M |
|---|
# Schema
# t.integer "user_id"
# t.integer "product_id"
class Wishlist < ActiveRecord::Base
# Associated models
belongs_to :user
belongs_to :product
# Accessible attributes
attr_accessible :user_id, :product_id
# Associated validations
validates :user_id, :presence => true
# validates :product_id, :pr... |
class WrongNumberOfPlayersError < StandardError ; end
class NoSuchStrategyError < StandardError ; end
def rps_game_winner(game)
raise WrongNumberOfPlayersError unless game.length == 2
# raise error if game strategy different from P,R or S
raise NoSuchStrategyError unless game.all? {|g| g.last =~ /[PSR]/i}
game_... |
class Bill < ActiveRecord::Base
has_many :movements, :dependent => :destroy
has_many :menu_day, :dependent => :destroy
accepts_nested_attributes_for :menu_day
attr_accessor :periodo_mask
before_save :check_limites
belongs_to :school
belongs_to :user
validates :school_id, presence: true
validat... |
require 'util/miq-xml'
require 'metadata/VmConfig/VmConfig'
require 'VolumeManager/MiqNativeVolumeManager'
require 'fs/MiqMountManager'
require 'awesome_spawn'
module MiqNativeMountManager
def self.mountVolumes
lshwXml = AwesomeSpawn.run!("lshw", :params => ["-xml"], :combined_output => true).output
nodeHash... |
class Calculator
attr_accessor :num1, :num2
def initialize(num1, num2)
@num1 = num1
@num2 = num2
end
def sum
@num1 + @num2
end
def difference
@num1 - @num2
end
def quotient
@num1.to_f/@num2.to_f
end
def product
@num1 * @num2
e... |
# Givens
Given(/^Active bill$/) do
create :active_bill
visit '/bills/1'
end
Given(/^Non Active bill$/) do
create :non_active_bill
visit '/bills/1'
end
Given(/^User is on Legislator page$/) do
create :legislator
visit '/legislators/1'
end
# Whens
When(/^User attempts to tag a bill$/) do
click_button '... |
class AddDateAndTimeToReminders < ActiveRecord::Migration[5.2]
def change
add_column :reminders, :date, :string
add_column :reminders, :time, :string
end
end
|
Time.class_eval do
# Weekend cutoff is 5pm Friday to 5pm Sunday.
def weekend?
wday == 6 || wday == 0 && hour < 17 || wday == 5 && hour >= 17
end
def weekday?
! weekend?
end
end
|
require 'couchrest_model'
class Dc < CouchRest::Model::Base
use_database "dashboard"
property :district_code, String
property :registered, Integer
property :approved, Integer
property :date_created, String
timestamps!
design do
view :by__id
view :by_district_code
view :by_registe... |
require 'bundler'
Bundler::GemHelper.install_tasks
require 'rake/clean'
require 'rake/testtask'
task :default => [:test]
task :test do
Rake::TestTask.new do |t|
t.libs << "test"
t.pattern = 'test/*_test.rb'
t.verbose = true
end
end
desc 'Measures test coverage'
task :coverage do
rm_f "coverage"
... |
class Vacation < ApplicationRecord
belongs_to :traveler
belongs_to :country
end
|
class ManageIQ::Providers::Amazon::Inventory::Collector::StorageManager::S3 <
ManageIQ::Providers::Amazon::Inventory::Collector
def cloud_object_store_containers
hash_collection.new(aws_s3.client.list_buckets.flat_map(&:buckets))
end
def cloud_object_store_objects(options = {})
options[:token] ||= nil... |
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.0.2'
gem 'pg', '0.17.1'
# Devise
gem 'devise', '3.2.1'
group :assets do
gem 'sass-rails', '4.0.1'
gem 'coffee-rails', '4.0.1'
gem 'uglifier', '1.0.4'
end
# Compass for CSS
gem 'compass-rails... |
require 'pry'
class Student
attr_accessor :id, :name, :grade
def self.new_from_db(row)
new_student = self.new # self.new is the same as running Song.new
new_student.id = row[0]
new_student.name = row[1]
new_student.grade = row[2]
new_student
end
def self.all
sql = <<-SQL
S... |
class CreatePages < ActiveRecord::Migration
def change
create_table :pages do |t|
t.string :title
t.integer :parent_id
t.string :custom_title
t.boolean :display_in_menu
t.string :browser_title
t.string :meta_keywords
t.text :meta_desc
t.boolean ... |
class Plan < ActiveRecord::Base
belongs_to :user
belongs_to :level
belongs_to :category
end
|
require 'uri'
require 'uriparser'
# wrapper the ruby URI class
module URI
def self.parser uri
UriParser.parse(uri)
end
end
module Kernel
def URI(uri)
UriParser.parse(uri)
end
end
|
require 'csv'
namespace :import do
desc "Import Churches from CSV"
task :organizations, [:filename] => [:environment] do |t, args|
campaign = Campaign.find_or_create_by(
name: 'Serve Day',
description: 'Serve Day',
status: 'open'
)
filename = File.join(Rails.root, 'tmp', args[:filen... |
class CreateQaAnswers < ActiveRecord::Migration
def self.up
create_table :qa_answers do |t|
t.integer :question_id
t.text :text, :limit => 15000, :null => false
t.timestamps
end
end
def self.down
drop_table :qa_answers
end
end
|
class MeetupEventsController < ApplicationController
before_action :check_user
before_action :set_event, only: [:show, :edit, :update, :destroy]
def index
@meetup_event = MeetupEvent.first
redirect_to new_meetup_event_url unless @meetup_event.present?
end
def new
redirect_to edit_meetup_event_ur... |
require './Lib/weather'
class Airport
include Weather
def initialize(gates=[])
@gates = gates
@holding_pattern = []
end
attr_reader :gates, :holding_pattern
def approach plane
if !full? && clear_to_fly?
clear_to_land plane
next_gate.dock plane
else
hold_plane plane
end
end
def depart ga... |
class CreateShareAStats < ActiveRecord::Migration
def change
create_table :share_a_stats do |t|
t.string :title
t.text :message
t.string :image
t.boolean :scholarship
t.string :tip
t.integer :mc_alpha
t.integer :mc_beta
t.string :redirect
t.text :redirect_mess... |
module SQLite3
class Encoding
class << self
def find(encoding)
enc = encoding.to_s
if enc.downcase == "utf-16"
utf_16native
else
::Encoding.find(enc).tap do |e|
if utf_16?(e) && e != utf_16native
raise ArgumentError, "requested to use byt... |
class Specinfra::Command::Linux::Base::Interface < Specinfra::Command::Base::Interface
class << self
def check_exists(name)
"ip link show #{name}"
end
def get_speed_of(name)
"cat /sys/class/net/#{name}/speed"
end
def check_has_ipv4_address(interface, ip_address)
ip_address = ip... |
module Admin::UsersHelper
def status(user)
return user.banned ? "Banned" : "Ok"
end
def role(user)
return user.admin ? "Admin" : "User"
end
def ban_btn_text(user)
return user.banned ? "Unban" : "Ban"
end
end |
class User < ApplicationRecord
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :validatable
has_one :verification, dependent: :destroy
has_many :... |
require_relative("../db/sql_runner")
require_relative("customer.rb")
require_relative("film.rb")
require_relative("ticket.rb")
class Screening
attr_reader :id
attr_accessor :film_id, :time_slot, :capacity
def initialize(details)
@id = details['id'].to_i() if details['id']
@film_id = details['film_id'].... |
class MissedVisitReminderService
def self.send_after_missed_visit(*args)
new(*args).send_after_missed_visit
end
def initialize(appointments:, days_overdue: 3)
@appointments = appointments
@days_overdue = days_overdue
@communication_type = if Flipper.enabled?(:whatsapp_appointment_reminders)
... |
# class to help manage user sessions
class UserSession
# receive a list of posible user ids, return de first that's not nil
def self.get_user_session_id(user_sessions)
user_sessions.each do |user_session|
return user_session unless user_session.nil?
end
end
end
|
# encoding: UTF-8
module OmniSearch
# Indexes::Plaintext
class Indexes::Plaintext < Indexes::Base
STORAGE_ENGINE = Indexes::Storage::Plaintext
end
end |
require 'player'
describe Player do
subject(:player1) { Player.new('Kavita') }
subject(:player2) { Player.new('Prabu') }
it 'returns player name' do
expect(player1.name).to eq 'Kavita'
end
it 'returns player hitpoints' do
expect(player1.hit_points).to eq Player::DEFAULT_HP
end
it 'reduces hitp... |
module ExceptionHub
class ExceptionStorage
def perform(exception, env)
storage = ExceptionHub.storage.new
storage.save(storage.find(exception.filtered_message),
{:message => exception.message, :backtrace => exception.formatted_backtrace})
self
end
end
end
|
#encoding=utf-8
require 'spec_helper'
describe NonconformingProduct do
let(:nonconforming_product) { }
describe "Validations" do
it { should validate_presence_of(:issue) }
it { should validate_presence_of(:description) }
end
describe "Associations" do
it { should belong_to(:user) }
end
... |
class RemoveColumnCoverUrlFromUsers < ActiveRecord::Migration
def change
remove_column :users, :cover_photo, :string
end
end
|
module Comercio
module Address
class Address < SitePrism::Page
def is_address
is_visible_el 'address.is_address'
end
def click_buy
click_el 'address.buy'
end
def choose_delivery delivery_type
delivery_type.downcase!
unless delivery_type == 'default'... |
class SessionsController < ApplicationController
def new
@user = User.new
end
def create
if auth
user = User.find_or_create_by_omniauth(auth)
current_user(user)
associate_cart_items_to_user
redirect_to root_path
else
user = User.find_by(email: user_params[:email])
... |
class KindsController < ApplicationController
def show
@snippets = Snippet.where("kind_id= ? AND is_private = ?", params[:id], false)
end
end
|
class Hangman
DICTIONARY = ["cat", "dog", "bootcamp", "pizza"]
end
|
require 'test_helper'
class QuestionTest < ActiveSupport::TestCase
test "should not save question without body and assigned_part" do
question = Question.new
assert !question.save, "Saved the question without a body"
end
end
|
class AddDescriptionToMessage < ActiveRecord::Migration
def change
add_column :messages, :to, :string, array: true, default: "{}"
end
end
|
module Monkeyshines
module RequestStream
#
# Watch for jobs in an Edamame priority queue
# (http://mrflip.github.com/edamame)
#
class EdamameQueue < Edamame::Broker
# How long to wait for tasks
cattr_accessor :queue_request_timeout
self.queue_request_timeout = 5 * 60 # seconds
... |
class OCR # :nodoc:
attr_reader :text
NUMBER_HEIGHT = 4
NUMBER_WIDTH = 3
NUMBERS = { ' _ | ||_|' => '0',
' | |' => '1',
' _ _||_ ' => '2',
' _ _| _|' => '3',
' |_| |' => '4',
' _ |_ _|' => '5',
' _ |_ |_|' => '6',
... |
class ClientsController < ResourceController
protected
def collection
@clients ||= end_of_association_chain.includes(:client_logo, :projects, :images, :services)
end
end |
class AddScheduleTable < ActiveRecord::Migration
def change
create_table :schedule do |t|
t.column :day, :string
t.column :hours, :string
end
remove_column :appointments, :practitioner_id, :int
remove_column :services, :practitioner_id, :int
end
end
|
require 'rails_helper'
describe Style do
describe "#dress?" do
context "type is dress" do
let(:style) { FactoryGirl.create(:style, type: "Dress") }
it "should return true" do
expect(style.dress?).to eq(true)
end
end
context "type is not dress" do
let(:style) { Fact... |
# frozen_string_literal: true
class Movie < ApplicationRecord
has_many :movie_genres
has_many :genres, through: :movie_genres
has_many :movie_directors
has_many :directors, through: :movie_directors
has_many :movie_creators
has_many :creators, through: :movie_creators
has_many :movie_cast_members
ha... |
RSpec.describe Dota::API::MissingHero do
let(:hero) { described_class.new(nil) }
specify "#id" do
expect(hero.id).to eq nil
end
specify "#name" do
expect(hero.name).to eq nil
end
specify "#image_url" do
expect(hero.image_url).to eq nil
expect(hero.image_url(:something)).to eq nil
end
en... |
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
before_action :configure_permitted_parameters, if: :devise_controller?
rescue_from CanCan::AccessDenied do |exception|
respond_to do |format|
format.json { head :forbidden, content_type: 'text/html' }
for... |
class RenameSalerIdColumnToItems < ActiveRecord::Migration[5.2]
def change
rename_column :items, :saler_id, :seller_id
end
end
|
# frozen_string_literal: true
# rubocop:todo all
# Copyright (C) 2014-2020 MongoDB 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
#
# U... |
class ExtendedRegister4 < DLMSClass
defineAttribute("logical_name")
defineAttribute("data")
defineAttribute("scaler_unit")
defineMethod("reset")
end
module DLMSTrouble
class DLMSClass
VERSIONED_NAME_REGEX = /^(?<name>([A-Z][A-Za-z0-9]*))CID(?<classID>[0-9]+)V(?<version>[0-9... |
class CreateNews < ActiveRecord::Migration[5.0]
def change
create_table :news do |t|
t.string :title, null: false
t.string :description, null: false
t.datetime :published_at
t.boolean :published
t.string :url
t.timestamps
end
end
end
|
class Stack
attr_accessor :stack
def initialize
@stack = []
end
def add(el)
stack << el
end
def remove
stack.pop
end
def show
puts stack
end
end
class Queue
attr_accessor :stack
def initialize
@stack = []
end
def enqueue(el)
stack << el
end
def dequeue
... |
require_relative "dish.rb"
class Order
def initialize (dish_list = [], total_price = 0.0)
@dish_list = dish_list
@total_price = 0.0
end
def dish_list
@dish_list
end
def add(dish)
dish_list << dish
end
def total_price
@total_price = dish_list.inject(0) {|total, dish| total + dish.price}
end
def... |
require 'spec_helper'
describe 'mysql::server' do
on_pe_supported_platforms(PLATFORMS).each do |pe_version,pe_platforms|
pe_platforms.each do |pe_platform,facts|
describe "on #{pe_version} #{pe_platform}" do
let(:facts) { facts }
context 'with defaults' do
it { is_expected.to con... |
JSONAPI.configure do |config|
# custom processor for nested models
config.default_processor_klass = Api::V1::BaseProcessor
config.json_key_format = :underscored_key
config.route_format = :underscored_key
# config.resource_cache = Rails.cache
config.allow_include = true
config.allow_sort = true
config.a... |
class CreateLocationRoutes < ActiveRecord::Migration
def change
create_table :location_routes do |t|
t.integer :start_id
t.integer :end_id
t.integer :distance
t.string :polyline
end
add_index :location_routes, [:start_id, :end_id], :unique => true
end
end
|
#
#
#
#
class HumanPlayer
def initialize
@code = [0,0,0,0]
end
def get_code
valid = false
while !valid
print "Enter code of 4 space-separated numbers between 1-6: "
code = STDIN.gets.chomp
valid = validate?(code)
if !valid
puts "Please enter 4 space-separated numbers ... |
# frozen_string_literal: true
require "rails_helper"
RSpec.describe CollectionPoint, type: :model do
subject(:collection_point) { create(:collection_point, coordinator: coordinator) }
let!(:address) { create(:address, addressable: collection_point) }
let!(:coordinator) { create(:user) }
describe "#address" ... |
require "etc"
require "fileutils"
require "find"
require "mail"
require "socket"
require "date"
require "permCheck/version"
require "modeBits"
# Check permissons and group ownership of files.
#
# @author Gord Brown
module PermCheck
# Top-level class to carry out an audit.
class PermCheck
# Set up for audit.... |
class Favour < ApplicationRecord
CATEGORY = %w[Groceries Gardening Pets Pharmacy Chat Other]
STATUS = %w[Open Accepted Done Expired Deleted]
# Geocoded
geocoded_by :address
# Associations
belongs_to :recipient, :class_name => 'User', optional: true
belongs_to :helper, :class_name => 'User', optional: tr... |
class Category < ApplicationRecord
has_many :work_categories
has_many :works, through: :work_categories
validates :name, presence: true, length: {minimum: 3, maximum: 25 }
validates_uniqueness_of :name
end
|
class DisplayReportContext < BaseContext
attr_accessor :audit_report,
:report_template,
:for_pdf,
:user
def initialize(*)
super
raise 'audit_report' unless audit_report
self.for_pdf = false if @for_pdf.nil?
end
def as_json
{
form_html: form... |
require "test_helper"
class IngestersControllerTest < ActionDispatch::IntegrationTest
setup do
@ingester = ingesters(:one)
end
test "should get index" do
get ingesters_url
assert_response :success
end
test "should get new" do
get new_ingester_url
assert_response :success
end
test "... |
class AddInprogressToIssues < ActiveRecord::Migration[5.1]
def change
add_column :issues, :inprogress, :datetime, null: true
add_column :issues, :released, :datetime, null: true
end
end
|
class Page < ActiveRecord::Base
#How to provide a foreign_key
#belongs_to :subject, {foreign_key: "subject_id"}
belongs_to :subject
has_many :sections
end
|
# encoding: utf-8
class Liquidacion < ActiveRecord::Base
before_save :salvar_calculados
before_save :set_saldo
# Relacion con carpeta, cliente, personal, doc
belongs_to :carpeta
belongs_to :cliente
belongs_to :personal
belongs_to :documento
has_many :pagos
# Valida la precensia de los campos
... |
class CreateRetrospective < ActiveRecord::Migration
def change
create_table :retrospectives do |t|
t.integer :number
t.references :sprint, index: true, foreign_key: true
t.references :project, index: true, foreign_key: true
end
end
end
|
class Price < ActiveRecord::Base
belongs_to :menu_item
belongs_to :price_title
belongs_to :item_type_variant
def self.find_by_menu(menu_id)
sql = "SELECT p.* FROM menu_items mi " +
"JOIN prices p ON mi.id = p.menu_item_id " +
"WHERE mi.menu_id = ?"
Price.find_by_sql [sql, menu_id]
... |
require 'rails_helper'
RSpec.describe "Quiz", type: :request do
let!(:question) { create(:question) }
let!(:questions) { [question] + create_list(:question, 5) }
describe 'GET /quiz' do
before { get quiz_index_path }
it 'succeeds' do
expect(response).to be_success
end
it 'outputs a list of... |
module OnboardDatax
class OnboardSearchStatConfig < ActiveRecord::Base
attr_accessor :config_desp, :brief_note, :engine_name, :labels_and_fields, :resource_name, :search_list_form, :search_params, :search_results_period_limit,
:search_summary_function, :search_where, :stat_function, :stat_heade... |
# ruby ~/Dropbox/Projects/ruby/ruby-snippet-examples/hash_array_looping.rb
# Hash https://ruby-doc.org/core-2.5.1/Hash.html
grades = { "Jane Doe" => 10, "Jim Doe" => 6 }
p grades
# to access
puts grades["Jim Doe"]
# alternate syntax for eys that are symbols
options = { :font_size => 10, :font_family => "Arial" }
# co... |
class Invoice < ActiveRecord::Base
include ActionView::Helpers::NumberHelper
belongs_to :delivery
has_many :invoice_items, :dependent => :destroy
has_many :items, :through => :invoice_items
attr_accessible :invoice_number,
:fob_total_cost,
:total_units,
... |
require_relative "../../../lib/google_mail"
require_relative "../../../lib/eapol_test"
feature "Signup" do
include_context "signup"
it "signs up successfully" do
gmail = GoogleMail.new
test_email = gmail.account_email.gsub(/@/, "+#{Time.now.to_i}@")
gmail.send_email(
"signup@wifi.service.gov.u... |
# -*- mode: ruby -*-
# vi: set ft=ruby :
# wit home Enterprise virtual (KVM) servers:
# 1. Proxy (forward and reverse)
# 2. Extranet web server (wiki)
Vagrant.configure("2") do |config|
config.vm.box = "centos/7"
config.vm.synced_folder "./", "/vagrant", type: "nfs"
config.vm.provider :libvirt do |libvirt,... |
#
# myapp.rb
# ConstantContact
#
# Copyright (c) 2013 Constant Contact. All rights reserved.
require 'rubygems'
require 'sinatra'
require 'active_support'
require 'yaml'
require 'constantcontact'
# This is a Sinatra application (http://www.sinatrarb.com/).
# Update config.yml with your data before running the applica... |
name1 = "Joe"
name2 = "Needa"
puts "Hello %s, where is %s?" %[name1, name2]
#Another way of putting variables inside a string is called "string interpolation" which uses #{} (pound and curly bracket). The next 3 lines will demonstrate this:
name1 = "Joe"
name2 = "Needa"
puts "Hello #{name1}, where is #{name2}?"
#bel... |
module Fog
module Hetznercloud
class Compute
class Real
def floating_ip_update_dns_ptr(id, body)
create("/floating_ips/#{id}/actions/change_dns_ptr", body)
end
end
class Mock
def floating_ip_update_dns_ptr(_type, _body)
Fog::Mock.not_implemented
... |
class Board < ActiveRecord::Base
belongs_to :user
has_many :pins
validates :name, :presence => true
end
|
class CreateEntries < ActiveRecord::Migration
def change
create_table :entries do |t|
t.datetime :start
t.datetime :stop
t.string :project
t.string :description
t.boolean :open?
t.time :elapsed
t.timestamps null: false
end
end
end
|
class ProgressBar
module Components
class Throttle
include Timer
def initialize options = {}
@period = options.delete :throttle_period
end
def choke force=false, &block
if not started? or not @period or force or elapsed >= @period
yield
start
e... |
class Animal
attr_reader :diet
def initialize(diet, superpower)
@diet = diet
@superpower = superpower
end
def move
puts "I'm moving!"
end
def superpower
puts "I can #{@superpower}!"
end
end
class Fish < Animal
def move
puts "I'm swimming!"
end
end
class Bird < Animal
end
class... |
module ApplicationHelper
def resource_name
:user
end
def resource
@resource ||= User.new
end
def devise_mapping
@devise_mapping ||= Devise.mappings[:user]
end
def user_avatar user, style, css_class = ""
if user.profile
image_tag user.profile.avatar.url(style), class: "img-circle #... |
module MalauzaiPlaces
class Client
attr_reader :api_key
attr_reader :options
def initialize(api_key = @api_key, options = {})
api_key ? @api_key = api_key : @api_key = MalauzaiPlaces.api_key
@options = options
end
def places(lat, lng, options = {})
options = @options.merge(options)
det... |
class UserMailer < ApplicationMailer
default from: 'notifications@example.com'
def answer_email(user , question , answer)
@user = user
@question = question
@answer = answer
@url = "http://localhost:3000#{question_path(@question)}"
mail(to: @user.email, subject: 'You have new answe... |
module EasyExtensions
class ExternalResources::ExternalResourceBase < ActiveResource::Base
add_response_method :http_response
def inspect
"#<#{self.class.name} id=#{self.id}>"
end
end
end
|
class GroupsController < ApplicationController
before_action :replace_action, only: [:update,:edit]
#renderメソッドは移動先のアクションの変数を持ってこなくてはならない。上記のreplace_actionはその変数をまとめたもの。
def index
@groups = current_user.groups
end
def new
@group = Group.new
end
def create
@group = Group.new(post_params)
i... |
class TargetGroup < ActiveRecord::Base
belongs_to :panel_provider
belongs_to :parent, class_name: 'TargetGroup', dependent: :destroy
has_many :children, class_name: 'TargetGroup', foreign_key: 'parent_id', dependent: :destroy
has_and_belongs_to_many :countries
scope :roots, -> { where(parent_id: nil) }
de... |
require 'rails_helper'
RSpec.feature "AddToCarts", type: :feature, js: true do
before :each do
@category = Category.create! name: 'Apparel'
10.times do |n|
@category.products.create!(
name: Faker::Hipster.sentence(3),
description: Faker::Hipster.paragraph(4),
image: open_asset(... |
# http://www.mudynamics.com
# http://labs.mudynamics.com
# http://www.pcapr.net
module Mu
class Pcap
class SCTP
class Parameter < Packet
attr_accessor :type, :size
def initialize
super
@type = 0
@size = 0
end
def self.from_bytes bytes
# Basic valida... |
class CommentsController < ApplicationController
before_action :is_admin, only: [:create]
def create
@job_posting = JobPosting.find(params[:job_posting_id])
@comment = @job_posting.comments.create(comment_params)
if @admin
redirect_to admin_job_posting_path(@job_posting)
... |
module Qualifications
include Reform::Form::Module
property :skills_list
property :certification_ids
collection :educations, populate_if_empty: Education do
# TODO: When Reform releases _destroy support implement that instead of this hack
property :id, virtual: false
property :_destroy, virtual: f... |
# Methods added to this helper will be available to all templates in the application.
module ApplicationHelper
def number_to_price(n)
number_to_currency(n, :unit => 'zł')
end
def polish_paginate(collection)
will_paginate collection, :prev_label => '« Poprzednie', :next_label => 'Następne »'... |
class ContentPage < ActiveRecord::Base
extend FriendlyId
friendly_id :url, use: :slugged
validates :link_text, :url, :title, presence: true
after_validation :move_friendly_id_error_to_url
def to_s
title
end
private
def move_friendly_id_error_to_url
errors.add :url, *errors.delete(:friendly_... |
class Admin::IdeaModeratorsController < Admin::IdeasBaseController
cache_sweeper :idea_sweeper, :only => %w(destroy)
before_filter :require_role_idea_instance_admin_of_instance
helper_method :moderators, :instance_admins, :users, :user, :role
def index
respond_to do |format|
format.html
... |
require 'azure_mgmt_compute'
require 'azure_mgmt_resources'
require 'azure_mgmt_storage'
require 'azure_mgmt_network'
# Include SDK modules to ease access to classes
include Azure::ARM::Resources
include Azure::ARM::Resources::Models
include Azure::ARM::Compute
include Azure::ARM::Compute::Models
include Azure::ARM::N... |
class OneTimeEmail < ActiveRecord::Base
belongs_to :user
validates_uniqueness_of :key, :scope => :user_id
after_create :deliver_mail
protected
def deliver_mail
ETTriggeredSendAdd.send_badge_level_up_notification(self.user) if App.sywr_enabled?
end
end
|
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
protect_from_forgery except: :gallery_web_address
def gallery_web_address
@customers = Customer.all
... |
# 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:
#
# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
# Ch... |
class GoogledriveController < ApplicationController
protect_from_forgery except: :get_docs # get_docsアクションを除外
def index
@files = GoogleDriveDatum.order('fullpath')
end
def docs
@files = GoogleDriveDatum.where("content <> ''").order('fullpath')
end
def get_docs
ajax_action unless params[:ajax_... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.