Chapter 11
Page 125. I need to create a users table. You’ve seen me do this enough, before. I don’t think I need to show it again.
Page 126. I generate the model for User. I generate all of the controllers for Login and User.
Ok, I keep following through th chapter. It doesn’t get interesting until…
Page 131. I need to create a User.login method. In it, I need to pass the name and password that the user entered, to the find method. Here’s how the book shows that method call:
find(:first,:conditions => ["name = ? and hashed_password = ?",name, hashed_password])
Now, Ackbar has the ability to do simple SQL fragments like this one. So, I could code the method exactly this way and it would work. Or, to make the conditions look a little more KirbyBase-esque, here is an alternate implementation:
find(:first){ |rec| rec.name == name andrec.hashed_password ==hashed_password }
I am probably a little biased, but I like the second way a lot better. :)
One more change on page 131. I need to add an Order.count_pending method. The book’s version looks like this:
def self.count_pendingcount("shipped_at is null")end
But, as mentioned earlier, KirbyBase uses Ruby’s nil object instead. So, my implementation of this method will look like this:
def self.count_pendingcount { |rec| rec.shipped_at.nil? }end
That’s all there is too it. The rest of the chapter, while interesting to finish, holds no code that KirbyBase could not handle.
So, I made it through Chapter 11. And, I’m left with a finished Depot Application that performs identically to the one in the book, only it is using Ackbar/KirbyBase as it’s database management system.
This exercise actually went smoother than I had hoped. A big reason is the obviously well thought out design of ActiveRecord, making it possible and practicable to substitue non-SQL database management systems. The other big reason this went so smoothly is due to Assaph Mehr’s care and dedication in crafting Ackbar. Thanks, Assaph!
Even though I accomplished my goal, I would like to post one more entry in the next few days. In it, I will try to summarize some of the lessons I learned while working through this exercise, some of reasons you might consider using Ackbar/KirbyBase in your Rails development, and some of the areas where using Ackbar/KirbyBase probably doesn’t make sense.
miumiu replied:
It is not more often that, the way of Prada’s fashion feels is to be the conflicting of the general compromise. Simply because $3.8 mil range can certainly dispatch even a monetarily protect specific proper tizzy.
April 22, 2013 at 6:09 am. Permalink.