Spaces in Ruby on Rails and how to avoid them!

Hi,

I just started learning ruby on rails and I am having hard time with white spacing!

Here is the piece of code that will not work:

validates_format_of :image_url, :with => %r{\.(gif|jpg|png)$}i, :message => "must be a URL for a GIF, JPG or PNG image"

and here is the piece of code that will work:

validates_format_of :image_url, :with => %r{\.(gif|jpg|png)$}i, :message => "must be a URL for a GIF, JPG or PNG image"

by putting the :image_url on the second line all hell breaks loose. Is there any good Ruby, Rails editor which can make sure that the code is in good shape and valid!

Is there any editor with intellisense support?

TextMate is the standard for Ruby development on the Mac. Personally I use UltraEdit on Windows and it seems to work well. There is a text highlight profile specifically for Ruby.

Hope this helps.

Eric Knoller RoR Power, Inc. http://www.rorpower.com

AzamSharp wrote:

Hi Eric,

Thanks for the reply!

I have one more question.

Let's say I have a model named "Product". How would I know what methods it supports? Like I know I can do this:

Product.content_columns

but how would I know that the content_columns exists without intellisence?

Standard? Schmandard!

I personally prefer Coding Monkeys' SubEthaEdit:

One way or another, there should be a 'Show Invisible Characters' or such in all those editors.

Product.methods or Product.instance_methods

Adam

Thanks,

> Let's say I have a model named "Product". How would I know what > methods it supports?

Product.methods or Product.instance_methods

With the caveat that with a language like ruby the methods might not exist until you call them (Eg the dynamic finders are created by method_missing when you first call them). Rails makes fairly heavy use of that sort of thing.

Fred

Oh, both aptana and netbeans have some degree of code completion, but I don't use either of those so I don't know how good it is.

Fred

AzamSharp wrote:

Let's say I have a model named "Product". How would I know what methods it supports? Like I know I can do this:

Product.content_columns

but how would I know that the content_columns exists without intellisence?

An "intelligent" IDE is no substitute for an API reference and learning the framework you intend to use.

In Rails, if you have an ActiveRecord model, then information about what methods it supports starts here:

http://api.rubyonrails.com/classes/ActiveRecord/Base.html

In console, I prefer the form: Product.methods - Object.methods or Product.instance_methods - Object.methods

This reduces information clutter...

F