NOTE: This post now lives (and kept up to date) on my blog: http://hakunin.com/rails3-load-paths
Do nothing. All files in this dir are eager loaded in production and lazy loaded in development by default.
| # config/initializers/clear_logs.rb | |
| # This snippet simply clears your logs when they are too large. | |
| # Every time you start the rails environment it checks log sizes | |
| # and clears the logs for you if necessary. | |
| if Rails.env.development? | |
| MAX_LOG_SIZE = 10.megabytes | |
| logs = File.join(Rails.root, 'log', '*.log') |
| module Kaminari | |
| module PageScopeMethods | |
| def total_count | |
| @_hacked_total_count || (@_hacked_total_count = self.connection.execute("SELECT (reltuples)::integer FROM pg_class r WHERE relkind = 'r' AND relname ='#{table_name}'").first["reltuples"].to_i) | |
| end | |
| end | |
| end |
NOTE: This post now lives (and kept up to date) on my blog: http://hakunin.com/rails3-load-paths
Do nothing. All files in this dir are eager loaded in production and lazy loaded in development by default.
| module ActiveAdmin | |
| module Views | |
| class IndexAsTable < ActiveAdmin::Component | |
| include CustomHelper | |
| def column_select resource, attr, list | |
| val = resource.send(attr) | |
| html = _select list, val, { "attrs" => %{ | |
| data-path='#{resource.class.name.tableize}' |
This shows one technique for preserving filters on index pages for ActiveAdmin resources, without having to patch the ActiveAdmin core.
It restores any previously-used filters whenever the index page is rendered for a resource, unless the current request is an actual application of new filters. It also properly handles the clear-filters button (via a synchronous Ajax request that happens immediately before the normal filter form processing).
Yes, it's a bit of a hack, but it has worked well for me so far.
| A comparison of Collection+JSON, HAL, JSON-LD and SIREN media types. | |
| Discussion at | |
| http://sookocheff.com/posts/2014-03-11-on-choosing-a-hypermedia-format/ |
| # This file extends and overrides parts of the ActiveAdmin DSL and internals | |
| # in order to provide support for automatically displaying and editing images, | |
| # which in our infrastructure are stored as URLs whose column names end in "img". | |
| # Since this file will be reloaded frequently in the development environment, | |
| # all operations done at load time (class_eval's, etc.) MUST be idempotent. | |
| ActiveAdmin::Views::TableFor.class_eval do | |
| def img_column(col_sym=:img, title="Image") | |
| column title, sortable: false do |obj| |
| module ActiveAdmin | |
| module Views | |
| class ActiveAdminForm | |
| class DeprecatedFormBufferSubstitute | |
| def initialize(form) | |
| @form = form | |
| end | |
| def << (value) | |
| @form.text_node value.html_safe | |
| end |
| <?php | |
| // Test cards | |
| $cards = array( | |
| '378282246310005', // American Express | |
| '371449635398431', // American Express | |
| '5078601870000127985', // Aura | |
| '5078601800003247449', // Aura | |
| '30569309025904', // Diners Club | |
| '38520000023237', // Diners Club |