My Methods – Rails Object extension
Donnerstag, der 29. Mai 2008, 09:43 Uhr von
Ullrich
This post is in English as the whole Coding category will be.
What’s this all about.
Ryan wrote on his blog about a ruby snippet he came up with a friend. His code snippet won’t be that useful for ruby on rails starters since his example only gives half of the solution.
So here’s the rest
Create file app/overrides/object.rb
class Object
def self.my_methods
methods - (superclass ? superclass.methods : [])
end
def my_methods
methods - (self.class.superclass ? self.class.superclass.new.methods : [])
end
end
Also create app/overrides/all.rb containing just
Dir[ File.dirname( __FILE__ ) + "/**/*.rb" ].each { |file| require( file ) }
This file now needs to be included in the environment.rb
require "#{RAILS_ROOT}/app/overrides/all"
This should do the trick. Now get out there and code, code, code!
Geschrieben in: Coding | Tags: Schlagwörter:Rails
0 Trackbacks | 2 Kommentare »
got to create a css template for code snippets… will do this later today
ok, installed wp-syntax plugin. looks nice