Hi,
I’m sure the following has been discussed 100s of times, and there is probably an obvious answer; either that or its all been fixed in Rails2.0 …
We have a simple relationship between three models, written in shorthand as follows:
Venue :has_many Gig :has_many Image
and
Image :belongs_to Gig :belongs to Venue.
It is easy to answer the question, “What [...]
Entries Tagged as ‘Uncategorized’
December 10, 2007
:has_many, :belongs_to, :through, and :include
July 12, 2007
using db:fixtures:load and extract_fixtures on large tables
We’ve been using the rake task, extract_fixtures (from Rails Recipe #42), as a convenient way of lifting data generated in development up into production (where we invoke the rake task, db:fixtures:load, to populate the db tables). Whilst not particularly quick to do the extract or load, it is very convenient, since the fixtures (yaml files) [...]
July 12, 2007
streaming with send_file, or redirect_to and apache
We recently had cause to generate and fling large pdf files from our rails app. In development, we used send_file to stream the pdf file out via mongrel, but it seemed sensible to redirect_to apache for the heavy lifting in production, freeing up mongrel and rails for the delicate stuff.
So, at the end of the [...]
July 12, 2007
changing environment variables followed by mongrel_rails restart
When making a change to environment variables such as PATH and JAVA_HOME, don’t use “mongrel_rails restart” to bounce the rails app to pick up the changed values. You could find yourself wasting much of the morning futilely chasing obscure shell/mongrel/capistrano issues, desperately seeking any kind of hint as to why the rails app was refusing [...]
May 1, 2007
Rails’ find :include, Ruby’s Marshal, and ArgumentError: undefined class/module
Fresh from the perils of not knowing that a place belongs_to a country, we generated a data structure that consisted of places, other places, and countries. This took a while to compute so, naturally, to speed things up during development iterations we wanted to cache it. Equally naturally, we didn’t want to make use of [...]
May 1, 2007
in Rails, a place belongs_to a country, and don’t you forget it
This time, some wrassling with relationships between models. Foolishly rejecting the easy option of doing everything the rails way, we hoped to be able to shoehorn a yucky data structure into rails.
We had a table called places, where each place had a two-letter country_code. We wanted to map this to full country names, [...]
March 30, 2007
Rails: xml page caching with a different page_cache_directory
So, there were some generated xml pages that needed caching. After some assorted reading, the basic caches_page approach seemed sufficient.
First step was to tweak config/routes.rb to bring the url params into the path to make the url cacheable. Something like:
map.connect “feed/resorts_and_holidays/:country_name/:how_recent”, :controller => ‘feed’, :action => ‘resorts_and_holidays’
Then add the following to app/controller/feed_controller.rb, to cache the [...]
March 22, 2007
Hello world!
Hi, another blog. Sorry.
Still, at least this one is intended to be useful to anyone thinking of giving Rails a try. We recently started from scratch, not knowing Ruby or Rails. We chose Rails as a framework for prototyping our dabblings, partly to try something new, partly to try out a ‘happening’ technology, partly to [...]
this feed