It just needed to happen. The Hardcore Racing eStore seemed slower every day. It started off as just an attempt to cache the make/model dropdown since we now wanted to put it in the search box in the left sidebar, which is visible on every page. It was simply an unrealistic number of queries to build that dropdown—with all the other queries I expected to make for a page’s request.
Read on to learn how I made my site FAST!
Read the rest of this entryHere’s a blog entry for the sake of making a blog entry. I dj’d on dnbradio for the um.. third time tonight. It was a pretty long set, but it wasn’t great. I guess it’s just as well cuz I didn’t record it. Also, it’s kind of hard to stab at your keyboard when you’ve rubbed off all your keys. Or I guess I more like scraped them off. But anyway, it looks really frickin cool, and I can work fine with it most of the time. Hehe.
In other news, I made some larger updates to the Hardcore Racing eStore this evening. Both the search and the browse functions have been enhanced. I’ve ditched the idea of using ajax for the browse feature. It really didn’t make much sense. Instead, I take you to a new page each time. (It doesn’t break the back button!)
But the real exciting part about what I’ve done is the caching. I’ve been able to cache bits of generated html that require lots of database interaction so that they can be just called up in subsequent requests—without the costly database query.
And it was damn easy… (stay tuned)
Ruby on Rails 1.0 was just announced, accompanied by a new website. I was active in #rubyonrails when it was announced:
14:51 ( onpo) can anyone access rubyonrails.org?
14:51 ( onpo) YES YOU CAN!
14:51 ( onpo) ITS OUT!
14:51 ( onpo) 1.0 is OUT!
14:51 ( onpo) WOoooooooooooooooooooooooooooooooooooooooooooooo
14:51 ( Qerub) the website has been 37signalized.
14:51 ( zraii) whoa
14:51 ( Ave) well hot diggity, toss the confetti
14:51 ( zraii) that just went up
14:51 ( danfg) OMG IMMA HAVE A HEART ATTACK
14:52 ( thread) ho damn
14:52 -+- bitsweat changed the topic of #rubyonrails to: 1.0 Release | Beta
gems: gem update --source http://gems.rubyonrails.com | Paste:
rafb.net/paste | Logs: loglibrary.com/channels/preview/62
14:52 ( thread) BAD FRICKIN ASS
14:52 ( thread) TY RAILS PPL
14:52 (@noradio) ____ _ _ _ ___ _
14:52 (@noradio) | _ \ __ _(_) |___ / | / _ \| |
14:52 (@noradio) | |_) / _` | | / __| | || | | | |
14:52 (@noradio) | _ < (_| | | \__ \ | || |_| |_|
14:52 (@noradio) |_| \_\__,_|_|_|___/ |_(_)___/(_)
14:52 (@noradio)
14:53 ( argv[0]) haha
14:53 ( danfg) WOOHOO!
etc… :)
I thought I would take a moment and show you all just how easy these fancy AJAX interface tricks are with Ruby on Rails and some javascript libraries. With all my years of web development experience, I never really learned learned javascript properly. (I just borrow code from the online examples.) But RoR makes this stuff a breeze!
The real benefit to using this method is that when the user makes their selection, I don’t need to send them an entirely new web page. Instead, the “smart” (read: javascript equipped) web page actually makes an HTTP request to the server in the background. The server then responds with an HTML fragment that is then dropped inside a DIV element (replacing its prior contents, if any). As the programmer, I usually only need to make calls to the Rails “helper” methods which in turn spit out (still) very simple calls to the included javascript libraries. Why is this so cool? Because I can make a snappy-quick interface without sending down the entire catalog, and with an absolute minimum of work!
Read the rest of this entryIt’s been almost 24 hours since I made the switch to the new web server. I’m now running the site from a Linode that we’re hosting some sites on for work. This is where I was linking all the big files from on here.
Typo is a very nice blogging engine written in my favorite new technology, Ruby on Rails. It has all sorts of neato “web 2.0” (as they call it) features. Try posting a comment. I didn’t even turn on moderation because the spam bots apparently don’t know how to post comments via ajax (yet). Wordpress was getting pounded pretty hard with something like 50-100 spam comments a day.
Oh, and sorry for dropping all that content… I’ll try and bring it back soon.
Fresh on Slashdot…
Robby Russell writes “ONLamp.com has published another article by Curt Hibbs titled, ‘What is Ruby on Rails?.’ In this article, Curt goes on to discuss all the major components of the popular Rails web framework and shows it does a lot of the heavy lifting for you. This article highlights all the major features, from Active Record to Web Services, which are going to be included in the upcoming 1.0 RC release of Ruby on Rails. With one book published already and four more on the way, do you think Rails will continue gaining as much popularity in the coming year?” An interesting follow-up to the two part tutorial from earlier this year.
I told you guys… RoR is on the upswing.
Oh, and my eStore has finally gone into production! Check out the Rails Goodness. Please excuse the design. I get to battle with clients and bosses over design/usability issues, so don’t blame me if the fixed width page is cramping your style.
Hardcore Motorsports eStore (site no longer available)
That first post I made about Ruby on Rails was more of a brain fart of excitement than a proper explanation of why it’s so cool. I really wanted to explain in my own words why I’ve decided I’d rather be working with RoR than any other framework, or at least the one I’m used to—PHP.
First of all, RoR is more than just a language; it’s a framework. This means that developers are encouraged to write applications in a roughly standard way, and all rails apps have a very similar flow. For instance, when you first begin a new rails application, you use the “rails” command line tool:
$ rails myapp
And rails generates all your starting directory structure for you—where to hold the application files, test code, external libraries, and so forth. And the fun doesn’t stop there! Say I have to write the same CRUD code I’ve down a thousand times in PHP to let an admin manage, say, users.
$ ruby script/generate scaffold User
Blamo! I get a model class that represents a user in the database, and a controller class complete with generated templates that handle all the flow for a simple CRUD. I need only to extend from this.
Rails uses what they call the Model-View-Controller (MVC) model. An instance of a model represents a single record in the database. It knows all about itself: how to validate its attributes, what its relationships to the other models are (which gives you lots of really sweet functionality for FREE!), and whatever else you want to program in. The view is nothing more than an erb (embedded ruby) template that spits out values calculated in the controller, which in turn is the class that dispatches and handles actions (incoming requests). Find yourself putting too much code into the view? Move the code into the helper (every controller has one) and call your new helper method from the view.
Here’s just a short example of how you might fetch some information about a product and display it to the user:
The controller, app/controllers/store_controller.rb:
class StoreController < ApplicationController
def product
@product = Product.find(params[:id])
end
end
The view, app/views/store/product.rhtml
<% @product.attributes.each do |field, value| %> <%= field %>: <%= value %><br /> <% end %>
No lingering sql or extra code of any kind. Couldn’t you get used to that?
Yeah, you can do all the same stuff in PHP, but your code will probably turn out pretty ugly. I’m just loving how elegantly Ruby on Rails solves these web development issues. Just the other day, I started experimenting with AJAX and script.aculo.us js libraries to achieve some quite impressive effects and interactivity with very little effort.
The Rails people like to call it a “disruptive technology.” I’m not sure to what extent Rails is a disruptive technology, but I’m pretty sure there is a place for it in the future as we continue to see its user base grow like wild!
And there are lots of good tutorials and references at documentation.rubyonrails.com.
I’ve gotten behind! Hooray for rapid-fire postings!
I’ve known about it for a while now, but I only got my copy of Agile Web Development with Rails by Dave Thomas and David Heinemeier Hansson a couple of weeks ago now. I’ve since dived right into RoR, and I must say… the more I learn about it, the more impressed I become. It seems like the most elegant and simple way to write web applications I’ve ever encountered. This all stems from the DRY principle (Don’t Repeat Yourself). DRY says that every bit of application logic should be expressed only once in your code. Models form database objects that are very smart (they know their associations with other objects, they can validate themselves, etc).
I could go on and on about RoR, but instead I’ll just drop you a few links: