Posts tagged: rails

Ruby on Rails startup errors

Ruby on Rails startup errors

If you see something similar to the following when starting Rails:

!!! Path to log file not valid: log/m

All you need to do is to create the ./log directory.

Intellij Idea, Ruby and Ruby on Rails

To set up an existing Ruby on Rails project in Intellij Idea 8:

  • Install the Intellij Ruby plugin
    • Preferences > Plugins > Available > Ruby
  • File > New Project
    • Select ‘Create Java Project from existing sources’ [Next]
    • Navigate  to the directory containing the source code [Next]
    • Select ‘Create source directory’. Use the default. (This is one of the vital steps)  [Next]
    • Accept anything on the next screen relating to libraries [Next]
    • Accept anything on the next screen relating to modules [Next]
    • Accept the facets (this doesn’t appear to have any immediate impact) [Finish]
  • File > Project Structure > [Platform Settings] > JDKs
    • In the second panel, click the ‘+’ button to add a new SDK. Select ‘Ruby SDK’
    • Navigate to the Ruby binary you want to use (usually /usr/bin/ruby or /usr/local/bin/ruby)
    • Change the entry name if you want to
    • [Apply], [OK]
  • File > Project > [Project Settings] > Project
    • Set Project SDK to the Ruby SDK you just created
    • [Apply], [OK]
  • Run > Edit Configurations
    • Click the ‘+’ button to add a new configuration. Select ‘Rails’
    • Name your configuration – e.g. ‘mongrel’
    • Select a server – ‘mongrel’
    • Select ‘Choose SDK from module’. Pick the module you’re in the process of configuring
    • [Apply]

You should now be able to debug and run your project using Intellij.

Open Flash Chart Plugin

Installing the Pullmonkey Open Flash Chart II for Ruby on Rails (Pullmonkey)

  • script/plugin install git://github.com/pullmonkey/open_flash_chart.git
  • Copy swfobject.js from the plugin’s assets/ directory (will make this happen at install time later) to your RAILS_ROOT/public/javascripts directory
  • Copy open-flash-chart.swf from the plugin’s assets/ director to your RAILS_ROOT/public/ directory

Done!

Rails and mini_magick

mini_magick is a gem that allows you to run ImageMagick in a shell rather that as part of your application. It replaces Rmagick.

To install

sudo gem install mini_magick

To use in your code

TinyMCE – Rails Plugin

git clone git://github.com/kete/tiny_mce.git tiny_mce_plugin

Starting and stopping mongrel cluster

sudo mongrel_rails cluster::start / stop

Ruby on Rails – Multiple DB Connections

Seems Magic Multi-Connections does what it says and provides simple support for multiple databases in a single Rails model.

Web framework comparisons

A simple and clear performance comparison for various versions of PHP and a little Rails at the end from PHP framework comparison benchmarks.

Interesting comments about Ruby on Rails scaling at Twitter, one of most heavily used Rails apps out there, from 5 Question Interview with Twitter Developer Alex Payne.

Ruby and UTF8 Encoding

For plain Ruby 1.8.6

$KCODE=’u’ doesn’t seem to do anything

Third-party solutions:

regex patterns take /u parameter to enable Unicode  (Parsing UTF-8 encoded strings in Ruby)

Chilkat though I can’t see where to download/buy the Ruby libraries. Looks like it may be Windows only.

Nikolai’s UTF8 Library

Onigurama is unicode-aware regex engine available for Ruby 1.8.6. Unclear how involved that is, or whether it’s compatible with UTF8/Unicode support in other packages – e.g.. character-encodings gem.

Rails 2.x

Rails 2.x handles UT8 encoding out of the box – IFF you use the ‘.chars’ accessors for strings (see the RubyOnRails Wiki) – uses the ActiveSupport unicode and multibyte extensions

Ruby IDE

A very quick survey of Ruby IDEs

Ruby

Active State – Komodo

NetBeans

Ruby on Rails

Aptana Studio and Eclipse Plugin

WordPress Themes