This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Company < ActiveRecord::Base | |
validates :name ,presence: {error_code: 9001, | |
developer_message: I18n.t('validations.developer_message.required'), | |
more_info: I18n.t('name.required.more_info') | |
} | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
##Candidate: | |
validates :user_id, presence: { error_code: 9001, | |
developer_message: I18n.t('validations.developer_message.required'), | |
more_info: I18n.t('name.required.more_info') } | |
validates :user_id, uniqueness: true, presence: { error_code: 9001, | |
developer_message: I18n.t('validations.developer_message.required'), | |
more_info: I18n.t('name.required.more_info') } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module FetchEvent | |
extend ActiveSupport::Concern | |
def fetch_additional_photo | |
@offset, limit, fixed = 50, 50, 50 | |
excluding_pid_lists = [].join(',') | |
0.upto(@offset) do |i| | |
increment = (fixed*i) | |
@offset+=increment |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe 'EducationRecord' do | |
let(:user) {users(:john)} | |
let(:candidate) {candidates(:john_candidate)} | |
before do | |
cookies[:user_auth_token] = encrypt_token(user.access_token) | |
end | |
around(:each) do |example| | |
VCR.use_cassette(:get_user_from_sso, {}, &example) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# in controller#action | |
@posts = Post.all.group_by(&:created_at) | |
# view | |
<% @posts.each do |date, posts | %> | |
<h2><%= date.strftime("#{date.day.ordinalize} %B,%Y") %></h2> | |
<tr> | |
<% posts.each do | post | %> | |
<td><%= post.what_ever_column_you_need %></td> | |
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ActiveAdmin | |
module Filters | |
# This form builder defines methods to build filter forms such | |
# as the one found in the sidebar of the index page of a standard resource. | |
class FormBuilder < ::ActiveAdmin::FormBuilder | |
include ::ActiveAdmin::Filters::FormtasticAddons | |
self.input_namespaces = [::Object, ::ActiveAdmin::Inputs::Filters, ::ActiveAdmin::Inputs, ::Formtastic::Inputs] | |
# TODO: remove input class finders after formtastic 4 (where it will be default) | |
self.input_class_finder = ::Formtastic::InputClassFinder |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
con = CrawlerBase.build('http://www.babson.edu') do |config| | |
config.build_page do |page| | |
page.content_identifier = 'a.faclink' | |
page.url = 'http://www.babson.edu/Academics/faculty/profiles/Pages/default.aspx' | |
page.build_details 'Bablon College' do |details| | |
details.department = '.bio_facultytitle > h3' | |
details.name = 'span[class*=name_]' | |
details.email = 'a[href*=mailto]' | |
details.photo = '.ms-rtestate-field > img' | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Module MixArrayFlattener | |
# Add #flatten_array to Array for the purpose | |
# of flatten nested array | |
module MixArrayFlattener | |
InvalidArrayItemFound = Class.new(StandardError) | |
# Flatten nested array! | |
# | |
# @return single flat array, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Original AFooClass | |
class AFoo | |
def bar | |
puts "Foooo Bar" | |
end | |
end | |
# Refining Module | |
module RefiningAFoo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require: rubocop-rspec | |
Rails: | |
Enabled: true | |
# Commonly used screens these days easily fit more than 80 characters. | |
Metrics/LineLength: | |
Max: 120 | |
# Too short methods lead to extraction of single-use methods, which can make |