Okay, so I've got a User class. It has :username and :password. I now
decide to be google and store every bit of information I can possibly
find about the user. So now I
have :street :city :state :zip :email :et cetera. Because I have
stepped on my rake, I can't use it (ie shared host, so no rake). I
have already added the fields appropriately to the database. Now, I
need to figure out how to add them (preferably simply) to the
show.rhtml file created by my scaffolding. I looked for something like
@user.to_html, but that didn't work right off the bat. Is there a
simple method of getting all the info into an HTML form easily? I know
I could just do a for each attribute type of loop, but is there a pre-
defined way? I'm trying to keep this program simple at first, lol.
Also, the only ones that show up in new.rhtml and index.rhtml are the
old :username and :password. I'll need to be able to change them
quickly too, if possible enough.
And note, I can rake on my dev environment. So if there's a generator
that will automatically detect these in the database, that would be
very Ruby Rockstar ish. (inside joke).
No there is no predefined way. You could use a form builder to make it slightly easier on yourself (this is covered in Rails Recipes, and probably on the web somewhere), but you will have to still type out all the tags.
From what I understand of your first post, you now want to be able to
see those fields within the form view so that you can start adding
data to it.
What you'll have to do is look in the controllers' view folder. From
there look at the partial file '_form.rhtml' within there you'll have
to manually add the new fields into that form file. Just copy and
paste one of the already listed text_field and update the names to
reflect the information you would like to store, making sure it
matches the names in your database model of course.
That is supposed to do that when put in the controller? (I haven't
gotten it to work yet right, but it did make my index work correctly)
-Ryan
That should work in Rails 1.2.6 (though it may bring up a deprecation
warning), but not in Rails 2.0. In Rails 2.0, you can add it back using
a plugin.