Software and Technology Ramblings

December 15, 2007

Integrating FCKEditor and ActiveScaffold

Filed under: Rails — Doug Hays @ 12:35 am

I just solved an issue that I couldn’t find an answer for on the web, so I thought I’d just put it out there so that maybe it could help someone else. I am creating a simple CMS tool for one of my clients and always like to use the FCKEditor for CMS tools. I hadn’t built such a thing in Rails before, nor had I used ActiveScaffold before today. But Rails + ActiveScaffold + FCKEditor seemed like the perfect combination. And it is, once you get it working. Here’s what I had to do to make this work for a table called content_items and a field called content.

After installing the FCKEditor and ActiveScaffold plugins, I created, for the content column, a form column override file in my views/content_items directory called _content_form_column.rhtml. After some trial and error, I landed at this solution:

< %>:

<%= fckeditor_textarea( :record,, :toolbarSet => 'Simple', :width => '100%', :height => '400px') %>

<input name="commit" type="submit" value="Save" class="submit"
	onClick="var oEditor = FCKeditorAPI.GetInstance('record_<>_<>_editor');
        document.getElementById('record_<>_<>_editor').value = oEditor.GetXHTML();" />

Now, this is my 15-minute solution. What I’d like to do is get that onClick JavaScript to fire on the form’s onSubmit event and remove this secondary submit button altogether. But, since it’s late, I decided to remove the ActiveScaffold Update button and make this column the last on the page. How’s that for an I’ll-deal-with-it-later hack!?

December 14, 2007

It’s the little things that make a Mac fantastic

Filed under: Apple — Doug Hays @ 11:23 am

Just a quick note on a surprising feature of Apple Mail and iCal. After I upgraded to Leopard, I noted that some items in my email (addresses, dates, times, etc) had contextual menus appear when you rolled over them. The menus let you create a contact or an iCal event from the data in the email. But, again, Apple surprises with attention to the smallest details. For example, I was emailed this simple confirmation for an upcoming meeting:


When I rolled over the 6:00, the menu appeared and selected Create New iCal Event…. A little pop-up appeared and I began filling it out. When I went to choose the date, to my surprise, it was already selected:


It scoped out the rest of the message to find the mention of Thursday to select the 20th.

The ability to add an iCal event from an email message isn’t what makes a Mac fantastic. It’s the fact that the functionality does not get in your way and when you choose to use the feature, it works as you’d expect… and better.

Powered by WordPress