# Populate form with object

**URL:** <https://www.ruby-forum.com/t/populate-form-with-object/231555>\
**Category:** Rails\
**Created:** [August 15, 2014, 9:06am UTC](https://www.ruby-forum.com/t/populate-form-with-object/231555 "2014-08-15T09:06:18Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![addis\_a](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c4cdca/32.png) [@addis\_a](https://www.ruby-forum.com/u/addis_a)\
**Post date:** [August 15, 2014, 9:06am UTC](https://www.ruby-forum.com/t/populate-form-with-object/231555/1 "2014-08-15T09:06:18Z")

</div>

Hey there,

Im going to as what im sure is a newbie question but from all my  
googling and trial an error and i cannot seem to figure out how to do  
this.

Basically im in the process of trying to learn RoR, to do this im  
building a test app that interacts with the Shopify API ( We use shopify  
a lot at my work ).

I have the app set up to pull a product and this is saved as an object (  
That all works fine ):

product = ShopifyAPI::Product.find( {{ product.id }} )

What im wanting to do is populate a form with the data from this object  
e.g. title, description etc so that users of the app can edit products  
from the app, click save and it will update the product within shopify.

The bit im stuck on is actually populating a form the the object data, i  
know how to call save once the changes have been done, i just cant work  
out how to actually populate the form.

Im sure this is dead easy but i just cant seem to work it out

Thanks in advance

---

<div class="post-metadata">

**Author:** ![benhiller](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/8e7dd6/32.png) [@benhiller](https://www.ruby-forum.com/u/benhiller)\
**Post date:** [August 15, 2014, 9:31am UTC](https://www.ruby-forum.com/t/populate-form-with-object/231555/2 "2014-08-15T09:31:55Z")

</div>

On 14 August 2014 21:58, Ben H. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Hey there,
> 
> Im going to as what im sure is a newbie question but from all my googling and  
> trial an error and i cannot seem to figure out how to do this.
> 
> Basically im in the process of trying to learn RoR, to do this im building a  
> test app that interacts with the Shopify API ( We use shopify a lot at my work ).

Start by working right through a good tutorial such as  
[railstutorial.org](http://railstutorial.org) (which is free to use online), that will show you  
the basics of rails, including the answer to your question.

Colin

---

<div class="post-metadata">

**Author:** ![benhiller](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/8e7dd6/32.png) [@benhiller](https://www.ruby-forum.com/u/benhiller)\
**Post date:** [August 18, 2014, 12:41am UTC](https://www.ruby-forum.com/t/populate-form-with-object/231555/3 "2014-08-18T00:41:54Z")

</div>

You basically need to load that product from the database and render the  
edit form. This edit form will have the product instance loaded from the  
database, Rails will automatically render the form and autofill the  
fields  
with values from the product object. Read my free book  
[www.rubyplus.com/rails.pdf](http://www.rubyplus.com/rails.pdf) to learn more. I use a simple blog  
application.  
The concept is the same.
