Skip to content

existence, refactored

With kindness comes naïveté. Courage becomes foolhardiness. And dedication has no reward.

Archive

Category: Development

Edit the config/environment.rb and add the following:

config.logger = Logger.new("#{RAILS_ROOT}/log/#{ENV['RAILS_ENV']}.log", 5, 10*1024*1024)

Where the 2nd and 3rd parameters are defined here.

Facebook looks at the meta="description" element of the shared link to determine its excerpt. The following link discusses how to do this:

Matthew Ebel » Blog Archive » Adding WP Post Excerpts to Facebook Links

The process requires modifying the header of your current theme, usually the header.php.

It’s also possible that the meta="description" element is missing in your theme (like in CRC‘s Suffusion theme). If that’s the case, just add the missing element.

[EDIT: Ditched this and went with All in One SEO Pack plugin instead.]

Problem

Apache mod_rewrite doesn’t work even if all of the .htaccess settings are correct.

Cause

The settings in /etc/apache2/sites-enabled/000-default for /var/www/ is set to AllowOverride None.

Solution

Change the setting to AllowOverride All.

Problem:

Member routes allow one to create additional routes to existing resources. For example, if you want to add an approve path to your purchases resource, you could do this in your config/routes.rb:

 map.resources :purchases, :member => { :approve => :put }

My problem was that the link I made for approving the purchase

<%= link_to "Approve Purchase", approve_purchase_path(@purchase), :confirm => "Proceed with approval?" %>

resulted in the following error:

Unknown action

No action responded to 1. Actions: approve, create, destroy, edit, index, new, show, and update

Cause:

Rails confused the link with a normal get operation.

Solution:

Explicitly declare the HTTP method for the action.

<%= link_to "Approve Purchase", approve_purchase_path(@purchase), :confirm => "Proceed with approval?", :method => :put %>

Problem:

When developing for Ruby on Rails, the development server (the one used by script/server) feels slow and unresponsive.

Cause:

RoR uses WEBrick as the default server. Based on my experience on a Ubuntu virtual machine with 1GB of RAM, this server doesn’t respond as fast as the web application servers in other web languages (Apache, Tomcat, IIS).

Solution:

Install Mongrel. In Ubuntu 9.04, you can install this using:

sudo gem install mongrel

In case you receive build errors, you might have to install ruby-dev to deal with the dependency issues.

sudo apt-get install ruby-dev

Once installed, Rails will automatically use Mongrel as the application server over WEBrick.