Putting the Discogs API on Rails – ActiveDiscogs

Sonntag, der 15. Juni 2008, 19:40 Uhr von Ullrich

I had a look inside ActiveResource as it is part of Rails since version 2.1, and tried to use it to access the Discogs API. It turned out to be a bit difficult and required a bit more coding than accessing a regular Rails RESTful API.

That’s the reason why i created a Rails Plugin which supports the basic tasks for now (getting releases, artists and labels). Future versions will support searching and caching and a bit more.

The project goes by the name of ActiveDiscogs and is available on http://activediscogs.rubyforge.org/

Feel free to join and play with it :)

Ah, before i forget: To install just use

script/plugin install svn://rubyforge.org/var/svn/activediscogs

Geschrieben in: Coding | Tags: Schlagwörter:,
0 Trackbacks | 1 Kommentar »

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:
0 Trackbacks | 2 Kommentare »