text stringlengths 10 2.61M |
|---|
class DqsPoro
attr_reader :tables
def initialize
@tables = {
'Fruits' => [1, 1, 1, 1, 1, 1, 0.5, 0.5, 0, 0, 0, 0],
'Vegetables' => [1, 1, 1, 1, 1, 1, 0.5, 0.5, 0, 0, 0, 0],
'Lean Meats & Fish' => [1, 1, 1, 1, 0.5, 0.5, 0, 0, 0, 0, -0.5, -0.5],
'Nuts & Seeds' => [1, 1, 1, 1, 0.5, 0.5, 0,... |
class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :token_authenticatable, :confirmable, :lockable and :timeoutable
devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable, :lockable
# Setup accessible (or protected) attribu... |
require 'netvbox/vm_set'
require 'netvbox/vm_set_manager'
module NetVbox
class PrintingDelegator
def initialize(vm_set_manager, vm_set)
@vm_set = vm_set
@vm_set_manager = vm_set_manager
end
def add_vm(hostname, username, password, vm_name, snapshot_name)
begin
@vm_set.add_vm(ho... |
FactoryBot.define do
factory :match do
user
receiver
email_sent true
end
end
|
FactoryBot.define do
factory :user do
sequence(:name) { |n| "name#{n}" }
sequence(:email) { |n| "correo#{n}@codeandomexico.org"; }
nickname { 'cmx' }
password { 'password' }
password_confirmation { 'password' }
factory :user_with_skills do
ignore do
skills_count 1
end
... |
class AddRepliesToArguments < ActiveRecord::Migration[6.1]
def up
change_table :arguments do |t|
t.references :argument, index: true
end
end
def down
change_table :arguments do |t|
t.remove_references :argument
end
end
end
|
class ProductWarrantiesController < ApplicationController
before_filter :require_admin
def index
@product_warranties = ProductWarranty.all
end
def new
@product_warranty = ProductWarranty.new
end
def create
@product_warranty = ProductWarranty.new product_warranty_params
if @product_warrant... |
#!/usr/bin/env ruby
# frozen_string_literal: true
def f2c(temperature)
((temperature - 32.0) / 1.8).round(2)
end
def c2f(temperature)
(temperature * 1.8 + 32).round(2)
end
def input(type_cast)
send(type_cast, gets.chomp) rescue nil
end
puts <<~OUT
Available conversions:
0: Fahrenheit => Celsius
1: ... |
class RunWorkout < Workout
belongs_to :user
validates_numericality_of :distance
def calrunpace
pace = (self.getworkouttotalminutes.to_f / self.distance.to_f).round(2)
end
end |
module UpdateRate
extend ActiveSupport::Concern
module ClassMethods
def parse_uri_for_body(url = 'https://api.privatbank.ua/p24api/pubinfo?json&exchange&coursid=5', ssl = true)
uri = URI.parse(url)
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = ssl
http.verify_mode = OpenS... |
class ChangeCoverFacebookIdToBigint < ActiveRecord::Migration
def change
change_column :covers, :facebook_id, :bigint
end
end
|
class User < ApplicationRecord
validates :name, presence: true, uniqueness: true, length: { in: 4..12 }
validates :email, uniqueness: true, presence: true
validates :password, presence: true, length: { in: 6..16 }
has_many :posts, dependent: :destroy
has_many :comments, dependent: :destroy
end
|
require 'rest_client'
require 'shoulda'
require 'yaml'
require 'aescrypt'
require 'bcrypt'
require 'base64'
require 'rest_client'
require 'shoulda'
require 'yaml'
require 'aescrypt'
require 'bcrypt'
require 'base64'
require 'factory_girl'
require 'uri'
require_relative '../app'
require_relative '../models/init'
require... |
class SnacksController < ApplicationController
before_action :authorized, only: [:buy]
def index
@snacks = Snack.all
render json: @snacks
end
def buy
@snack = Snack.find(params[:id])
@user_snack = UserSnack.create(snack: @snack, user: @user)
render json: @user_snack
end
end
|
class Student < ActiveRecord::Base
has_many :payments
belongs_to :course
end
|
class User < ApplicationRecord
attr_accessor :remember_token, :activation_token, :reset_token
has_many :orders, dependent: :destroy
has_one :giftcode, dependent: :destroy
validates :name, presence: true, length: {maximum: Settings.leng_name_max}
VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i
valid... |
# encoding: utf-8
# Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
module MobileCenterApi
module Models
#
# A single symbol upload entity
#
class SymbolUpload
# @return [String] The id for the... |
class CreateJournals < ActiveRecord::Migration
def change
create_table :journals do |t|
t.integer :profile_id, :null => false
t.integer :profile_pic_id
t.string :title, :limit => 80
t.string :url_title, :limit => 80
t.text :body
t.i... |
class AddProfileImgToCandidate < ActiveRecord::Migration
def change
add_column :candidates, :profile_img, :string
end
end
|
class NoteController < ApplicationController
before_action :checkUserAuthentication
def notebooks
@notebooks = EvernoteOAuth::Client.new(token: access_token).note_store.listNotebooks
end
def create_notebook
if params[:notebook_name].blank?
redirect_to('/notebooks')
... |
class Table
attr_accessor :set
def initialize
@set = DiceSet.new
6.times { @set.add(Dice.new.roll) }
end
def roll
@set.roll
end
def take(args)
@set.take(args)
end
def clone
new_table = Table.new
new_table.set = self.set.clone
new_table
end
def empty?
@set.empty?
... |
require_relative "spec_helper"
require_relative "../nested.rb"
def hopper
programmer_hash = {
:grass_hopper => {
:known_for => "COBOL"},
:languages => ["COBOL", "FORTRAN"]
}
end
end
def alan_kay_is_known_for
programmer_hash = {
:known_for => "Object Orientation"
}
end
end
... |
#!/usr/bin/env ruby
def File::u_plus_x file_name
File::chmod(File::stat(file_name).mode | 0700, file_name)
end
|
class Api::FriendsController < ApplicationController
def create
@friend = Friend.new(user_id: current_user.id, friend_id: params[:id])
@friend_request = FriendRequest.find_by(user_id: current_user.id, friend_id: params[:id])
@opposite_friend = Friend.new(user_id: params[:id], friend_id: current_user.id)
... |
require 'troles/strategy_helper'
User.troles_strategy :ref_many do |c|
c.valid_roles = [:user, :admin, :blogger, :editor]
end.configure!
Config.add_roles [:user, :admin, :editor, :blogger]
module UserSetup
def find_role name
Role.where :name => name.to_sym
end
def create_no_roles_user
Factory.crea... |
class SessionsController < ApplicationController
skip_before_action :require_login, only: [:new, :create]
skip_before_action :require_account, only: [:new, :create]
def new
end
def create
user = authenticate_session(session_params)
if sign_in(user)
redirect_to custom_dashboard_path
else
... |
require File.expand_path('../helper', __FILE__)
class PragmaticlyTest < Service::TestCase
def setup
@stubs = Faraday::Adapter::Test::Stubs.new
end
def test_push
@stubs.post "/projects/fake_uid/hooks" do |env|
assert_equal 'pragmatic.ly', env[:url].host
assert_equal 'application/json',
... |
class UserResource
def initialize(user)
@user = user
end
def toJson
{
username: @user.username,
email: @user.email
}
end
end
|
require 'iconv'
require 'nkf'
module BrowsingSupport
module Filter
def k2h(text)
return text if text.blank?
text = text.gsub('ヴ', 'う゛')
NKF.nkf('-w --hiragana', text)
end
def h2k(text)
return text if text.blank?
text = text.gsub('う゛', 'ヴ')
NKF.nkf('-w --katakana', t... |
require "fileutils"
require "rubygems"
require "aejis_backup/helpers"
require "aejis_backup/configuration"
module AejisBackup
class <<self
include AejisBackup::Helpers
def config_path(path=false)
path ? (@@config_path = path) : @@config_path
end
alias :config_path= :config_path
def confi... |
require "rails_helper"
module Clockface
RSpec.describe "clockface/events/delete.html.erb", type: :view do
let(:event) { Clockface::EventsPresenter.new(create(:event)) }
let(:captcha) { "abcde" }
before do
event
assign(:event, event)
assign(:captcha, captcha)
view.extend ConfigHel... |
# == Schema Information
#
# Table name: health_profiles
#
# id :integer not null, primary key
# animal_id :integer
# last_exam_date :date
# last_exam_location :string(255)
# heartworm_test_date :date
# heartworm_test_location :string(255)
# heartworm_... |
FactoryGirl.define do
factory :configuration do
config_key "MyString"
config_value "MyString"
unit "MyString"
end
end
|
class CreateRestaurantSpecials < ActiveRecord::Migration[5.0]
def change
create_table :restaurant_specials do |t|
t.date :data
t.text :desciption
t.references :special, foreign_key: true
t.references :restaurant, foreign_key: true
t.timestamps
end
end
end
|
Shindo.tests('Rackspace::Servers#delete_image', 'rackspace') do
tests('success') do
@server = Rackspace[:servers].servers.create(:flavor_id => 1, :image_id => 19, :name => 'foggetserverdetails')
@server.wait_for { ready? }
@image = Rackspace[:servers].images.create(:server_id => @server.id)
@image.wa... |
#! ruby -Ku
=begin
2015/08/01
日記を書くためスクリプト
日記のメイン処理
=end
require "fileutils"
require "kconv"
require "json"
require './method_input'
require './method_save_nikki'
############################################################
#ハッシュの日記データを、ファイルに書き込むためのテキストに変換する
def nikki_convert(data)
output_text = "" #配列... |
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Robots::DorRepo::Accession::EndAccession do
subject(:robot) { described_class.new }
let(:object) { build(:dro, id: druid, admin_policy_id: apo_druid) }
let(:apo) { build(:admin_policy, id: apo_druid) }
let(:druid) { 'druid:zz000zz0001' }
le... |
class CreateSupplements < ActiveRecord::Migration[5.0]
def change
create_table :supplements, id: :uuid do |t|
t.string :name
t.string :description
t.timestamps
end
create_table :effects, id: :uuid do |t|
t.integer :effectiveness_days, default: 30
t.references :supplement, t... |
require 'spec_helper'
describe Seedify::ParamReader do
before do
seed = @seed = Class.new
seed.extend(Seedify::ParamReader)
seed.param_reader(:email, default: 'a@b.c')
seed.param_reader(:count, type: :integer)
sub = @sub = Class.new(seed)
sub.param_reader(:name, default: 'Name')
end
it ... |
module Antlr4::Runtime
class LexerSkipAction < LexerAction
include Singleton
def initialize
@_hash = nil
end
def action_type
LexerActionType::SKIP
end
def position_dependent?
false
end
def execute(lexer)
lexer.skip
end
def hash
return @_hash ... |
class Transaction < ActiveRecord::Base
belongs_to :account
belongs_to :transferred_to, :class_name => 'Deposit', :foreign_key => 'transfer_transaction_id', :dependent => :destroy
belongs_to :transferred_from, :class_name => 'Payment', :foreign_key => 'transfer_transaction_id'
belongs_to :payee, :class_name => '... |
ActiveAdmin.register SubRep do
# See permitted parameters documentation:
# https://github.com/activeadmin/activeadmin/blob/master/docs/2-resource-customization.md#setting-up-strong-parameters
#
# permit_params :list, :of, :attributes, :on, :model
#
# or
#
# permit_params do
# permitted = [:permitte... |
module Web::Admin::NavbarHelper
def admin_menu_item(name, url, icon = nil)
title = name.is_a?(Class) ? name.model_name.human.pluralize(:ru) : name
if icon
menu_item url do
concat icon_element icon
concat ' '
concat title
end
else
menu_item title, url
end
end... |
require 'add_uniq_by_to_array'
module TwitterHelper
RAILS_CACHE_KEY = 'twitter.tweets.recent'
def build_recent_tweets_sidebar
tweets = recent_tweets
return if tweets.empty?
sidebar do
content_tag(:ul, :class => 'twitter') do
tweets.map do |tweet|
content_tag(:li, :class =>... |
class Note < ApplicationRecord
validates_presence_of :note
belongs_to :assessment
belongs_to :user
end
|
class Statistic < ActiveRecord::Base
# Associations
belongs_to :appearance
belongs_to :statistic_type
# Validations
validates_uniqueness_of :stat_type, scope: [:appearance_id]
TYPES = [
"SH", # Shots
"SG", # Shots on goal
"G", # Goals
"A", # Assists
"OF", # Offsides
"FD", # ... |
require 'rails_helper'
RSpec.feature 'Show category' do
scenario 'that exists' do
category = create(:category, name: 'Meals')
visit category_path(category)
expect(page).to have_text 'Meals'
end
end
|
class Spacecraft < ActiveRecord::Base
has_many :missions
has_many :pilots, through: :missions
def stdInfo
"Spacecraft Name: #{self.name}"
end
end
|
class AddHolescopeToTournaments < ActiveRecord::Migration
def change
add_column :tournaments, :holescope, :string
end
end
|
require "rails_helper"
RSpec.feature "Visitor", type: :feature do
include LoginHelper
context "that visits our welcome page" do
it "will see the navbar" do
visit root_path
expect(page).to have_content("Technically Employed")
expect(page).to have_content("View Jobs")
expect(page).to h... |
require File.dirname(__FILE__) + '/../test_helper'
class TraceControllerTest < ActionController::TestCase
fixtures :users, :gpx_files
set_fixture_class :gpx_files => 'Trace'
# Check that the list of changesets is displayed
def test_list
get :list
assert_response :success
assert_template 'list'
... |
module TagHelper
# 根据传入的tags数组,转成用于显示在list中的html代码
def show_tags_in_list(tags)
if tags.blank?
return content_tag(
:div,
content_tag(:span, '没有标签', :class => 'name'),
:class => 'no-tag'
)
end
raw tags.map{|tag|
content_tag(
:div,
... |
# -*- coding: utf-8 -*-
class Advertisement < ActiveRecord::Base
INSIDE_TYPE = 1
OUTSIDE_TYPE = 2
TOPPAGE_TYPE = 3
NOT_PUBLISHED = 1
PUBLISHED = 2
STATE = { PUBLISHED => 'published', NOT_PUBLISHED => 'unpublished'}
SHOW_IN_HEADER = { true => "show", false => 'hidden'}
SIDE_TYPE = {INSIDE_TYPE => 'pref... |
# == Schema Information
#
# Table name: accounts
#
# id :integer not null, primary key
# number :string
# company :string
# inn :string
# kpp :string
# bik :string
# created_at :datetime not null
# updated_at :d... |
class MomentumCms::Site < ActiveRecord::Base
# == MomentumCms ==========================================================
self.table_name = 'momentum_cms_sites'
# == Constants ============================================================
REMOTE_FIXTURE_TYPE = [
'http',
'ssh'
].freeze
# == Relation... |
# coding: utf-8
require File.expand_path('../lib/vagrant-clone/version', __FILE__)
Gem::Specification.new do |spec|
spec.name = 'vagrant-clone'
spec.version = VagrantClone::VERSION
spec.authors = ['Alexander Kaluzny']
spec.email = ['galiaf1995@gmail.com']
spec.summary = 'P... |
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 login!(user)
@current_user = user
session[:session_token] = user.reset_session_token!
end
def logout... |
# Configure ActionMailer SMTP settings
ActionMailer::Base.smtp_settings = {
:address => 'localhost',
:port => 25,
:domain => 'localhost',
}
# Monkey patch to allow sending of messages in specific locales
module ActionMailer
class Base
adv_attr_accessor :locale
private
alias_method :old_render_messag... |
class UsersController < ApplicationController
respond_to :json, only: [:api_sign_in, :api_sign_out]
def api_sign_in
# params { user: { email: , password: } }
# JWT - Json Web Token
user = User.find_by_email(params[:user][:email])
if user.blank?
render json: { success: false, error: "User not ... |
#
# Author:: Celso Fernandes (<fernandes@zertico.com>)
# © Copyright IBM Corporation 2014.
#
# LICENSE: MIT (http://opensource.org/licenses/MIT)
#
Shindo.tests("Fog::DNS[:softlayer] | Domains model", ["softlayer"]) do
@service = Fog::DNS[:softlayer]
tests("success") do
tests("#create") do
name =... |
#Implement min in O(1) in a stack
class Stack
attr_accessor :top, :min_top
class Node
attr_accessor :next, :data
def initialize(data)
@data = data
@next = nil
end
end
def initialize
@top = nil
@min_top = nil
end
def addToTop(data, top)
node = Node.new(data)
n... |
module AccountsHelper
def new_account_link
link_to(new_account_path, :class=>"btn btn-large btn-success") do
content_tag(:i, "", :class => "") + t("accounts.new.title")
end
end
def delete_account_link(account)
link_to(account, method: :delete, data: { confirm: 'Are you sure?', :class=>"confi... |
module Brcobranca
module Remessa
module Cnab240
class Bradesco < Brcobranca::Remessa::Cnab240::Base
# Logradouro da Empresa - Nome da Rua, Av, Pça, Etc
attr_accessor :logradouro
# Numero da Empresa - Numero do Local
attr_accessor :numero
# Complemento da Empresa - Ca... |
if ENV["CODECLIMATE_REPO_TOKEN"]
require 'codeclimate-test-reporter'
CodeClimate::TestReporter.start
end
require "rubygems"
ENV["RAILS_ENV"] ||= 'test'
ENV["SECRET_TOKEN"] = "TEST123"
ENV["DEVISE_SECRET_KEY"] = "TEST_DEVISE_123"
require "rails/application"
# https://github.com/timcharper/spork/wiki/Spork.trap_met... |
require 'test/test_helper'
require 'flog'
require 'sexp_processor'
describe "Flog Command Line" do
before :each do
@flog = Flog.new({})
end
describe 'flog_files' do
describe 'when given empty input' do
before :each do
@files = ['/empty/empty.rb']
end
it 'should not fail when ... |
class ReviewTemplatesController < ApplicationController
before_action :set_review_template, only: [:show, :edit, :update, :destroy]
# GET /review_templates
# GET /review_templates.json
def index
@review_templates = ReviewTemplate.all
end
# GET /review_templates/1
# GET /review_templates/1.json
def... |
class ReviewQuestionInstance < ActiveRecord::Base
# validates_numericality_of :value, :on => :create, :message => "is not a number", :greater_than_or_equal_to => 1, :less_than_or_equal_to => 5
has_many :review_answers
belongs_to :account
belongs_to :review_question
belongs_to :campaign
has_many :review_form... |
require 'sidekiq/api'
module JobService
extend self
def start(_name, owner, *args)
options = args.extract_options!
job = Job.find_or_initialize_by jobable: owner, job_type: options[:type]
job.status = "pending"
job.start_at = Time.now
job.save
klass = "::#{_name.to_s.camelize}Job".safe_c... |
require "minitest/autorun"
<<<<<<< HEAD
require_relative "change_maker2.rb"
class TestChangeMaker < Minitest::Test
def test_change_is_0
assert_equal({"quarters" => 0, "dimes" => 0, "nickels" => 0, "pennies" => 0}, change_maker(0))
end
def test_change_is_1
assert_equal({"quarters" => 0, "dimes" => 0, "nickels"... |
#!/usr/bin/ruby
require 'pry'
require_relative 'queue.rb'
@verbose = true
Gamestate =
Struct.new('Gamestate',
:boss_hp, :boss_dmg,
:player_hp, :player_mana, :player_armour,
:effects, :player_turn, :mana_spent)
Spell = Struct.new('Spell', :name, :cost, :damage, :heal, :effect)
... |
# frozen_string_literal: true
FactoryGirl.define do
factory :user do
sequence :uid { |n| "abc#{n}" }
first_name 'First'
last_name 'Last'
sequence :email { |n| "user#{n}@resuelve.mx" }
last_sign_in_at Time.now
factory :admin { admin true }
factory :inactive_user { active false }
end
end... |
module ConsoleUtils
module JSONOutput
extend ActiveSupport::Autoload
class ParseError < StandardError
def initialize(original_message = nil)
super("Failed to format a json. (#{original_message})")
end
end
eager_autoload do
autoload :BaseFormatter
end
autoload :Defa... |
class Song
attr_reader :name, :artist, :genre
@@count = 0
@@artists = []
@@genres = []
def initialize(name, artist, genre)
@name = name
@artist = artist
@genre = genre
@@count += 1
@@artists.push(@artist)
@@genres.push(@genre)
end
def self.count
@@count
end
def self.artists
@@artists.... |
class RenameKeyToIdentifier < ActiveRecord::Migration
def up
rename_column :movies, :key, :identifier
end
def down
rename_column :movies, :identifier, :key
end
end
|
class AddDefaultToPlatform < ActiveRecord::Migration
def change
change_column :users, :platform, :string, null: false, default: "ios"
end
end
|
class RemoveWeightFromAnimals < ActiveRecord::Migration
def change
remove_column :animals, :weight
remove_column :animals, :weight_measure
end
end
|
class AddPriceRangeToRestaurant < ActiveRecord::Migration
def change
add_column :restaurants, :price_from, :string , :limit => 7
add_column :restaurants, :price_to, :string , :limit => 7
end
end
|
template "/etc/launchd.conf" do
source "launchd.conf.erb"
mode "0644"
end |
class AddCustomerIdToBookingRequest < ActiveRecord::Migration[6.0]
def change
add_reference :booking_requests, :customer
end
end
|
require 'rails_helper'
RSpec.describe Gig, type: :model do
it 'validates all attributes' do
gig = Gig.new(:cost => 15, :start_time => nil, :end_time => nil, :name => "Date Night", :description => "Bedtimes at 8pm, try not to give too many snacks!", :parent_id => 1, :sitter_id => 1)
expect(gig).to have_attrib... |
class NodeSupportContractAssignmentsController < ApplicationController
# sets the @auth object and @object
before_filter :get_obj_auth
before_filter :modelperms
# POST /node_support_contract_assignments
# POST /node_support_contract_assignments.xml
def create
support_contract = SupportContract.find(par... |
class Trainer < ApplicationRecord
validates :name, :gender, presence: true
validates :status_active, inclusion: { in: [true, false] }
validates :name, uniqueness: true
validates :wins, :losses, numericality: { greater_than_or_equal_to: 0 }
has_many :teams , dependent: :destroy
has_many :pokemons, through: ... |
module TableHelper
def build_table(headers, collection)
render "shared/table", headers: headers, collection: collection
end
def get_row_to_render(item)
case item.class.name.underscore.to_sym
when :bookmark
bookmark_row(item)
when :site
site_row(item)
when :tag
tag_row(item)
... |
require 'net/http'
module WackyGraph
GRAPH_BASE_URI = 'http://graph.facebook.com'
SECURE_GRAPH_BASE_URI = 'https://graph.facebook.com'
class GraphRequest
attr_accessor :oauth_token
def initialize(oauth_token)
@oauth_token = oauth_token
end
def get(path, options = {})
uri = build_ur... |
class AddRollNumberColumnToTables < ActiveRecord::Migration
def self.up
add_column :courses,:roll_number_prefix,:string
add_column :batches,:roll_number_prefix,:string
add_column :students,:roll_number,:string
add_column :archived_students,:roll_number,:string
add_column :batch_students,:roll_numb... |
class AddOrderNumberToInvoiceIngredients < ActiveRecord::Migration
def change
add_column :invoice_ingredients, :order_number, :integer
end
end
|
# frozen_string_literal: true
# == Schema Information
#
# Table name: quiz_trials
#
# id :integer not null, primary key
# quiz_id :integer not null
# user_id :integer not null
# created_at :datetime not null
# updated_at :datetime not null
# finished_a... |
require 'rubygems'
require 'sinatra'
require 'mdb/client'
require 'blog'
# The BlogApp implements the View and Controller parts of the MVC pattern.
# This app receives end user http requests, invokes a model method (through
# a "view"), and then renders the appropriate view from the model data.
#
# Run by MRI
# Liste... |
require 'factual/query/base'
class Factual
module Query
class Monetize < Base
VALID_PARAMS = [
:filters, :search, :geo,
:limit, :offset
]
def initialize(api, params = {})
@path = "places/monetize"
@action = :read
super(api, params)
end
VA... |
class TweetWorker
include Sidekiq::Worker
def perform(tweet_id)
tweet = Tweet.find(tweet_id)
user = tweet.user
puts "========================================"
puts "User: #{user}"
puts "User: #{user.inspect}"
puts "Tweet: #{tweet}"
puts "Tweet: #{tweet.inspect}"
# set up Twitter ... |
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
before_filter :configure_permitted_parameters, if: :devise_controller?
before_filter :set_current_user
before_filt... |
Then(/^I verify "([^"]*)" with built expected response$/) do |variable_name|
expected_response = Helper.get_stored_value('expected_response')
actual_response = Helper.get_stored_value(variable_name)
expected_response.to_json.should be_json_eql(actual_response.to_json).excluding('password')
end
Then(/^I verify "(... |
class CreateRecipes < ActiveRecord::Migration[4.2]
def change
create_table :recipes do |r|
r.string :name
r.string :meal_of_the_day
r.string :description
r.string :method
r.timestamp
r.float :rating
end
end
end
|
class User < ApplicationRecord
has_many :authorizations
has_many :rates
has_many :reviews, dependent: :destroy
has_many :requests, dependent: :destroy
has_many :active_relationships, class_name: "Relationship",
foreign_key: "follower_id",
dependent: :destroy
has_many :passive_relationships, clas... |
require "yaml"
def load_library(emoticons)
emoticons = YAML.load_file(emoticons)
get_meaning = {}
get_emoticon = {}
emoticons.each_pair do |meaning, emoji_array|
english = emoji_array[0]
japanese = emoji_array[1]
get_meaning[japanese] = meaning
get_emoticon[english] = japanese
end
emoji_has... |
class VideoService
attr_reader :video_file_path
def initialize(params)
@video_file = params[:video][:video_file]
@video_name = format_name @video_file.original_filename
@poster_file = params[:video][:poster_file]
@poster_name = format_name @poster_file.original_filename
... |
class User < ActiveRecord::Base
has_secure_password
validates :email, presence: true
validates :password, presence: true
end
|
class OrganizationsController < ApplicationController
def index
@organizations = Organizations.all
render json: @organizations
end
end
|
class ApplicationController < ActionController::Base
before_action :authenticate_user!,except: [:top, :about]
before_action :configure_permitted_parameters, if: :devise_controller?
def after_sign_up_path_for(resource)
flash[:notice] = "Welcome! You have signed up successfully."
user_path(resource.id)
end
def after_... |
# frozen_string_literal: true
ActiveAdmin.register ::V2::Origin do
permit_params :name, :attribution_text
menu label: "Origins (v2)", priority: 100
scope :all, default: true
actions :index, :show, :edit, :update
index do
column :code do |origin|
link_to origin.name, v2_v2_origin_path(origin)
e... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.