Sunday, July 11, 2010

Your First Extension With Radiant

So I'm trying out Radiant, and one of my first questions is, what if I wanted to actually get a Rails view in there as content? Without a doubt I'll need to make a Radiant extension, so I'll be following the steps laid out here.

So you do a script/generate extension whatever and you get a full directory replete with views and even a routes.rb and everything. Which seems to be a normal Rails extension. So I just did a HelloWorld, but they did an example with scaffold. Either way works. The interesting thing is that your routes end up available in Rails just like normal. So: 

  map.connect 'helloWorld', :controller => 'root', :action => 'hello'

refers to the real url helloWorld, even though it's in its own mini routes.rb. So it's all normal and 100% Rails.

Only one thing in the instructions was wrong: the routes.rb, they say, "In the extension directory (/sample/vendor/extensions/queen), edit the queen_extension.rb file, to define the routes to your extension, replace:" but this should be in the routes.rb, actually (perhaps it's changed?).

And then you... follow the instructions and finish, and it works perfectly. Not much of a blog entry, I know, but perhaps my optimism about Radiant has gotten the better of me.

No comments: