Wednesday, February 27, 2008

Creating your own plugin

I finally forced myself to make my own plugin instead of having controllers and models all over the place. Of course, I waited for the right time to make a plugin that wasn't too different, and needed to be different at the same time.

I chose to make another version of acts_as_voteable by Juixe. Here are the steps I took
  1. I watched Ryan Bates' screencast on making plugins
  2. I coped acts_as_voteable and starting editing things one by one to see what broke.
  3. When I needed a clearer and more advanced explanation (like adding helpers and such), I referred to Geoffrey G's howto on creating plugins.
It took me about 4 hours to figure the whole thing out (I'm a slow learner.. and I already knew about polymorphic associations!).

The change I had to make to acts_as_voteable was that I had to have 3 kinds of votes: positive, neutral and negative. Very small change, right? :)

You can get my plugin like this:

script/plugin install

Monday, February 25, 2008

Syntax highlighting

I did a fresh install of Ubuntu on my laptop, and I installed gVim (rails.vim) as well. To my surprise, there was no syntax highlighting! Good thing a quick ":syntax on" fixed that.

Friday, February 8, 2008

Expected "model.rb" to define Model

I was getting this error:

ActionView::TemplateError (Expected /home/lucidph/public_html/rails/pbed/app/models/article_photo.rb to define ArticlePhoto) on line #5 of articles/gen_xml.xml.builder

A lot of people get this with ferret and some bug with it, but I didn't have ferret. The problem: I forgot to upload attachment_fu to the server!

Friday, February 1, 2008

Deploying in Bluehost

I started writing this entry not knowing what is wrong with my app in Bluehost - except that it isn't running. I know this because I get a :

Application error

Rails application failed to start properly

1) First I made sure it had all the gems it needed. Since we wanted to freeze our gems, we had put them in the gem folder.

I added this to our environment.rb

ENV['GEM_PATH'] = '/home/YOUR_USERNAME/.gems:/usr/lib/ruby/gems/1.8'

2) Looking at the production.log, now I see an error. What's the error? Among other stuff, the one that's most readable is "Missing helper file helpers/formatting_helper.rb".

I upload it.

3) It works.