More docs

Posted over 7 years back at The Hobo Blog

p.s. As I mentioned a while back, the manual source is in Markdown, and the PDF manual is generated by Safari from HTML + CSS. Anyone got any bright ideas for getting a contents page with page numbers on it?

More docs

Posted over 7 years back at The Hobo Blog

p.s. As I mentioned a while back, the manual source is in Markdown, and the PDF manual is generated by Safari from HTML + CSS. Anyone got any bright ideas for getting a contents page with page numbers on it?

Episode 24: The Stack Trace

Posted over 7 years back at Railscasts

The stack trace can be a very useful tool when it comes to debugging. Learn the ins and outs of how the stack trace works in this episode. Note: I am using an older version of the Rails bundle here so it might be a little different than yours. The command in the newer version is called Install Plugin and requires you to type textmate_footnotes in the search.

MyConfPlan: Check Me Out

Posted over 7 years back at zerosum dirt(nap) - Home

Dr Nic Williams wrote a nice little app to allow folks to plot out the sessions they’ll be attending at Railsconf (or any conference, for that matter) and share them with others. In case you’re curious, check out my tentative session list.

Some of those decisions are tough ones! In particular, I’d like to see both Nutter’s JRuby talk as well as Dan Webb’s javascript-fu presentation. I’d also like to attend both Matthew Bass’ homesteading talk as well as Brian Leonard’s Tooling/NetBeans session. Sigh, decisions decisions.

Also of note: Dr Nic built MyConfPlan in Hobo, which seems to have come a long way since I last checked it out. Very cool stuff.

Zed Shaw - Ruby on Rails Podcast

Posted over 7 years back at Ruby on Rails Podcast

The author of Mongrel talks about its development and condemns HTTP while offering to save the internet with hate.
Also mentioned:

Manual updated

Posted over 7 years back at The Hobo Blog

I’ve just uploaded a new version of the manual. Highlights of the new content are:

DRYML:

  • Dynamic inner-tags

Hobo Model Controller:

  • Controller customisation
  • Controller data filters
  • Auto-complete (the controller side of things only)

Probably most significant is the controller customisation stuff. I’ve mentioned the new mechanism in a blog-post or two, but now the whole set of options is documented.

Enjoy.

Manual updated

Posted over 7 years back at The Hobo Blog

I’ve just uploaded a new version of the manual. Highlights of the new content are:

DRYML:

  • Dynamic inner-tags

Hobo Model Controller:

  • Controller customisation
  • Controller data filters
  • Auto-complete (the controller side of things only)

Probably most significant is the controller customisation stuff. I’ve mentioned the new mechanism in a blog-post or two, but now the whole set of options is documented.

Enjoy.

Episode 23: Counter Cache Column

Posted over 7 years back at Railscasts

If you need to display the record count for a has_many association, you can improve performance by caching that number in a column.

Episode 22: Eager Loading

Posted over 7 years back at Railscasts

One way to improve performance is to cut down on the number of SQL queries. You can do this through eager loading. Learn all about it in this episode!

Hobo 0.5.2 released

Posted over 7 years back at The Hobo Blog

OK 0.5.2 is now available, both in the svn trunk and as a gem

* hobo-0.5.2.gem

* Changelog

The important breaking change is that the customisation hooks in your hobo_model_controllers no longer work. e.g. if you have

def create_response
  redirect_to "..."
end

That will no longer work. The equivalent is now:

def create
  hobo_create :html_response => proc { 
  redirect_to "..."
  }
end

If you have done a lot of stuff with those hooks, you might want to wait until tomorrow before grabbing 0.5.2. I’m hoping to put a decent chunk of time into catching up with the documentation tomorrow.

Enjoy!

Hobo 0.5.2 released

Posted over 7 years back at The Hobo Blog

OK 0.5.2 is now available, both in the svn trunk and as a gem

* hobo-0.5.2.gem

* Changelog

The important breaking change is that the customisation hooks in your hobo_model_controllers no longer work. e.g. if you have

def create_response
  redirect_to "..."
end

That will no longer work. The equivalent is now:

def create
  hobo_create :html_response => proc { 
  redirect_to "..."
  }
end

If you have done a lot of stuff with those hooks, you might want to wait until tomorrow before grabbing 0.5.2. I’m hoping to put a decent chunk of time into catching up with the documentation tomorrow.

Enjoy!

Episode 21: Super Simple Authentication

Posted over 7 years back at Railscasts

The final piece of the administration puzzle: authentication. There are many different approaches which is why I saved this step for last. This episode will cover a few techniques including the simple solution used for this site.

Episode 20: Restricting Access

Posted over 7 years back at Railscasts

In this second part of the series on administration, you will learn how to lock down the site to keep the public from accessing the administration features.

REST vs AutoComplete

Posted over 7 years back at zerosum dirt(nap) - Home

After struggling with it probably a little bit more than I should have, I’ve totally come around to the REST way of looking at things. It seems clean and nice, and I’m 100% behind it. That said, I’ve found that once you adopt the mentality, things that don’t gel with it start to stick out like the guy in the fur coat at the PETA meeting.

Case in point: the ever-popular Rails auto_complete_field helper. To back up my accusation here, let’s walk through an example scenario with a REST app, and examine the issues that arise…

