Skip to content

Instantly share code, notes, and snippets.

View zolzaya's full-sized avatar

Zolzaya Erdenebaatar zolzaya

View GitHub Profile
@svyatov
svyatov / update_cache_counters.rake
Created December 6, 2012 16:11
Rails Rake Task: Update all cache counters
desc 'Update all cache counters'
task :update_cache_counters => :environment do
models_to_update = {}
# or: Rails.application.eager_load!
# Dir loads less, so it's faster
Dir.glob(Rails.root.join('app/models/*')).each { |model| require model }
# as a convention, cache counter column name must begin with assotiacion's name and end with '_count' suffix,
# e.g. 'comments_count', 'posts_count'
@joost
joost / ruby_google_analytics_server_to_server.md
Last active November 27, 2023 15:43
Google Analytics API (server-to-server) using Ruby
@afeld
afeld / gist:5704079
Last active April 21, 2025 15:11
Using Rails+Bower on Heroku
@aboma
aboma / ember.select2.js
Last active February 7, 2021 17:07
select2.js enabled select box view for ember.js
// Select box utilizing Select2 functionality that overrides Ember.Select;
// Define view in the same way that you would an Ember.Select view.
// Additional attributes supported are: width, allowClear, and closeOnSelect;
// Example view:
// {{ view App.Select2
// viewName="fieldValueSelect2"
// prompt="Please select a value list"
// contentBinding="controller.fieldValuesLists"
// optionLabelPath="content.name"
// optionValuePath="content.id"

Guide to loading/error events and substates

In addition to the techniques described in the Asynchronous Routing Guide, the Ember Router provides powerful yet overridable conventions for customizing asynchronous transitions between routes by making use of error and loading substates.

loading substates

# app/filters/base_filter.rb
class BaseFilter
include ActiveModel::Model
include ActiveModel::Attributes
def initialize(session)
@_session = session
super(@_session.fetch(:filters, {})[filter_resource_class])
end