Icon_search
Stephanie Sharp Buck Sharp Kim Landrum Travis Roberts Colin Jones Natalie Glenn Andrew Reifman Charlie Maffitt Kelly C. Jones Juli Tredwell
Colin

Colin's Blog

RSS

Engines vs. Rails, Part the Second

Posted on 03/18/2008
0 Comments

So we're upgrading to Rails 2.0 for our new sites, and I found a problem with the way Engines (even the latest version as of today) interacts with Rails 2.0.

First load of my Rails Engines page (in a development site):

[machine] Everything works great!

Second load:

[machine] A copy of ApplicationController has been removed from the module tree but is still active!

[me] Crap.

Enter some help from the interwebs: http://www.ruby-forum.com/topic/137733

[me] Hooray!

Basically, I just had to add this to the init.rb file in each Engines plugin:

load_paths.each do |path|
  Dependencies.load_once_paths.delete(path)
end

Tagged:  rails 2.0, module tree, ApplicationController has been removed, engines

Back to top

undefined method `last' for {}:Hash

Posted on 02/22/2008
8 Comments

Sometimes you hate the things that make your life so easy, because you have some problems with those things that make it temporarily more difficult. But then you fix the problems, and everything's back to being cool again.

In this case, I'm using Engines with Ruby on Rails, and there seems to be a conflict between my version of rake and my version of engines. So I did a rake db:migrate and got the ugly-looking:

undefined method `last' for {}:Hash

on line 10 of the rakefile. Well, after some Googling and clicking through, I found that all I needed to do was update a few lines of the engines code. In /vendor/plugins/engines/tasks/engines.rake, change the redefine_task method to read as follows:

def redefine_task(task_class, args, &block)
   task_name, deps = (RAKEVERSION >= '0.8.0') ? resolve_args([args]) : resolve_args(args)
   task_name = task_class.scope_name(@scope, task_name)
   deps = [deps] unless deps.respond_to?(:to_ary)
   deps = deps.collect {|d| d.to_s }
   task = @tasks[task_name.to_s] = task_class.new(task_name, self)
   task.application = self
   if RAKEVERSION >= '0.8.0'
     task.add_description(@last_description)
     @last_description = nil
   else
     task.add_comment(@last_comment)
     @last_comment = nil
   end
   task.enhance(deps, &block)
   task
end

Tagged:  undefined method, rails, engines, rake

Back to top

Valid XHTML - How to Lose the Non-SGML Characters

Posted on 05/31/2007
0 Comments

Here at Plexus, we pride ourselves on our use of Web standards, which lead to greater usability and searchability, in addition to better preparation for future browsers and other Web technology. We proudly display links to validation services at w3.org for our XHTML 1.0 Strict and CSS, and they show that we're writing valid code.

On our sites that allow users to enter content, however, we sometimes encounter validation errors such as:

This page is not Valid XHTML 1.0 Strict
Error Line 60 column 118: non SGML character number 128.

[the problem here was a left quote pasted in from Microsoft Word]

We've looked at writing scripts that convert each "non SGML character" to ones that will pass XHTML validation, but it ends up being very difficult to track down each individual invalid character.

The better solution (assuming you're like us and have been using ISO-8859-1 encoding) is to just change the character encoding UTF-8. That is, drop a META tag in your document template like this:

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

And you should be home free, so now you can feel confident about your code still passing XHTML 1.0 Strict validation even though you're letting clients paste Microsoft characters in.

Tagged:  non SGML characters, UTF-8, xhtml

Back to top

Reduce PDF File Size

Posted on 04/02/2007
10 Comments

If you're like me and have struggled for hours trying to figure out how to shrink someone else's PDF files without access to the original, you're in luck (as long as you're running Mac OSX):

  1. Just open the offending PDF in Preview, save as JPEG (slide the quality down to "Least" for greater reduction in file size)
  2. Save your new JPEG as a PDF (also with Preview).

You're basically just flattening the PDF into an image, rather than unembedding fonts and "optimizing" images like Adobe Acrobat's PDF Optimizer does.

Pros: Big drop in file size; free; fast & easy

Cons: You'll lose editable forms; you may also lose resolution, depending on how low you slide the quality when you save as JPEG

Hope it helps somebody!

Tagged:  PDF, reduce, filesize, shrink, size

Back to top

Merge PDFs without Acrobat

Posted on 12/19/2006
3 Comments

Several times in the last few months, I've needed a way to combine two PDF files into one. I don't have the full version of Acrobat on my machine, and using Photoshop to do it is more hassle than it's worth, so I found this freeware utility that does the job handily:

pdftk

Tagged:  PDF, merge, combine, pdftk

Back to top