#101: detecting whether association loaded in ActiveRecord
Solved!
Sometimes you want to check if something's loaded before you hit the db.
#96: rails tests not getting rolled back
Solved!
There are a number of reasons this might happen: you have a test, it runs fine individually, but when you run rake test or rake test:units, it fails. This might be because one test is writing to the db and those changes aren't getting rolled back.
#93: inspecting the state of a named_scope
Solved!
I know named scopes are getting all changed around in Rails 3, but I figured this out a while ago, and then forgot it, came here to find my answer, and realized I never wrote it down.
The problem is that when you're building complex chained scopes its often...
#81: associated STI subclasses not loading in dev
Solved!
Let's say you have
class Chili < ActiveRecord::Base
has_many :beans
end
class Bean < ActiveRecord::Base; end
class Pinto < Bean; end
Now, let's say you have one chili record that's associated with one pinto (it's a sad chili). If you do this...
#69: MemCacheError () failures in Rails 2.3.x
Solved!
While attempting to use Rails.cache.write using MemcachedStore, writes with strings fail consistently with MemCacheError () . Reads occasionally succeed for some odd reason.
Only seems to happen on Ubuntu Intrepid ( production environment ), with memcached...
#56: Passenger can't find a shared module in Rails
Solved!
I recently put some shared code from a Rails app into a module in app/models/shared/sweepers_module.rb. The module itself was called Shared::Sweepers. I included it in some sweeper classes, and everything worked fine in Mongrel. In Passenger, though, I got...
#55: accessing locals hash within an ActionView partial
Solved!
How do you access the hash of locals you pass into a partial from within that partial?
#48: Rails to Blogger, Wordpress integration
Looking for a reasonable library or wrapper around the Blogger API and Wordpress AtomPub/XML-RPC APIs, so that I can syndicate content to various blog engines, or just post content to user-specified blogs in general.
#47: finding a time zone give lat/lon coordinates
Solved!
A little while ago we started using time zones in iNat, which was more troublesome than anticipated. One problem I ran into was automatically setting the time zone from pre-existing observations given their lat/lon. I ended up http://www.earthtools.org/webservices...
#45: why is Rails logging to ".log"?!
Solved!
I started using Workling, but quickly realized it was logging to "log/.log" for some inane reason.
#44: multivalue facet fields in acts_as_solr
Solved!
Solr supports faceted search, which is good, but acts_as_solr has pretty terribly documentation, which is bad.
#43: resetting Rails schema_migrations table
Solved!
I just ran a failing migration, and in a fit of panic, deleted all the rows from my schema migrations table. That's a pretty dumb thing to do.
#37: make url_for() generate a URL for the current page including GET params
Solved!
If you just use url_for() in a view, it will generate the url corresponding to the controller/action/id that generated, but it will leave out the precious GET params.
#35: validating date_select in rails
Solved!
If you use the date_select helper in Rails, setting all fields except for the year will result in MultiparameterAssignmentErrors. You can catch the exception, but it's kind of hard to catch it in a place where you can add errors to a model instance.
#34: Indexing the results of an nested set ancestry query
I would like to use Sphinx and ThinkingSphinx to index the results of a nested set ancestry query, but I'm not entire sure how. The kind of query I need to do would be something like
SELECT id FROM taxa WHERE taxa.lft <= $target_taxon_lft AND taxa.rgt...
#28: crontab settings for deploying Ultrasphinx
Solved!
the SelfSolved instance deployed uses Ultrasphinx for its full-text indexer and search provider. The sphinx indexer needs to be run regularly to index new text that appears on the site.
I need crontab incantations to set the indexer to create delta indexes...