views:

18

answers:

1

As an Oracle ADF developer I am familiar with being able to create an Entity (the rails equivalent would be a Model) that includes all of the DB constraints (PK, FK, unique, length, any non-trigger induced constraint). As a result, in ADF I can very easily create a field on the view that is based on an Entities attribute.

For the sake of example, I place 3 such fields, one is a String (or VARCHAR2 in Oracle...) with a max length of 20, and the other is an INT and a DATE. The metadata (type, length constraints) are stored in the Model. And by default, any field generated with automatically include this validation on the front end. So, the first field, the String(20) will be a text input field with a max length of 20. So, question 1, will rails do this automatically on the front end or must I go and set this? Now, in ADF the int field that is placed on the view will not allow the user to enter non-digits (this will trigger on an attempt to update the Model (hitting submit, going to a new page). So, question 2, does rails automatically prevent non-digits? Also does rails have re-usable validation for simple things like phone numbers, addresses. Lastly, question 3, by default in ADF, any date will automatically generate a typical calendar widget for input. Does this also occur for rails? What does rails use for these kinds of javascript widgets if this isn't the case?

+1  A: 

Hi, Rails does recognise your datamodel automatically, but does not add any validation and stuff automatically. Not sure why not, because all the knowledge is there. I guess it has something to do with performance?

I know of one plugin that does this for you though: dr. nic's magic-model-generator. It is not the same as ADF but it's a start. It investigates your datamodel and adds all the required validations and relations to your models.

As to dates, and forms, either you use something like formtastic, and then everything is somewhat automatic (adviseable). Or if you choose the more standard, manual way, use the calendar-date-select gem (gem install calendar_date_select).

Hope this helps.

nathanvda
Hey, do you recommend any javascript frameworks to use with RoR? I am thinking to go that route instead of install a calendar widget/each other widget when needed. Maybe something like jquery ui.
Zombies
jQuery and jQuery ui are a very good choice indeed. I use jQuery, and use a somewhat ad-hoc decision process :) While i personally prefer jQuery, i think you should also look at Netzke, http://netzke.org, which seems to be offering a cleaner integration between extjs and Rails.
nathanvda