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 ActiveModelInstanceTagWithAssociations | |
def error_message | |
Rails.logger.debug "ActiveModelInstanceTagWithAssociations: " + @method_name.inspect | |
if @method_name.end_with?('_ids') | |
# Check for a has_(and_belongs_to_)many association (these always use the _ids postfix field). | |
association = object.class.reflect_on_association(@method_name.chomp('_ids').pluralize.to_sym) | |
else | |
# Check for a belongs_to association with method_name matching the foreign key column |
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
$ sencha app build -run native | |
Sencha Cmd v4.0.0.203 | |
[INF] | |
[INF] init-plugin: | |
[INF] | |
[INF] cmd-root-plugin.init-properties: | |
[INF] | |
[INF] init-properties: | |
[INF] | |
[INF] init-sencha-command: |
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 ApplicationCell < Cell::Rails | |
helper ApplicationHelper | |
helper I18nHelper | |
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
ree-1.8.7@cells (master) lebigmac:cells james$ gem list | |
*** LOCAL GEMS *** | |
abstract (1.0.0) | |
actionpack (3.0.9) | |
activemodel (3.0.9) | |
activesupport (3.0.9) | |
builder (2.1.2) | |
bundler (1.0.17) |
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 ApplicationController < ActionController::Base | |
TOKEN_PLACEHOLDER = "__CROSS_SITE_REQUEST_FORGERY_PROTECTION_TOKEN__" | |
after_filter :inject_csrf_token | |
private | |
def inject_csrf_token | |
if protect_against_forgery? && token = session['_csrf_token'] | |
if body_with_token = response.body.gsub!(TOKEN_PLACEHOLDER, token) |
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
# config/initializers/template_handlers.rb | |
require 'action_view/template/handlers/textile' | |
ActionView::Template.register_template_handler :textile, ActionView::Template::Handlers::Textile.new |
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
# bash history (see: http://blog.macromates.com/2008/working-with-history-in-bash/) | |
export HISTCONTROL=erasedups | |
export HISTSIZE=10000 | |
shopt -s histappend | |
export PATH=$PATH:/usr/local/mysql/bin/ | |
# For mysql gem install. See: http://pathfindersoftware.com/2010/10/installing-mysql-gem-with-bundler-on-snow-leopard/ | |
export ARCHFLAGS="-arch i386" |
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 Project < ActiveRecord::Base | |
named_scope :foo, :conditions => ['projects.id IN(?)', [1,2,3]] | |
named_scope :bar, :conditions => ['projects.id IN(?)', [2,3,4]] | |
end | |
$ ./script/console | |
Loading development environment (Rails 2.3.9) | |
ree-1.8.7-2010.02 :001 > Project.foo.bar | |
Project Load (0.5ms) SELECT * FROM `projects` WHERE ((projects.id IN(2,3,4)) AND (projects.id IN(1,2,3))) ORDER BY projects.name |
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
# Adobe Flash fails to pass the correct mime-type when POSTing files. | |
# This piece of middleware is used to correctify the matter | |
# | |
# N.B. Requires `file` command so will probably only work on POSIX systems | |
# | |
# To use add this to an initializer: | |
# ActionController::Dispatcher.middleware.insert_after(ActionController::ParamsParser, IdentifyMimetypesMiddleware, /^(Adobe|Shockwave) Flash/) | |
require 'rack/utils' |
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 ActiveRecordExtensions | |
module ClassExtensions | |
# Returns +Array+ of all +ActiveRecord+ model classes | |
def models | |
Dir.glob(Rails.root.join('app', 'models', '**', '*rb')).each do |model| | |
ActiveSupport::Dependencies::Loadable.require_or_load model | |
end | |
Object.subclasses_of ActiveRecord::Base |
NewerOlder