iprog.com

announcing db_log_cleaner rails plugin

my first public rails plugin is ready to go. called db_log_cleaner, it’s a more complete version of another plugin called postgre_log_cleaner.

it filters out selected log messages from both postgres and mysql to help keep development.log cleaner.

details are on the project page.

0 comments

uploading multiple files with attachment_fu

i was recently sharing with someone how to make multiple uploads work with the attachment_fu plugin. as an aside, attachment_fu is the successor to acts_as_attachment. if you were planning to use acts_as_attachment, upgrade your plans and use attachment_fu instead.

multiple file uploads are actually fairly straight forward.

first, in the view:

1<%= file_field_tag 'attachment_data[]' %>

put as many of these in the view as desired. it’s also easy to cause an arbitrary number of them to be added via javascript by the user’s browser.

then, in the controller:

1@attachment = Attachment.new
2params[:attachment_data] ||= []
3params[:attachment_data].each do |file|
4  @attachment = Attachment.create({:uploaded_data => file}) unless file == ""
5end

Attachment is my model for uploaded file—substitute as appropriate. as this isn’t a complete how-to for attachment_fu, i won’t get into configuring attachment_fu or the model here.

that’s it. that wasn’t so painful, eh?

21 comments

syntax highlighting for rails

i’ve been rewriting the software backend for this site. it has been my intention, once that was partly done, to begin to discuss more technical stuff here, including code samples—most likely for rails stuff.

that’s all fine and well, but you can’t just post code snippets in black and white. no, this is a technicolor world now and that would never do. so i’ve been on a quest to figure how how to make my shiny, new rails backend parse the code blocks and introduce them to my box of 64 (!) crayolas. (as an aside, i’m pretty sure i wasn’t the only one at age 7 who thought his world would be complete if only i could get a 64-color crayola set — much better than my set of 16.)

anyway, i won’t get into lots of details at this point (although i can if somebody wants me to), but in case you need to do the same thing, here are a few jumping off points.

the most common solution seems to be to use the syntax gem. you’ll need to roll your own interface between it and rails, although rails weenie can offer some help.

syntax will recognize ruby, yaml, and xml by default. if you need something more robust, UltraViolet looks interesting although it would certainly have a heavier memory footprint. it leverages textmate bundles so it should be able to interpret/colorize nearly anything that is even semi-common, and then some.

i’m sure there are more options—add them to the comments if you know of something.

0 comments

mail.app and smtp

apple’s mail.app works fairly well. that is, until something goes wrong. i know—stating the obvious. but hang with me for a moment. if you’re sending outbound email over ssl and/or with authentication, things get messy quickly. for reasons unknown to me, apple hasn’t seen fit to provide any debugging information at all. nothing lands in the console log and certainly no description of the error is presented to you, the willing email sender. instead you receive a terse message: ‘Cannot send message using the server ’. yay; super helpful.

i’ve done some digging with the help of the mail server itself, so perhaps if you’re getting this less than descriptive error, there is hope.

Read more...

0 comments

project naming

starting a new project usually has some overhead steps for me. one of those is a name. i can’t start the project until i’ve figured out what to call it. silly, but that’s how it is. so i’ve tried to go for code names knowing that i will pick the real name later. that works to a point. last night i got stuck picking a code name. i found WildFinder which has a searchable list of lots of species names. that helped out quite a bit—there are all kinds of species with cool names i didn’t know were animal names.

0 comments