Archive

Archive for the ‘Rails Reference’ Category

Reserved words in Rails

May 30, 2007 15 comments

Oh the agony… I just spent half a day agonising over a new model that I created, and didn’t work when I was doing a find for a record. Just because one of the column name is a named after a reserved word! The error was an obscure:

SyntaxError: compile error
/usr/lib/ruby/gems/1.8/gems/activerecord-1.15.2/lib/active_record/base.rb:1359: syntax error, unexpected tINTEGER
Object::1

So I dedicate this blog entry to the listing of reserved words in Rails. If anyone else has come across any other reserved words that gave you hell, please comment!

Reserved words for Rails’ ActiveRecord
  • type
  • integer
  • string
  • text
  • file
  • number
Reserved words for Rails’ ActiveController
  • template ( Someone mentioned this on the Internet. I didn’t test this out )

Updates:

Some people have pointed me to these links.  They are more comprehensive!

Rails and observe_form

March 8, 2007 Leave a comment

In using the method observe_form in Rails, your form should be created with the option :id.  Otherwise, the observe_form won’t be able to locate the form and javascript error is encountered in prototype.js.

Sample code snippet in the rhtml:

<% form_tag(‘javascript:void(0)’, :id => ‘my_form’) do %>

<% end %>

<%=  observe_form :my_form,
: url  => {:action => ‘new’} %>

Categories: Rails Reference