Juanita’s Birthday
April 23rd, 2006Writing Down Goals
I’ve known for a long time that writing your goals is a major step toward achieving them, and I’ve done this in the past. I haven’t kept up on reviewing my goal list as much as I want to, and one thing that’s always been recommended that I’ve never done is share my list of goals with world. It’s a fairly scary thing to share your dreams. I worry about what people will think, and what will happen if I don’t achieve them.
I’ve been toying with the idea of posting all my goals on the web for a while now, and I just found a website that makes it really easy and interesting to do. 43things.com is a place where a ton of people are sharing their goals and encouraging each other. It’s a great idea and the positive environment helps me a lot. So now along with knowing all the music I listen to, anyone who wants can see my list of goals at 43Things. I hope this will further motivate me. Heck, I’m sure it will. There’s nothing like publicly declaring something in writing to light a fire under your ass to do it.
Rails Sortable Column Headers With Associations
Of all the magic things Ruby on Rails does by default, I’m surprised they didn’t automatically create sortable column headers. I figured out my own way to do it, but I couldn’t figure out how to sort columns correctly when the data for that column contained a foreign key – until now.
For example, I have a requests table with an employee_id field. This is an integer that references the id of some employee in my employee table. Sorting those integers doesn’t alphabetically sort my request list based on who made the request.
I finally found a good lead to the solution from a modified version of SortHelper2, by Jonathan Conway. His code worked great for me as long as I did my list function like this:
def list sort_init('id', 'asc', nil, 'cheeses', true) sort_update @cheese_pages, @cheeses = paginate :cheeses, :per_page => 30, :order => sort_clause, :include => [:cheese_maker] end
But I defined some functions in my class that I use so that I don’t have to rewrite finds every time, so I had to use custom/classic pagination. This got me to wonder what the code looked like for the find statement. I finally figured out how to use the :include statement in the find command to sort by an association.
find( :all, :include => :employee, :conditions => ["resolved_on is null"], :order => "employees.name asc", :limit => @it_request_pages.items_per_page, :offset => @it_request_pages.current.offset)
Normally I think the api documentation for rails is great, but how am I supposed to know how to do this from the find function definition of :include option (:include: Names associations that should be loaded alongside using LEFT OUTER JOINs. The symbols named refer to already defined associations. See eager loading under Associations). Okay, I guess there’s a decent example if you do find the eager loading section of the Associations definition.
Moisture Festival
What a weird name for a festival. What a weird festival. Fun though. Kim and I caught the final marathon night with Becka and Michael. It’s cool that it’s in the back of a brew pub so that you can buy beer during the show. There were some really unique acts. The best was probably the acrobat, martial art, sword fighting jugglers. Yeah, that’s multi-talented. The guy who blew bubbles blew my mind! I never knew bubbles could do those things. Next year I’ll have to see the burlesque show too.