Posted by acts_as_flinn
Fri, 21 Jul 2006 03:00:00 GMT
While installing the latest version of
mongrel I had to update my ruby installation to Ruby-1/.8.4 on Mac
OS X 10.4. I needed to update readline because I was getting this nasty message:
dyld: Symbol not found: _rl_filename_completion_function
Hivelogic had a nice tutorial on a full rails installation that includes some information on installing 1.8.4 on 10.4.
Mongrel is up an running and all is well.
Posted in Rails Development | no comments | no trackbacks
Posted by acts_as_flinn
Tue, 11 Jul 2006 13:59:00 GMT
Ok, so PhillyOnRails was cool. David Black the author of Ruby for Rails : Ruby Techniques for Rails Developers spoke, but for the most part I missed it. I am notoriously bad at following Google Maps/Mapquest directions (since most of the time they are wrong). I pulled off the Fort Washington exit from the map, but there was road construction so it was the wrong exit. I circled around a few times and by the time I pulled up to the right place it was 45 minutes into his presentation.
Oh well, I enjoyed the hands on talk, though it was a little disorganized I enjoyed speaking with other rubyists. Right when I walked in people were talking about login_generator, I felt like I found an embassy.
Anyhow there was a lot of interesting talk and interesting people. So I will be writing more about my excursions in the coming months.
Posted in Rails Development | no comments | no trackbacks
Posted by acts_as_flinn
Thu, 06 Jul 2006 18:55:00 GMT
I am working on an export feature for a few formats, one of them CSV. There are some CSV handling classes in stdlib, but for some reason or another I really didn’t like them. I looked around for an easy way to do to_csv from ActiveRecord but I didn’t like what I found that much.
After more looking I found FasterCSV which I seemed to like a lot more. It has a method for handling array to csv functionality that seemed pretty easy to handle in my view. At this point this export is very simple so I will share it.
In my controller of course I find my records to export, and I
require "faster_csv"
and I am setting ‘Content-Type’ and ‘Content-Disposition’
headers['Content-Type'] = "application/octet-stream"
headers['Content-Disposition'] = 'attachment; filename="foos.csv"'
render :layout => false
Here is what my view looks like
<%= @foos.first.attributes(:except => 'searchable').keys.collect{|k| k.humanize}.to_csv -%>
<% for foo in @foos %><%= foo.attributes(:except => 'searchable').values.to_csv %><% end %>
Note :except => ‘searchable’ isn’t needed, but I left it in to give you a clue where to drop unwanted attributes.
The only thing I don’t like here and in Ruby in general is that hashes don’t retain any order, so just because your table looks like id, name, description doesn’t me that attributes will. You might get name, id, description That’s the PHP coder still inside of me complaining. I am sure that I will update this to keep order happy in the near future, so check back.
no comments | no trackbacks