# Hopefully an easy question - post scaffolding add parameters

**URL:** <https://www.ruby-forum.com/t/hopefully-an-easy-question-post-scaffolding-add-parameters/125685>\
**Category:** Rails\
**Created:** [January 11, 2008, 5:25am UTC](https://www.ruby-forum.com/t/hopefully-an-easy-question-post-scaffolding-add-parameters/125685 "2008-01-11T05:25:13Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![kopf1988](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/74df32/32.png) [@kopf1988](https://www.ruby-forum.com/u/kopf1988)\
**Post date:** [January 11, 2008, 5:25am UTC](https://www.ruby-forum.com/t/hopefully-an-easy-question-post-scaffolding-add-parameters/125685/1 "2008-01-11T05:25:13Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![kopf1988](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/74df32/32.png) [@kopf1988](https://www.ruby-forum.com/u/kopf1988)\
**Post date:** [January 11, 2008, 5:29am UTC](https://www.ruby-forum.com/t/hopefully-an-easy-question-post-scaffolding-add-parameters/125685/2 "2008-01-11T05:29:18Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![kopf1988](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/74df32/32.png) [@kopf1988](https://www.ruby-forum.com/u/kopf1988)\
**Post date:** [January 11, 2008, 5:32am UTC](https://www.ruby-forum.com/t/hopefully-an-easy-question-post-scaffolding-add-parameters/125685/3 "2008-01-11T05:32:49Z")

</div>

Furthermore, using Rails 1.2.6. 🙂

---

<div class="post-metadata">

**Author:** ![kopf1988](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/74df32/32.png) [@kopf1988](https://www.ruby-forum.com/u/kopf1988)\
**Post date:** [January 11, 2008, 5:45am UTC](https://www.ruby-forum.com/t/hopefully-an-easy-question-post-scaffolding-add-parameters/125685/4 "2008-01-11T05:45:05Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![kopf1988](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/74df32/32.png) [@kopf1988](https://www.ruby-forum.com/u/kopf1988)\
**Post date:** [January 11, 2008, 10:39am UTC](https://www.ruby-forum.com/t/hopefully-an-easy-question-post-scaffolding-add-parameters/125685/5 "2008-01-11T10:39:31Z")

</div>

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.

\<% for column in User.content\_columns %\>

**\<%= column.human\_name %\>:** \<%=h @user.send(column.name) %\>

\<% end %\>

---

<div class="post-metadata">

**Author:** ![kopf1988](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/74df32/32.png) [@kopf1988](https://www.ruby-forum.com/u/kopf1988)\
**Post date:** [January 11, 2008, 5:40am UTC](https://www.ruby-forum.com/t/hopefully-an-easy-question-post-scaffolding-add-parameters/125685/6 "2008-01-11T05:40:59Z")

</div>

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.

On Jan 11, 2008 3:01 PM, kopf1988 [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Furthermore, using Rails 1.2.6. 🙂
> 
> >

–  
Ryan B.

> **[frozenplague.net](http://www.frozenplague.net)**
>
> This domain may be for sale!

Feel free to add me to MSN and/or GTalk as this email.

---

<div class="post-metadata">

**Author:** ![kopf1988](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/74df32/32.png) [@kopf1988](https://www.ruby-forum.com/u/kopf1988)\
**Post date:** [January 11, 2008, 10:42am UTC](https://www.ruby-forum.com/t/hopefully-an-easy-question-post-scaffolding-add-parameters/125685/7 "2008-01-11T10:42:27Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![kopf1988](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/74df32/32.png) [@kopf1988](https://www.ruby-forum.com/u/kopf1988)\
**Post date:** [January 11, 2008, 11:23am UTC](https://www.ruby-forum.com/t/hopefully-an-easy-question-post-scaffolding-add-parameters/125685/8 "2008-01-11T11:23:00Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![kopf1988](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/74df32/32.png) [@kopf1988](https://www.ruby-forum.com/u/kopf1988)\
**Post date:** [January 11, 2008, 6:00pm UTC](https://www.ruby-forum.com/t/hopefully-an-easy-question-post-scaffolding-add-parameters/125685/9 "2008-01-11T18:00:33Z")

</div>

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](http://wiki.rubyonrails.com/rails/pages/Scaffolding+Extensions+Plugin)

Jeremy
