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!
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.
> 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.