Imagine a really simple web application which consists of a collection of Articles. The only user interaction is that guests can comment on articles and tag them with keywords. So in a RESTful world, we have an Articles resource, and a Tags resource. Tags are also nested on Articles such that when you ask for /articles/:article_id/tags you’re asking for the subset of tags which have been applied to article_id. We might present these as a tab you can click on when viewing an article resource in a browser.

Now let’s say that there’s a form somewhere (maybe the #new action on an ArticleCommentsController), which can be used to apply new tags to a given article. There’s an auto_complete_field in that form, that will suggest tags to apply to an article, based on the tags that have already been applied. Dumb example, I know, but hear me out.

So, given this scenario, it would make sense to point our auto_complete_field helper at article_tags_path(article_id). This is about as RESTful as it gets — we’ve become a client of our own API. Nice! Our #index action on ArticleTagsController, in a perfect world, would do a couple things above and beyond just displaying the pretty HTML list of tags on the article:

  • It would have a respond_to block. if a browser client is asking for XHTML, we probably want to render a nice paginated view of the relevant tags, ordered by weight, with a nice layout. On the other hand, if we’re asking for XML or JSON, it just returns no-frills data in the appropriate format.
  • it would optionally check for a filter query string. perhaps we set params[:filter] = :attribute_name and then make the actual string filter value (the thing we’re trying to help auto-complete) available via params[:attribute_name]. in the case of our tags example, we’d end up with a params hash that has filter=name and name=zer (or some other text string). If a filter parameter is found, we’d filter the results by the pattern specified. This could all be wrapped up in a nice little helper.

This proposal raises a couple issues. First, the auto_complete_field helper as it exists today expects us to return some HTML from the AJAX call that we can plug into an appropriately named DIV. This is simple and works well, but if we’re really consuming our own web service, we should probably be talking to it via JSON or XML and have a JavaScript handler to process the results, converting them into list format or whatever it is that we desire. But I have to admit that this convenient hack works nicely.

More importantly, if the auto-complete filter is being applied to the collection of resources, that means it maps to the #index action by way of a GET request. So our parameters end up encoded in the URL with a query string like ?filter=name&name=zer. Obviously, GET params are a little more limiting than POST params in terms of length and (perceived) security. But for simple filter strings that take a short sequence of characters, I don’t see this as being an issue. And this is always the case when doing an auto-complete, as far as I can figure.

Note that the auto_complete_field JavaScript helper doesn’t actually allow you to specify an HTTP verb other than POST, although that’s easy enough to change. Surely the core team would accept the one-line fix required to support a :method => :get option if it’s the “right thing to do”. The real problem is more of a philosophical one: are we, as a community, really going to embrace REST 100% or is it acceptable to add small bits of cruftiness in places where it seems inconvenient?

A perfectly legitimate half-way solution is to define a standard #autocomplete action for any resource you want to use in this manner. The advantage to this is that you can easily use a POST against a custom :collection method on the resource. That way, we continue to work inside the existing box of conventions. But I ask you, is that really RESTful?! What do you think?

Update

Posted over 7 years back at The Hobo Blog

You may have noticed I’ve been a little quiet of late—both on the blog and the forums. It’s end-of-project syndrome. We’re just coming to the end of the final delivery in the first major client project built on top of Hobo. Deadlines are hard work!

Here’s a bit of an update about what’s been going on with Hobo recently.

First-up, Hobo 0.5.2 is due to go out. I’ll make a commitment, because I’ve found that’s a good way to ensure it actually happens - I’ll get 0.5.2 out by the end of this week. In this version are a bunch of fixes as always, the new mechanism to customise controller behaviour, and a nice extension to ActiveRecord which came out the recent stuff on scope_out.

If you followed the comments on that post you probably saw the link to neotrivium from kaspar (thanks!). A very nice development of the ideas in scope_out but lacking some scope_out features such as cacheing of scoped associations. All this inspired me to see if I could take the idea a bit further, and you can see how I got on in Hobo 0.5.2. By way of a sneak preview you can do:

Post.comments.published

And get back a full AR association proxy, which you can either treat as an array, or use to do further finding, counting etc. All this for the bargain price of:

def_scope :published, :conditions => "published = 1"

In the Comments class. You can also do things like:

Comments.published.find(...)
Comments.published.boring.count

Handy! (the SQL fragment to identify a boring comment is left as an exercise for the reader)

Let’s see, what else..?

I’m waaay behind on the forums, so a big apology to anyone who’s looking for help and hasn’t yet received any. I’ll get there :-)

On the subject of community - I was very happily surprised to get this mail yesterday:

Hey Tom,

We started a #hobo channel on freenode for hobo users. Please come visit us irc.freenode.net #hobo and help support your freenode hobo community users :) We are supporting eachother right now and would like to see you come through.

UncleD @ http://rubyonrailsblog.com

Awesome! I’m afraid to say I haven’t shown my face as yet (did I mention I’ve had a deadline on?) I definitely will stop by from time to time, but I must warn you I’m not a great IRCer.

And saving the best news for last–a little tentative at this stage, but potentially a big deal. We at HoboTech are close to making our first hire. I’m REALLY looking forward to the prospect of NOT BEING RUN COMPLETELY OFF MY FEET ALL DAY EVERY DAY!!! Sorry just venting some frustration :-) If this works out it’s going to have a big impact on the time I have to focus on the many aspects of Hobo (documentation!), so cross your fingers.

Catch you again later this week with the “0.5.2 Released” post :-)