All posts

Rails

 

How to do cascading deletes with Ruby on Rails

 

Easy and auto-magically done with some Rails goodness:

class User < ActiveRecord::Base
      has_many :user_friends, :dependent => :destroy
end

Deleting a User will then perform a cascaded delete of the dependent user_friends when the User is destroyed.

posted on 2013-04-25 00:00:00 UTC

Topiclocalhost
TagsRails
Read more

 


 

Rails Request Object and Environment Variables

 

Example usage:

request.env["HTTP_USER_AGENT"]

List of Rails Request Environment Variables

  • GATEWAY_INTERFACE
  • HTTP_ACCEPT
  • HTTP_ACCEPT_CHARSET
  • HTTP_ACCEPT_ENCODING
  • HTTP_ACCEPT_LANGUAGE
  • HTTP_CACHE_CONTROL
  • HTTP_COOKIE<...

    posted on 2012-05-21 00:00:00 UTC

    TopicSandbox
    TagsRails
    Read more