deprecated snippets

Fixing "config.breakpoint_server has been deprecated and has no effect" when using Rails Edge

Tagged rails, debug, edge, deprecated  Languages ruby

You might get this error if you're using Rails Edge: config.breakpoint_server has been deprecated and has no effect:

To fix the error we need to remove the following from config/environments/development.rb:

config.breakpoint_server = true

Next install ruby-debug:

gem install ruby-debug

Then add this to the end of config/environments/development.rb:

require 'ruby-debug'

Next, start your server, and the error should be gone...

To debug your code just add a call to debugger:

class MySillySpace ...
  def create
    debugger # add this line

Now when you access the URL with your browser you'll have access to the debugger from the console window.

To learn how to use ruby-debug, read this tutorial written by the ruby-debug author.

How to mark deprecated methods in Ruby

Tagged ruby, deprecated  Languages ruby

This code can be used to mark deprecated methods in Ruby:

module Kernel
  def mark_deprecated(new_method)
    warn "DEPRECATED: the #{__method__} called from #{caller.first} has been deprecated and replaced by #{new_method}!!!"


class Horse
  def self.shit