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
#For executing corn Jobs in server. | |
#set :whenever_command, "bundle exec whenever" | |
#require "whenever/capistrano" | |
require "delayed/recipes" | |
default_run_options[:pty] = true | |
set :ssh_options, {:forward_agent => true} | |
set :rails_env, "production" |
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
def self.convert_key_to_human_readable_name(obj, options) | |
messages = [] | |
class_name = obj.class.name.underscore | |
errors = obj.errors.messages | |
separator = options[:separator].present? ? options[:separator] : ',' | |
errors.each do |key, value| | |
base_key = (options[key].present? && options.keys.include?(key)) ? options[key].to_s : key.to_s | |
values = value.each { |val| val.downcase } | |
values.flatten.join(" #{separator}") unless values.empty? | |
if key == :base |
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 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
# 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
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
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
##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
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
# Expected | |
# "error": { | |
# "status": 422, | |
# "code": "some_object/validation", | |
# "message": "Cannot create the {some_object} because provided data is not valid", | |
# "details": "More thorough description of a problem and probably even solution for curious users", | |
# "href": "http://some.url/to-describe/the-problem/in-even-more-details/optional", | |
# "errors": { | |
# "name": { | |
# "code": "validation/missing_required", |