Ruby on Rails Monday, November 14, 2016

Just to let you know that what you are wanting to do is very difficult to get right.

As somebody that has tried 3 or 4 times and never been happy with the outcome,
I'd suggest that you do some requirements work up front to really understand the
MVP that you need for the first go around. Having it actually used by people will
bring to light a lot of stuff that will need to be addressed for the next version, so 
take it in small steps so that you don't have to re-write too much code to move forward.

To your actual question, you can easily write your own helpers that will populate the form
with the names you have stored in your database.

- Brendon.

On Sunday, November 13, 2016 at 5:29:11 AM UTC-8, Jussi Hirvi wrote:
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:

       <%= f.label :name %>
       <%= f.text_field :name, class: 'form-control' %>

What would be the neatest way to make this code more generic, so I don't
have to actually write the field names here and in several other places?

I need to iterate a field list either in db schema, or in a
manually-built array of fields.

- Jussi

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/be2ce29d-de30-4922-bed5-fe800a108744%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment