AJAX Combo with Ruby on Rails

I put up another page on rails. This one shows you how, using ajax, to create self filter combo boxes in Ruby on Rails. I tried and failed, to do this using RJS (ruby javascript templates) … I simply ran out of time. That aside, the “old” ajax support in rails is great and pretty clean.

The tutorial page is up at: http://mudabone.com/aietc/?page_id=410

2 Comments

matt wApril 25th, 2006 at 7:00 am

I’ve got to say, all this Rails stuff you’re posting looks 1) like total Greek – was it really necessary to come up with a COMPLETELY different paradigm for web development, and 2) like a lot of work – seems like this project should consist of a simple HTML/JavaScript page using a library like prototype and a fairly simple web service (which is about 20 lines of JSP/ASP/Perl/XYZ. While I hate to be the naysayer who’s never used it, my impression of rails, having never used it, is that it’s another one of these “let’s make it so simple that it’s absurdly complicated” frameworks – kind of like ASP.net. Something really simple might be really simple, but something complicated (as most things are or at least become) is still complicated, but in a fucked up abstract you-have-to-know-the-blackbox-implementation kind of way. Please… englighten me.

AdministratorApril 25th, 2006 at 7:37 am

Greek? These tutorials aren’t great, the formatting is horrible. But, Greek?, no worse then the rest of the “non-human” crap out there.

“was it really necessary to come up with a COMPLETELY different paradigm for web dev”? It’s not completely different. You might not be familiar with the Model-View-Controller design pattern… that’s not new but it could be seen as a “paradigm shift”. Besides the MVC stuff rails isn’t really doing anything that different from .Net – it’s just about a zillion times more elegant.

This example does use prototype… that and scriptaculus are “native” in rails. While I haven’t quite figured out how they work (documentation is still pretty minimal on a lot of rails stuff, and I’ve got deadlines to meet on this rails project) RJS (ruby javascript) templates promise to remove the need for any javascript programming, ever. Which, unless you’re catholic, has got to be good news.

Why would you want to create a separate webservice and “20 lines of code” when you can do it in one project, simply?

Speaking of webservices you should check out REST http://www.xfront.com/REST-Web-Services.html – they make a great argument for “soap’s fucking stupid”. Rails supports REST and has some really nice http-header mechanisms that you can use right in your controllers.

In general – I think something really complicated – that’s not a spaghetti code nightmare of corporate stupidity – could be done very well in rails. Ruby is an amazing language and Rails makes it very easy to use.

Rails is “still complicated, but in a fucked up abstract …” … they call it convention-over-configuration. Learn the not-so-complicated abstractness and you’re golden… definitely beats the massive-architecture land of 365 days of config school paradigm that defines J2EE and .Net land and that you have to relearn for each release and each new massive “solves everything” retarded library from 20-book-hell land that comes out.

You should do a sample project in Rails – you’ll love it, guaranteed. It’s really frustrating to learn (just buy, and go through the book “Agile Development with Rails” but, as you learn it it’s like enlightenment. You bang your head trying to figure out the MVC way to do what you’ve done backwards your whole life and, when you figure it out you’re like… duh, that’s SUCH a better way of doing things. Kind of like test-driven-design or Agile development.

Rails (and Ruby) does come at a price currently:
1) it’s slow a shit.. you need good hardware if you’re doing rails, forget shared hosting for anything that’s not completely trivial. if (like a guy i met in Canada) you’re doing genome processing, you’ll need to write those libraries in something non-ruby. ruby is almost at the bottom of all benchmarks.
2) it’s really young (2004) and the documentation is still a bit fragmented or just non-existent (that’s why I try to write tutorials – you know, fix the problem).
3) it’s not a solution for everything. there are definitely things that you shouldn’t do in rails… like putting a front end on a horrific legacy database. You’ve got to follow their conventions or things will be at worst impossible, at best, a train wreck. If you come to rails like “How can I do this type of Java thing in Rails” you’ll get very frustrated (and laughed at from the community). Most java/.net/massive-architecture-heads need to read up on Rails Engines before they stop their bitching.

All that said – it’s still the best way to develop db backed websites I’ve seen (and I think I’ve tried most). It makes .Net look like a fucking dinosaur with a serious meth problem. I can’t stand going back to .Net after Railing for a week.