Mr eel
No Letting Go
I’m not really taken in by saccharine R’n'B tunes, mainly because I feel that most of those songs are so far away from genuine feeling. More concerned with the form.
But sometimes, oh you come across something so sweet, you can’t help but love it. Wayne Wonder’s No Letting Go. I’ve been thrashing it for the last year or so and it’s as lovely as ever.
This and Bounty Killer’s Sufferer are my favorite tunes to use the Diwali riddim. Even if you don’t know what the Diwali is, chances are you’ve already heard it. It was used by Sean Paul, Lumidee and knocked-off by the Black Eyed Peas (Hey Mama).
Just a Small Gripe
What with the Agile Development with Ruby on Rails book and the excellent Pickaxe book, Rails developers are a pretty pampered bunch considering the age of the framework — only about a year.
In addition we also get the Rails Wiki and the API reference. Most of the time, if you have a problem, you can find the answer in one of these sources.
But I do have one complaint, hence the title of this post. Unfortunately the API documentation for app developers is lacking. The current API documentation seems to be aimed mainly at the team maintaining Rails. It’s a bugger because good documentation of the methods is critical for someone learning rails. I’m finding this is especially the case when dealing with ActionView.
For example, lets look at the datetime_select. This method accepts a reference to an object and one of it’s attributes — which should be datetime. It also accepts a hash of options which let you do things like omit the minute select. Unfortunately there is no documentation for the various options it accepts.
I wonder, is the plan to make the API documentation more complete or do we need something aimed more directly at app developers?
I might be going off a bit half-cocked here, but I really am a bit lost and a bit frustrated with the documentation at the moment. Are there any other sources I can look into? Should I start weeping?
Corporations Suck Basically
Just in case you needed reminding. Sony are being dorks about PSP imports.
I’m having a hard time thinking of how it benefits Sony to stop the importation of PSPs into markets waiting for an official release. Surely it would actually benefit them. I mean, all those hardcore game fans are doing them a favor. I tend to think that importations help generate pre-release buzz.
The only advantage I can see is an attempt at fixing prices within particular territories ala the (scumbag) DVD Consortium. It’s possible that imports could be cheaper in the longer term.
Also what makes them think they have the right to stop it? Frankly if they put a product to market, it’s no business of theirs what happens to it afterward. If I decide to sell it to someone in the UK or shoot it into space, once I’ve bought it that PSP is mine and I’ll do as I please with it. I think those rights extend to retailers like Lik-Sang as well.
*sigh*, deep down corporations are sooks. If they don’t get their way, they sue.
Kompakt Still Stacks It
I was going off Kompakt for awhile there. Some of the output was starting to seem a bit static, a bit erm… mono. Even the beloved Speicher series was beginning to loose it’s luster for me.
But thankfully things don’t always stay the same. I recently picked up Speicher 29, which has a track by Matthew Johnson on it. It totally kills. Deep, dark and mysterious, heavy on the atmosphere. Highly recommended.
Also eyes out — or should I say, ears out — for the new(ish) Kaito 12″ on Kompakt. I pretty much go wobbly-eyed for anything that cat puts out.
Nintendo is in Trouble!
Holy shit! Are you kidding me? The company is near collapse? They are running out of money? No new products?
Well no. Apparently the Revolution is their last-ditch effort to stay in the market. Or something like that. The article is a bit lacking in the having-a-point stakes. The best I can surmise is that it’s really important for the Nintendo Revolution to succeed, or else.
Which is bully of course. Make a product. Make it sell. Make a profit. If you are doing that and doing it well, you can probably keep at it for awhile. Looking at a companies success and future in terms of units shipped vs. the competition is a mugs game. It doesn’t actually tell you anything about how well the company is doing. That is to say; how much money it’s making.
I’ve posted about this before, but as a loyal Nintendo fan-boy, I feel the need to re-iterate this point. Nintendo is a financial superstar and unlikely to fall out of the market anytime soon.
Introspection in Rails
OK, I’m working on security for a web-app using ACLs. What I want to do is populate a database table with references to the controllers and methods in the app. I can then use these as permissions.
I can get the controllers into a hash like this:
controllers = {}
ObjectSpace.each_object(ActionController::Base) do |controller|
controllers["#{controller.class}"] = controller
end
This works very well, but it only has access to the classes currently loaded. To make sure all of the controllers are loaded so we can access them using ObjectSpace, I look at each controller in the controllers folder, and require each in turn.
Like so:
require 'find'
Find.find(File.join(RAILS_ROOT, 'app/controllers')) { |name|
require_dependency(name) if /_controller\.rb$/ =~ name
}
It finds the files, but the method call require_dependency() doesn’t seem to work. The controllers just aren’t being loaded. Anyone know why?
Some Ruby Love
A single line of code to split a string into an array, then go through each entry and convert it into an integer.
date = string.split('-').collect {|entry| entry.to_i}
Something so complicated in another language turns out to be one line. *sob* I luv you Ruby!
Rails: Rendering Partials Only When You Have ‘Em
I needed a neat way of including a sub-navigation on certain pages in a web application. Since this sub-nav will turn up in the views for multiple actions, it make sense to have it as a partial.
Now I wanted to do this the Rails way. If the partial is in a controller’s view folder it gets rendered, otherwise… well nothing. This is the behavior we see with Rails automatically linking actions and views together based on their names.
But how to do it?! I am Ruby newbie after all. Thank Sweet Jelly for the internet. I stumbled across this interesting post. It’s about auto-discovering CSS files for controllers. It’s really neat! This served as a good basis for my own partial-discovering code. Like so:
def sub_navigation
view_path = "#{RAILS_ROOT}/app/views/#{controller.controller_name}/"
render_partial('sub_nav') if FileTest.exist?("#{view_path}/_sub_nav.rhtml")
end
This goes into the application_helper.rb file so I can access it in any view. First line in the method sets the file path to the view folder for the current controller.
The second line sez; ‘write out the sub-nav if a sub-nav file exists in this folder’.
The only downside here is we can’t share sub-navs between controllers. I’m gonna have to think about it a bit.