Ask YC: I built this to learn Rails in 2 days. What do you think?
I sat down last week and felt determined to learn Rails as quickly as possible. I skimmed the Agile Web Development With Rails book and got to work on a fuel-calculating mini-app. Time to completion: 2 days with very little sleep.
Site: http://fuel.dustincurtis.com
While I was building the site, I kept wishing that I could look at an app's code in its entirety for help with syntax (searching google gave me nothing), so here's the code (it's probably very shitty): Code: http://itsalltaken.com/fuelcode
What do you think of the design and implementation?
PS. I need to add in a bunch of higher-level validations to prevent people from using obscene numbers/dates/etc. Also the mobile version isn't quite done yet.
26 comments
[ 4.0 ms ] story [ 89.5 ms ] threadIt's very elegant in its simplicity - well done!
Bonus points for being from Santa Rosa. I spent four awesome years living there. Pepe's still has a special place in my heart for best vegetarian burrito, evar.
Your code will improve at once if you read a Ruby book. For example, you confess to being confused in your fueling.rb model file --
<GOBBLEDEGOOK>
-- where you define a class method on the Fueling class, then set an instance variable (@current_id). I believe this will set @current_id in the scope of the Fueling class. Then you define a Fueling instance method (validate) and try to read @current_id inside it -- but it fails, because when you're in an instance method @current_id refers to a variable in some actual Fueling object, not to the @current_id that's in the scope of the Fueling class.
</GOBBLEDEGOOK>
You may have no idea what I just said. Even experts can get lost in Ruby's class hierarchy. So get a Ruby book and it will help you sort out the Ruby approach to OO programming.
People seem to like "Ruby for Rails", and its author is smart. The Pickaxe book ("Programming Ruby") is more famous and I liked that just fine, too. (Don't tell Zed Shaw.) If you're not already intimately familiar with another OO language, you might not want to learn Ruby from _Why the Lucky Stiff's Poignant Guide to Ruby (with cartoon foxes!)... although that's what I did.
P.S. Just today I had my accountant explaining to me the importance of separate tracking for "business" miles that I drive for my company, as well as tracking total miles driven. Food for thought. Just don't offer that feature if you plan to take the service down sometime during a tax year...
[0] or at least differences between Ruby 1.6, which is covered in the book, and 1.8, which most people use.
PS: Could you add km/h and L as well?
Along a similar note, I wish I could work along these lines. I tend to be too much of an academic, and spend endless weeks reading about whatever (rails in this case) and never actually get down to implementing much, then get attracted to the next new shiny toy, and move on. So from my perspective, great job!
I saw your confusing comments for non-working Fueling validate(). Why don't you just check for nil there? It's always nil for 1st time users, no?
Location: /
Location: /account/login Location: /fuelings I was never able to access the app again after the last error.The javascript stuff to make the forms pretty (and disappear when active) is the very next step. Login cookie is next.
account/login tabbing: I'll fix that. Thanks.
The time calculation is based on midnight of the date you select on the Add Fueling page. I'll add the time of day, but I don't think people keep track of their fueling habits that closely.
Regarding editing, I've removed your NULL date, so you can log back in. I'll add verification to prevent that from happening in the future.
Again, thanks. Awesome.
http://weblog.jamisbuck.org/2006/10/18/skinny-controller-fat...
I've pastied an example of how this approach should help.
http://rafb.net/p/P4YMM359.html (Pastie.caboo.se is down now for some reason, so this is good enough for now)
Generally, the only major issue I see throughout is the repeated Fueling.find(:all) calls. Not only will that hit up the database quite a bit (Rails 2.0's query caching would help a little, but that's beside the point), but it would take up a crazy amount of memory once you get a lot of fuelings in the system.
Keep at it!
They're rebooting after a failed update or something.
edit: it's back up (12:41am pst)
My friends and I built the app in the link below with Rails and in 48h too.
http://pagestacker.com
ThereXs an interesting story behing its development.
It was in september. At the time, we were pretty much still learning about Rails. We had heard about a contest in which participants should build a complete web app from scratch in 48h using Rails. It was called "Rails Rumble".
http://www.railsrumble.com
After those initial 48h, there was a 14 days period of voting that was open to the public in order to choose the "best" apps (whatever that means). Although we led the voting almost since day one, the organization decided to disqualify most of our votes and gave us an "honorable mention".
In the link below you can find a Twitter feed with the ranking results that were published as the voting developed.
http://twitter.com/railsrumblerank
We still donXt fully understand the reasons why the organizers decided as they did. Maybe it had something to do with the fact that weXre from Brazil in our team ("I didnXt even know brazilians had computers" =)). Who knows...
Anyway, what matters is that weXre seing some traction among users, not only in Brazil but around the world (not much, but some), and we must decide if we should invest more and try to enhance the app.
What weXve found is that most users never heard anything about the segment to which the app belongs, much less about its leader, which has only some 3 million registered users around the world.
So, IXd really appreciate some honest feedback about it.
Thanks!