October 2007
11 posts
2 tags
Hallowe'en at Tho'ghtbot
Never having carved a pumpkin in my adult memory, this was the product of hours of labor:
questioning one-to-ones
I constantly find myself reviewing and questioning my domain model. Recently I noticed a pattern in 2 different webapps.
Here’s the requirement from the client
The web site has groups. Each group has a forum. Users can create and comment on posts in the forum.
A quick scan of that sentence finds 5 nouns we care about
Group
Forum
User
Post
Comment
Lets forget...
1 tag
Jester 1.5: Universal REST
It’s been quite some time since the last Jester release, but there’s actually been a great deal of work done on it since then. Jester’s object hierarchy code has been completely rewritten, some major new features added, and some syntax changes that break backwards compatibility. This release emphasizes working with customized server-side REST APIs, not just the ones generated by default in Rails...
Almost Painless Nested Resources
It’s often the case that you have a restful resource that needs to be accessible nested, and at root. For example, let’s say we have a storefront with a bunch of users and products. Each user can play with their own products, and the admin users can play with everyone’s products. You’ve got a :products resource at root, and a nested version to scope it under :users
# Admin see all products at...
ruby everywhere
Been doing some JavaScript apps recently in Rails and decided to push RJS as far as I could.
Along the way I found some things that are pretty nice to have on the client side to avoid having to code all your JavaScript in strings.
update_page
<%= link_to_function 'Yes' do |page|
page[:one].hide
page[:two].show
end %>
Putting that in your views Generates the...
1 tag
yeah what is that
Now most of the Rails community is familiar with map.resources since it was officially released in Rails 1.2.3. But another method came with it that I’ve never used or seen anyone use. So I decided to investigate it.
Looking at the doc for ActionController::Resources#resource it says
No default index, new, or create routes are created for the singleton resource controller.
OK,...
4 tags
The Ideal of Agnosticism
Less than anything, less than I could possibly say, does SQL makes me happy. In fact, it gives me Tourette’s, even-no-especially when properly formatted. “Hey guys how LEFT INNER JOIN are you SELECT WHERE doing INSERT SUM.” I know at least a few of you out there agree with me, because plenty of you are doing what you can to shield us sensitive code-aesthetes from the horror of this profane...
8 tags
Did you order the code red?!
On Fridays, we enjoy getting together for lunch and reviewing code which needs tender loving care. This week, our liveliest discussion surrounded responsibility for authorization logic.
The problem ~ where does the authorization logic go?
You’ve come across it before ~ you have a User model and a second model for which Users must be authorized to perform certain tasks:
def show
@event =...
Thoughtbot: Too lazy to present on our own stuff.
We’d like to give a quick shoutout to some of our friends who are spreading the word about our projects.
Jester
Mike Bailey recently presented on Jester in front of the Melbourne Ruby User Group:
I demonstrated using Jester, the awesome javascript library that gives you an active_resource-like client of Rails resources. Read more…
Pete Forde from Unspace is also spreading the...
4 tags
Using Jester from inside an XPCOM Component
One of the original reasons we decided to write Jester was for use in a XULRunner Application. This would give us the ability to make a desktop client application (written in XML and Javascript) that would talk to a Rails back end via ActiveResource.
Using prototype (one of the dependencies of Jester) in XULRunner is something that has been documented in other places, and once you apply those...
Remember your MVCs
From novice to expert, I’m sure every Rails developer believes in MVC. But all to often I’ve seen programmers cut right through the Model/View/Controller boundaries when implementing new features – especially where precedent hasn’t yet been set.
I can understand where the urge comes from, as there are times when the boundaries are fuzzy. Rails has the validates_confirmation_of for entering a...