I have a html table which consists of columns for days, and rows for hours of the day.
I intend this to be a UI widget, similar to the commonly seen calendar date picker.
Clicking on a particular cell of the table would select that date and time for creating a new reservation.
I was considering using a url to represent this selection such as,
http://jupiter.local/reservations/new/2009-09-10/1200/1300
or
http://jupiter.local/reservations/new/date/2009-09-10/start-time/1200/end-time/1300
Is this a valid approach?
I have read a little about rest, however I still don’t get it, except for the obvious example used for showing how to edit a blog record. e.g. blog/posts/23/edit
Currently while playing around with the app, I input the details via form fields, however the date-time select widget will make things much easier to use.
The (current) plan is to render out a series of urls for the hours which are available. If a slot is already booked, then no url is rendered. Of course I would validate the input as well.
To begin with I will assume that a single hour slot is all that can be booked.
I see that websites such as airlines tend to render out a series of urls with a unique code. I expect this requires a session to keep track of these unique id’s.
I am looking for some guidance on the approach as I have not designed something like this before and it is primarily intended as a learning experience.
Thanks
I’d say you are overcomplicating a bit the RESTful routes. A REST URI emphasizes on working with resources. A reservation is a resource. A Date, IMHO, it’s not. It’s mostly a param, and thus, you should be working with something like:
Although, I’d try to send them using a POST method (http://jupiter.local/reservations/new)
In either way, the controller will work with params[:reservation][:date], params[:reservartion][:start-hour], etc.
It’s a more simply approach.
With that, I’m guessing those are attributes mapped to a table. If not, you can easily create “virtual” attributes for the model with the
sentence.
If you send this through AJAX (which I guess you’d using from your description), Rails will add an authentication string, and you can also add your session ID (though I think it adds it aswell).
If you need more ideas, be sure to update your question 🙂