I am going through the railstutorial.org book, so I am still a newbie with ruby.
My goal is to create my own multi-site framework with admin pages (including pages for administering uploaded files, users, and dynamical pages). I have been experimenting with Refinery, but it may be too difficult to modify for different purposes (not sure yet).
For now, based on the tutorial, I know how to use form_for to produce forms. The fields are handled like this:
If I understand you correclty you want to do something like:
<% fields.each do |field| %>
<%= f.label field %>
<%= f.text_field field, class: 'form-control' %>
<% end %>
where fields is an array of symbols representing the names of attributes
you want to accept via the form.
Personally, I prefer to have things spelled out explicitly as it's easier
to see the final shape of HTML. If your goal is to save typing maybe you
could consider using some kind of snippets?
First of all, thanks for admission to the list. I had to email the list owner to accomplish that.
<% fields.each do |field| %>
<%= f.label field %>
<%= f.text_field field, class: 'form-control' %>
<% end %>
Ok, that's good to know.
Personally, I prefer to have things spelled out explicitly as it's
easier to see the final shape of HTML. If your goal is to save typing
maybe you could consider using some kind of snippets?
I am mostly thinking of admin pages. Over the years, I have put together a personal cms solution in another language (lasso). There I had for each admin page an array of arrays containing field names, field types (text, textarea, radio, checkbox, date, hidden), validations (no-html, integer, date, email, unique, length, etc.), operators (eq, lt, gt, etc.), text field sizes, and some other things. It worked well for me, and maybe I will try to create something similar now with RoR. Though maybe I could use the db/schema as the basis, and only declare additions and exceptions to the schema.
However, I am still open to alternatives, for example Refinery.