I discovered an interesting difference between two patch levels of the same Ruby (1.8.7)

def index
 respond_to do |format|
  format.html {
   super # call the index method of the superclass
  }
 end
end

This does not produce an error in Ruby 1.8.7 patchlevel 72 (the one that happens to ship with Snow Leopard), but in Ruby patchlevel 249 (the most recent one), it tells me I'm not allowed to do this.

This method was adapted from this blog post.

So, you are creating a thing (record) or maybe you are updating it. You've added created_by and updated_by fields to your model, and you've made these integers with the intention of them both being foreign keys to the Users model.

Maybe you've even setup a belongs_to relationsion to your User model like so:

Feb 162010

The referrer is the URL the user came from. (It gets passed as part of the headers to the new request). You can get it out of rails this way:

request.env['HTTP_REFERER']

Or the shorter version:

request.referrer

It seems that no one noticed that "referer" is actually not a word – the correct spelling is double-R ("referrer"). request.referer and request.referrer both work, but request.env['HTTP_REFERRER'] does not.

Quick demonstration of public, private, and protected methods.

© 2012 Tech Notes Suffusion theme by Sayontan Sinha