Archive for August, 2012

Error Handling in Rails

Begin – Rescue – End begin #YOUR CODE SHOULD BE HERE rescue #IF YOUR CODE FAILS, THIS WILL BE EXECUTED end Example #!/usr/bin/ruby begin puts ‘I am before the raise.’ raise ‘An error has occurred.’ puts ‘I am after the raise.’ rescue puts ‘I am rescued.’ end puts ‘I am after the begin block.’ This […]

Read More →

Rails 3 and HTTP

To switch from HTTP to HTTPS or SSL: # config/application.rb module MyApp class Application < Rails::Application config.force_ssl = true end end

Read More →

Rails Notes

Active Records update MyObject.update (params[:id], params[:myobj]) returns object whether passed or not. MyObject.valid? to check if the object is valid update_attribute vs. update_attributes Update_attribute updates one attribute as opposed to multiple attributes. When update_attribute is used, validation doesn’t get fired up for the model..

Read More →