Tidbit from RailsCast 132:
ActionController::Base.helpers is a proxy object you can use to access Rails view helpers, outside of views, e.g.:
1
ActionController::Base.helpers.pulralize(products.count, ‘product’)
|
|||||
|
Tidbit from RailsCast 132: 1 Ran into a problem with RSpec when trying to create a spec for a view that used an ActionView url helper that required additional parameters to generate the url. route.edit_page ‘:site/edit’, :conditions => { :method => :get }, :controller => ‘webpages’, :action => ‘edit_page’ The above route sets params[:site] which is later used for url generation (using, [...] This is just about the best write-up on floats that I have seen. I just found out how to do something I have been wondering for a long time: :include syntax to eager-load through multiple associations. In the rdoc for class ActiveRecord::Associations::ClassMethods I discovered you can nest include statements in hashes as follows: If for example table_a has_many table_b and table_b has_many table_c and table_c has_many table_d: Model.find :first, :include => [...] This just bit me again so I thought I would share it. Thanks to this post, I discovered how to install the MySQL ruby gem on Mac OS X: sudo env ARCHFLAGS="-arch i386" gem install mysql — \ |
|||||
|
Copyright © 2010 Sam Pierson's Blog - All Rights Reserved |
|||||