Adding Ajax to Journal.ntf on Rails Demo
Keeping in mind yesterday's Journal on Rails app, take a look at this Journal on Rails plus Ajax demo, before coming back to read on.
Nice isn't it!? You can create, edit and delete entries all from within the "view" using Ajax calls.
Two of my favourite toys at the moment are Ajax and Rails. That's why I was excited when I found the Ajax Scaffold Generator the other day while reading the Ajaxian.
Scaffolds are a quick and easy method of creating all the code needed for a web application in Rails. Given a SQL table it examines the "fields" it contains and builds a form to enable user input/data output. Depending on the type of fields it creates different user inputs. Much like Domino. It also creates the "lists", which we'd know as Views. It's really clever.
For reference, here's the default look for an app based on the same Journal SQL table and built using Rails' default scaffold. Boring isn't it. This is how the Journal on Rails app started out until I added the stylesheets and whatnot.
So, how did I make the fancy Ajax "view" then? Well, Richard White has created the Ajax Scaffold Generator. Once installed (which is ridiculously easy) you can over-ride the default scaffold and create a web application based on Ajax.
So, last night, I created the new code for the Journal based on Richard's scaffold. It took one command line to generate the code and all I had to do then was FTP it.
Note that all three versions are based on the same data. Don't believe me? Well, I added the "Open" link to the end of each row in the Ajax demo, which open the same entry but uses the "journal" Controller instead of the one called "ajax". This information is passed to Rails via the URL, which it interprets to see what controller you want to use and what action you want to perform (create, list, edit, show etc).
In our case the URL might be something like:
/rails/journal/show/8
Which translates to:
/project-directory/controller-name/action/entry-id
Rails receives information in a similar way to how Domino translates URLs like /view/document?action.
You gotta love RoR. Tomorrow - Ajax Views in Domino in which I let off a little steam.
Sigh... just when my Domino apps were starting to look half way decent (thanks to your many articles), you go and raise the bar tenfold! I can't wait to see the Ajax views in Domino.
This is great...I really like this new departure, but maybe instead of going betamax with the best solution which I understand can only be hosted currently on a few providers, I would like to see the fine php work you started (VHS approach) being built into a framework, providing a learning tutorial, with mySQL support, I know this would be helpful for me, however, if this has already been discussed before this comment, my apologies.
I wouldn'g get too excited Ed.
Glyn. Not making trouble this week then? :o)
PHP isn't on my list of playthings at the moment. Sorry. Been there done that. Time to learn some other methodology.
Where do you find the time Jake?
Jeff. It's the beauty of managing yourself and working from home. There's always the time and no guilt about doing it in "somebody else's time". Then there's the couple of hours every night when the soaps are on and I'm allowed upstairs.
Anyway, this Ajax addition only took about 10 mins.
I'm actually writing about this very thing for an article I'm working on:
"Utilizing AJAX for the Online Management of Domino Data"
Doesn't quite have a ring to it... I know.
And what's that they say about "great minds"? Brilliant work here man, like Ed said - you're raising the bar!
-Chris
jake
the way it looks, maybe next week we have from you at last
RAILS ON DOMINO
Jake,
excellent stuff here again- as previous posters point out this exploratory work is great to read and really raises awareness of emerging techniques & frameworks. Nowadays I spend my time with Oracle rather than Domino [and can't say I ever miss it :-0] - but this sort of thing is great for seeding development ideas and definitely raises the bar.
Your effort is greatly appreciated, keep up the great work
Ryan