Hopefully an easy question - post scaffolding add parameters

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.

-Ryan

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).

-Ryan

Furthermore, using Rails 1.2.6. :slight_smile:

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.

Isn't there a method like scaffold :user

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

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.

You could also just regenerate the scaffold. Any non identical file will be asked to be overwritten, only confirm the _form.rhtml file.

kopf1988 wrote:

Isn't there a method like scaffold :user

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.

You might want to look at the Scaffolding Extensions plugin: http://wiki.rubyonrails.com/rails/pages/Scaffolding+Extensions+Plugin

Jeremy