text stringlengths 10 2.61M |
|---|
class TasksController < ApplicationController
def index
@title = "Tasks"
#@Tasks = Task.order("created_at DESC")
@Tasks = Task.where(:status => nil, :project_id => params[:project_id]).order("created_at DESC")
@Tasks_sip = Task.where(:status => false, :project_id => params[:project_id])
@T... |
require File.dirname(__FILE__) + '/helper'
context "ActiveRecord Adapter" do
context "Select" do
specify "simple ==" do
sql = User.select { |m| m.name == 'jon' }.to_s
sql.should == "SELECT * FROM users WHERE users.name = 'jon'"
end
specify "simple !=" do
sql = User.select { |m| m.name ... |
FactoryBot.define do
factory :zip_code do
zip { 2131 }
city { "Rozzie" }
state { "MA" }
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 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 RenameProductAdditionalInfos < ActiveRecord::Migration
def change
rename_table :product_additional_infos, :product_specifications
end
end
|
class Evenement < ApplicationRecord
mount_uploader :picture, EventUploader
belongs_to :category
belongs_to :organisateur
has_many :commentaires
has_one :section
end
|
# require 'test_helper'
# class UpdateAdminTest < ActiveSupport::TestCase
#
# setup do
# @new_name = 'New Name'
# end
#
# teardown do
# Admin.destroy_all
# end
#
# test 'Update Admin interactor exists' do
# class_exists?(UpdateAdmin)
# end
#
# test 'successful update' do
# admin = create(:... |
class SynchronizationsController < ApplicationController
def index
if current_organization
@synchronizations = Maestrano::Connector::Rails::Synchronization.where(organization_id: current_organization.id).order(updated_at: :desc).limit(40)
end
end
end |
Given(/^I am on the homepage$/) do
visit '/'
end
When(/^I follow "(.*?)"$/) do |text|
click_link text
end
Then(/^I should see "(.*?)"$/) do |content|
expect(page).to have_content content
end
Given(/^I am on the sign up page$/) do
visit '/new_player'
end
When(/^I enter my name$/) do
fill_in :playername, :wit... |
# frozen_string_literal: true
module Complicode
VERSION = "1.0.1"
end
|
module Enjoy::Pages::Blocksetable
extend ActiveSupport::Concern
included do
helper_method :render_blockset
helper_method :blockset_navigation
end
private
def blockset_navigation(type)
Proc.new do |primary|
SimpleNavigation.config.autogenerate_item_ids = false
begin
blockset_na... |
class Spokes
def initialize(index)
@index = index
end
SPOKES = [
->(n) { 3 * n**2 - 2 * n + 1 },
->(n) { 3 * n**2 - n + 1 },
->(n) { 3 * n**2 + 1 },
->(n) { 3 * n**2 + n + 1 },
->(n) { 3 * n**2 + 2 * n + 1 },
->(n) { 3 * n**2 + 3 * n + 2 },
]
INVERSES = [
->(... |
package_options = ''
platform_family = node['platform_family']
platform_version = node['platform_version'].to_i
case platform_family
when 'debian'
package_options = '--force-yes -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confnew"'
include_recipe 'apt'
package 'apt-transport-https'
apt_... |
require 'gtk3'
#====== La classe BoutonGrilleA caractérise la grille de jeu représentée à l'aide de boutons en guise de cases sur l'interface
class BoutonGrille
#=Variable d'instance
# @bouton : Le bouton
# @coordI, @coordJ : Coordonnées du bouton
attr_reader :coordJ
attr_reader :coordI
attr_read... |
json.employers do |json|
json.array! @employers do |emp|
json.id emp.id
json.first_name emp.first_name
json.last_name emp.last_name
json.avatar emp.avatar
json.full_name emp.full_name
json.email emp.email
json.contact emp.contact
json.code_num emp.code... |
class CreateListings < ActiveRecord::Migration
def change
create_table :listings do |t|
t.integer :lister_id, null: false
t.string :title, null: false
t.string :description, null: false
t.string :neighborhood, null: false
t.date :start_date, null: false
t.date :end_date, null:... |
require 'spec_helper'
describe Guard::DslDescriber do
let(:describer) { ::Guard::DslDescriber }
let(:guardfile) do
<<-GUARD
guard 'test', :a => :b do
watch('c')
end
group :a do
guard 'test', :x => 1 do
watch('c')
end
end
group "b" do
g... |
require 'spec_helper'
describe ClientsController do
before(:each) do
@controller.stub(:authenticate_user!)
@controller.stub(:has_admin_credentials?)
end
def valid_attributes
{:name => "Test", :description => "Test", :user_attributes => {:email=> "test@test.com", :password => "password", :password_co... |
# Definition for a binary tree node.
# class TreeNode
# attr_accessor :val, :left, :right
# def initialize(val)
# @val = val
# @left, @right = nil, nil
# end
# end
# @param {TreeNode} t
# @return {String}
def tree2str(t)
return "" if t == nil
root = t.val
left = tree2str(t.left)
r... |
module Shop
class BasketProducts
def fetch_info
grouped_products = BASKET_PRODUCTS.group_by { |prod| prod.type_id }
grouped_products.map do |product_type_id, products|
product_info = ProductsInfo.new.fetch.find { |prod_info| prod_info.type_id == product_type_id }
{
type_id:... |
class CreateServiceCache < ActiveRecord::Migration
def change
enable_extension 'hstore' unless extension_enabled?('hstore')
create_table :service_caches do |t|
t.string :service
t.string :key
t.hstore :data
t.timestamps null: false
end
end
end
|
class Event < ApplicationRecord
has_many :invites
has_many :users, through: :invites
belongs_to :user
end
|
class Board
attr_reader :board, :current_turn, :game_over
def initialize
@board = [
0, 1, 2,
3, 4, 5,
6, 7, 8
]
@current_turn = "X"
@game_over = false
end
def show_board
print @board[0..2]
print "\n"
print @bo... |
class AddProjectRefToContributions < ActiveRecord::Migration
def change
add_reference :contributions, :project, index: true, foreign_key: true
end
end
|
require "rails_helper"
RSpec.describe UserMailer, :type => :mailer do
let(:user) { Fabricate(:user,
email: "bob@gmail.com") }
let(:mail) { UserMailer.activation_needed_email(user) }
describe "activation_needed_email" do
it "successfully renders the headers" do
expect(mail.... |
class AddAcceptCheckboxes < ActiveRecord::Migration
def up
add_column :users, :accepted_terms_and_privacy, :boolean, default: false
add_column :users, :accepted_waiver, :boolean, default: false
end
def down
remove_column :users, :accepted_terms_and_privacy
remove_column :users, :accepted_waiver
end
end
|
# == Schema Information
#
# Table name: task_notes
#
# id :integer not null, primary key
# task_id :integer
# description :text
# percent_complete :integer
# created_at :datetime not null
# updated_at :datetime not null
# task_type :string(255)... |
# require 'bundler/setup'
require 'rack'
require 'yaml'
require "erb"
SDB= "database.yml"
require __FILE__.sub('config.ru','pipe.rb')
class Web
def self.req
@req
end
def self.folder
@folder||=__FILE__.sub('config.ru','')
end
def self.pipe_index
str = "<table><tr><th>ID</th><th>Name</th><th>I... |
# Write a method that takes two arguments, a string and a positive integer, and prints the string as many times as the integer indicates.
=begin
approach:
- use the times method to print out the string as many times as required
=end
def print_times(string, number)
number.times { puts string }
end
print_times('b... |
# -*- encoding : utf-8 -*-
class LogEntry < ActiveRecord::Base
validates_presence_of :log, :admission, :group, :applicant, :member
belongs_to :applicant
belongs_to :admission
belongs_to :group
belongs_to :member
default_scope order: "created_at ASC"
end
# == Schema Information
# Schema version: 201304221... |
# == Schema Information
#
# Table name: music_difficulties
#
# id :integer not null, primary key
# difficulty :string
# level :string
# music_id :integer
# created_at :datetime not null
# updated_at :datetime not null
# rating_base :float default(0.0), not... |
FactoryBot.define do
factory :tournament do
rule_id { Faker::Number.within(range: 1..7) }
title { Faker::Game.title[1..20] }
max_user_count { [8,16,32][Faker::Number.within(range: 0..2)]}
incentive_title { Faker::Superhero.prefix }
target_match_score { [3,5,7,10][Faker::Number.within(range: 0..3)]... |
class Guild < ApplicationRecord
belongs_to :owner, class_name: 'User', foreign_key: 'owner_id'
has_many :memberships, class_name: 'GuildMembership', dependent: :destroy
has_many :war_statuses
has_many :requests, through: :war_statuses
has_many :wars, through: :requests
has_many :users, through: :memberships... |
class ChangeCountColumnToAttachedImage < ActiveRecord::Migration[5.1]
def change
rename_column :attached_images, :count, :media_id
add_index :attached_images, :media_id, unique: true
remove_column :hashtags, :count
end
end
|
module Admin::Controllers::Home
class ProcessCommand
include Admin::Action
def call(params)
redirect_if_not_signed_in('Attempt to execute a command without being signed in')
redirect_if_level_insufficient(1,'Attempt to execute a command by user with insufficient level')
@user = current_us... |
class PlacementRegistration < ActiveRecord::Base
belongs_to :student
belongs_to :placementevent
validates_uniqueness_of :student_id, :scope => :placementevent_id
def member
student = self.student
student ||= ArchivedStudent.find_by_former_id(self.student_id)
end
# def check_student_invitation?... |
module StrokeDB
module StrokeObjects
# Included in a StrokeDB object.
# Relies on #has_slot? method.
module LazyAccessors
# This method catches slot access calls (obj.slot, obj.slot=).
# Slot accessors are created on the fly.
Ceq = "="
R_0_minus2 = (0..-2)
def method_missing... |
class AddClosedateToJobs < ActiveRecord::Migration
def change
add_column :jobs, :closedate, :datetime
end
end
|
# == Schema Information
#
# Table name: reservations
#
# id :integer not null, primary key
# startDate :date
# endDate :date
# room_id :integer
# created_at :datetime not null
# updated_at :datetime not null
#
class Reservation < ActiveRecord::Base
attr_accessible :start... |
class CreateCompanies < ActiveRecord::Migration
def change
create_table :companies do |t|
t.references :user, index: true
t.text :nombre
t.text :razon_social
t.text :descripcion
t.string :rfc
t.text :calle_numero
t.text :colonia
t.integer :numero_postal
t.stri... |
#-// 10/07/2012
#-// 10/07/2012
$simport.r 'iei/spritix', '1.0.0', 'IEI Spritix'
#-inject gen_module_header 'IEI::Spritix'
module IEI
module Spritix
@@spx_funcs = {}
def self.add_spx sym,&func
@@spx_funcs[sym] = func
end
add_spx :flip_horz do |sp,*params|
tween_struct, = params
tween... |
# frozen_string_literal: true
require 'common/models/base'
module EVSS
module PPIU
class PaymentAddress
include Virtus.model
attribute :type, String
attribute :address_effective_date, DateTime
attribute :address_one, String
attribute :address_two, String
attribute :address_t... |
class AdminsController < ApplicationController
# before_filter :authorize_admin, only: [:new, :create, :edit]
# before_action :zero_authors_or_authenticated, only: [:new, :create]
# before_action :require_login
def index
# current_user.articles
# render layout: false
@admin... |
# Object Oriented Programming is a programming paradigm that
# was created to deal with the growing complexity of large
# software systems. Programmers found out very early on that
# as applications grew in complexity and size, they became
# very difficult to maintain. One small change at any point
# in the program w... |
class CreateProducts < ActiveRecord::Migration[5.0]
def change
create_table :products do |t|
t.string :title
t.text :description
t.integer :cost
t.integer :price
t.string :created_on
t.string :cover_image
t.string :tag
t.boolean :display
t.timestamps
end
... |
require 'test_helper'
class BaseTest < Test::Unit::TestCase
context "vimeo advanced base" do
setup do
@base = Vimeo::Advanced::Base.new("12345", "secret")
end
should "generate a valid web based authentication login link" do
link = @base.web_login_link("delete")
asser... |
RailsAdmin.config do |config|
config.main_app_name = ['Booking Sports', 'Панель управления']
config.authenticate_with do
warden.authenticate! scope: :user
end
config.current_user_method(&:current_user)
config.authorize_with :cancan
config.audit_with :paper_trail, 'User', 'PaperTrail::Version'
con... |
require 'rails_helper'
require 'spec_helper'
RSpec.describe MovieSearchFacade do
before(:each) do
@movie_facade = MovieSearchFacade.new
end
it "exists" do
expect(@movie_facade.class).to eq(MovieSearchFacade)
end
describe "instance_methods" do
it "top_40" do
result = @movie_facade.top_40
... |
spec = Gem::Specification.new do |s|
s.name = 'autogg'
s.summary = 'converts a folder of flacs to ogg, preserving directory structure'
s.requirements << 'oggenc must be installed on the base system'
s.version = "0.2.5"
s.author = 'Evan Simmons'
s.email = 'esims89@gmail.com'
s.homepage = 'https:... |
require 'test/unit'
require 'soap/rpc/standaloneServer'
require 'soap/rpc/driver'
module SOAP; module ASPDotNet
class TestASPDotNet < Test::Unit::TestCase
class Server < ::SOAP::RPC::StandaloneServer
Namespace = "http://localhost/WebService/"
def on_init
add_document_method(
self,
N... |
module EARMMS::DashboardHelpers
def branch_meetings
EARMMS::Branch.all.map do |b|
now = DateTime.now()
yesterday = now - 1
yesterday = DateTime.civil(yesterday.year, yesterday.month, yesterday.day, 23, 59, 59)
twoweeks = yesterday + 14
upcoming = EARMMS::BranchMeeting.where(branch: ... |
require 'rails_helper'
RSpec.describe Apps::IntegrationsController, type: :controller do
let(:user) { create(:user) }
let(:app) { create(:app, user: user) }
before(:each) { login(user) }
describe "GET #index" do
it "returns a success response" do
create(:integration, app: app)
get :index, para... |
require "application_system_test_case"
class DummyUsersTest < ApplicationSystemTestCase
setup do
@dummy_user = dummy_users(:one)
end
test "visiting the index" do
visit dummy_users_url
assert_selector "h1", text: "Dummy Users"
end
test "creating a Dummy user" do
visit dummy_users_url
cli... |
class Role < ApplicationRecord
belongs_to :employee, optional: true
end
|
class ShoutsController < ApplicationController
def new
@shout = Shout.new
end
def create
@shout = Shout.new(params[:shout])
@shout.user_id = User.first.id
if @shout.save
redirect_to shouts_path
else
render :new
end
end
def index
@shouts = Shout.order('created_a... |
module CostCalculations
extend ActiveSupport::Concern
included do
def kwatts_to_cost(kwatts)
{
name: plan.name,
calculated_kwatts_cost: (kwatts * kwatt_cost).to_s[0..3]
}
end
end
end
|
# Suite of tests covering Review testing Invalid Postcode
#
# These helpers enable you to clear out all default LOCALE data, load specic yaml as locale,
# and then re-instate the default locale data
#
# You can load a string of yaml via command :
#
# I18n.backend.store_translations(:en, YAML.load(yaml))
#
RSpec.shared... |
# frozen_string_literal: true
module Vedeu
module Coercers
# Coerces a colour options hash into: an empty hash, or a hash
# containing either or both background and foreground keys.
#
# @api private
#
class ColourAttributes
include Vedeu::Common
# @param value [Hash]
# @... |
class TicTacToe
def initialize(board = nil)
@board = board || Array.new(9, " ")
end
# Define your WIN_COMBINATIONS constant
WIN_COMBINATIONS = [
[0,1,2], # Top row
[3,4,5], # Middle row
[6,7,8], # Bottom row
[0,3,6],
[1,4,7],
[2,5,8],
[0,4,8],
[2,4,6]
]
#display_board... |
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
def after_sign_in_path_for(resource)
send("#{resource.type.downcase}_root_path")
end
end
|
require_relative '../../../lib/tax_calculator/tax_applier'
RSpec.describe TaxCalculator::TaxApplier do
subject(:applier) { described_class.new(product) }
describe "#apply" do
context 'when product in exempt from normal taxes' do
let(:product) do
double(
'product',
name: 'pill... |
class AddImgUploaderToProdImage < ActiveRecord::Migration
def change
add_column :product_images, :prod_img, :string
end
end
|
class InjuriesController < ApplicationController
#before_action :authenticate_user!
helper_method :sort_column, :sort_direction
def index
require_login
if (params.has_key?(:date) && params[:category] == "date") #EDIT HERE, CHECK IF DATE IS ATTACHED
@injuries = ... |
require_relative 'tile'
class Board
attr_reader :checked_pos, :bomb_pos #FIX ME
def initialize(size = 9, num_bombs = 10)
@grid = Array.new(size) do |row|
Array.new(size) {Tile.new}
end
@num_bombs = num_bombs
@got_bombed = false
@bomb_pos = place_bombs(num_bombs)
@num_flags_left = nu... |
require 'gooddata'
require 'csv'
require 'prettyprint'
class GoodSuccess
def initialize(username, password)
@client = GoodData.connect(username, password, server: 'https://engagement.gooddata.com' )
@project_goodsuccess = @client.projects('d0yaqkwwo0ej2fyai2l2t9m4e4bjggsw');
end
def get_top_usage_work... |
module SheetSync
module Download
class TweetReviewDownloader
attr_reader :row
def initialize(row, row_parser: TweetReviewRowParser,
review_syncer: ReviewSyncer,
sync_policy: TweetReviewSyncPolicy,
review_tweet_finder: ReviewTweetFinder,
... |
# Given the following data structure use a combination of methods, including either the select or reject method, to return a new array identical in structure to the original but containing only the integers that are multiples of 3.
arr = [[2], [3, 5, 7], [9], [11, 13, 15]]
new_arr = arr.map do |sa|
sa.select do |e|... |
class CreateFastaFiles < ActiveRecord::Migration
def self.up
create_table :fasta_files do |t|
t.string :label
t.string :fasta_file_name, :fasta_content_type
t.integer :fasta_file_size
t.boolean :is_generated, :default => false
t.integer :project_id, :null => false
t.integer :u... |
ActiveAdmin.register Order, as: "Ordenes_no_verificadas" do
actions :all, :except => [:show, :new, :edit]
filter :created_at, as: :date_range, label: "Fecha de creación"
filter :order_number, label: "Número de orden"
filter :company, label: "Empresa"
filter :users, collection: -> { User.all.map { |user| [us... |
class CrimeVictimsController < ApplicationController
before_action :set_crime_victim, only: [:show, :edit, :update, :destroy]
# GET /crime_victims
# GET /crime_victims.json
def index
@crime_victims = CrimeVictim.all
@crime_victim = CrimeVictim.where(:crime_id => params[:crime])
@victim_excel = Vict... |
class CommentsController < ApplicationController
before_action :authenticate!, only: %i[create update destroy]
before_action :set_comment, only: %i[update destroy]
before_action :authorize!, only: %i[update destroy]
def index
if params[:review_id]
@comments = Comment.where(review_id: params[:review... |
ActiveAdmin.register Song do
permit_params :track_no, :name, :artist_id, :album_id, :year, :file,
category_ids: []
config.sort_order = "name_asc"
controller do
def scoped_collection
super.includes :album, :artist, :categories
end
end
filter :name
filter :artist, collection: ->{Artist.or... |
class Person < ActiveRecord::Base
validates_presence_of :name, :item, :quantity, :price
end
|
class Book < ApplicationRecord
# This file breaks the SOLID principles. How would you refactor?
def url_name
"book-#{id}-#{title.parameterize}"
end
def pdf_url
# Oops... it breaks the rubocop's ABC size rule... How could we do better?
case editor
when 'seuil'
Seuil.get_book(isbn: isbn).g... |
class Edu::Ugroup < ActiveRecord::Base
include Concerns::Edu::GroupEnrolls
include Concerns::Edu::Contestable
resourcify :roles, role_cname: "Acn::Role"
def teacher
return nil if self.roles.size == 0
User.joins(:roles).where(acn_roles: {id: self.roles[0].id }).first
end
def removable
true
en... |
class UserController < ApplicationController
private
def resource_params
params.require(:resource).permit(:login)
end
end
|
require 'spec_helper'
describe ApplicationController do
describe "#route" do
context "when user logged out" do
it "should redirect to root url" do
get :route
expect(response).to redirect_to(new_user_session_path)
end
end
context "with logged in user" do
before(:each) {... |
require 'chef/knife'
ATTRIBUTE_CLASSES = [:normal, :default, :override]
module KnifeNodeAttribute
module Helpers
def get_node(name)
puts "Looking for an fqdn of #{name} or name of #{name}"
searcher = Chef::Search::Query.new
result = searcher.search(:node, "fqdn:#{name} OR name:#{name}")
... |
class Evaluation < ActiveRecord::Base
belongs_to :order
validates_presence_of :rating_pizzeria, :rating_service, :rating_pizza, allow_blank: true
end
|
class ChangeDiscountCartitem < ActiveRecord::Migration
def self.up
remove_column :cartitems, :discount
add_column :cartitems, :discount, :decimal
end
def self.down
end
end
|
class UserSessionsController < ApplicationController
before_filter :required_login, :only => :destroy
# - GET /account/login
#
def new
@user = User.new
end
# - POST /account/session
#
def create
if @user = User.find_and_authenticate(params[:user])
flash[:notice] = 'Login successfull'
... |
module Api::V1::Customers
class InvoiceDetailsController < CustomerUsersController
include Serializable
before_action :set_invoice_details, only: %i[destroy update]
before_action :invoice_belongs_to_customer?, only: %i[destroy update]
def index
invoices = current_user.invoice_details.where(dele... |
class RenameColumnToUserItem < ActiveRecord::Migration
def change
rename_column :user_items, :user_id, :user_group_id
end
end
|
module Api
module V1
class ApiController < ApplicationController
include JSONAPI::ActsAsResourceController
rescue_from Pundit::NotAuthorizedError, with: :user_not_authorized
protect_from_forgery with: :null_session
private
def context
{user: pundit_user}
end
d... |
require 'spec_helper'
describe Subscription do
Plan.delete_all
let(:user) { FactoryGirl.create(:user) }
let(:basic) { FactoryGirl.create(:plan, :id => "1", :level => 'Basic') }
let(:plus) { FactoryGirl.create(:plan, :id => "2", :level => 'Plus') }
before do
card = { number: '4242424242424242', exp_month... |
class AddColumnsAwards < ActiveRecord::Migration[6.1]
def change
add_column :awards, :best_film, :string
add_column :awards, :best_director, :string
add_column :awards, :best_actor, :string
add_column :awards, :best_actress, :string
add_column :awards, :best_supporting_actor, :string
add_colum... |
module CDI
module V1
class SimpleEducationalInstitutionSerializer < ActiveModel::Serializer
root false
attributes :id,
:name,
:about,
:profile_image_url,
:profile_cover_image_url,
:profile_images,
:... |
# Numbers to Commas Solo Challenge
# I spent [3.5] hours on this challenge.
# Complete each step below according to the challenge directions and
# include it in this file. Also make sure everything that isn't code
# is commented in the file.
# 0. Pseudocode
# input: integer
# output: comma separated ineger as a str... |
require 'rebase_attr'
class RebaseWithAccessorTestBase
attr_accessor :x
end
class RebaseWithoutAccessorTestBase
def method_missing(method, *args, &block)
case method
when :x
@x
when :x=
@x = args.first
else
super
end
end
end
# This converts options to local var... |
# frozen_string_literal: true
# How you log into the system
class LoginsController < ApplicationController
layout 'session'
def show
redirect_to root_path if current_user
end
def create
login(request.env['omniauth.auth'])
redirect_to root_path
end
end
|
module HomePagesHelper
def is_admin?
current_user.admin?
end
end
|
# frozen_string_literal: true
require_relative '../../test_helper'
class Commands::Urls::ScrapeUrlTest < TestCase
def test_parses_a_title
result = VCR.use_cassette('google') do
Commands::Urls::ScrapeUrl.call('https://www.google.com')
end
assert result == {
url: 'https://www.google.com',
... |
class SalaryWorkingDay < ActiveRecord::Base
xss_terminate
validates_presence_of :payment_period
validates_presence_of :working_days, :message => :enter_the_number_of_working_days
validates_numericality_of :working_days, :message => :working_days_should_be_a_number, :if => lambda{|d| d.working_days.present?}
... |
class Array
def clean_string_values_in_array
self.map! do |val|
val.clean_string_values_in_array if val.is_a?(Array)
val.clean_string_values_in_hash if val.is_a?(Hash)
val.is_a?(String) ? val.strip.clean_string : val
end
end
def to_ms_product_key
valid_chars = 'BCDFGHJKMPQRTVWXY23... |
class Category < ApplicationRecord
validates :name, presence: true
validates :name, uniqueness: {
allow_blank: true,
scope: :parent_category_id
}
validate :ensure_single_level_nesting
has_many :sub_categories, class_name: "Category",
foreign_key: :parent_category_id, depende... |
class ArticleSerializer < ActiveModel::Serializer
attributes :id, :title, :content, :created_at, :updated_at, :nb_comments, :comments, :nb_likes, :likes
def nb_comments
Comment.where(article_id: object.id).count
end
def nb_likes
Like.where(article_id: object.id).count
end
end
|
require "application_system_test_case"
class GetCardsTest < ApplicationSystemTestCase
setup do
@get_card = get_cards(:one)
end
test "visiting the index" do
visit get_cards_url
assert_selector "h1", text: "Get Cards"
end
test "creating a Get card" do
visit get_cards_url
click_on "New Get... |
class FeeAccountsController < ApplicationController
before_filter :login_required
filter_access_to :all
before_filter :validate_if_enabled, :only => [:manage]
require 'lib/override_errors'
helper OverrideErrors
check_request_fingerprint :create, :update
# fee accounts dashboard
# list active fee acc... |
# encoding: UTF-8
module API
module V1
class ChatMessages < API::V1::Base
helpers API::Helpers::V1::ChatMessagesHelpers
before do
authenticate_user
end
# one-one chat. get room via user id.
namespace :messages do
namespace :user do
route_param :user_id ... |
module Superintendent::Request
module Response
JSON_CONTENT_TYPE = 'application/json'.freeze
JSON_API_CONTENT_TYPE = 'application/vnd.api+json'.freeze
def respond_404
[404, {'Content-Type' => JSON_API_CONTENT_TYPE}, ['']]
end
def respond_400(error_class, errors, request_id)
[
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.