# Loop of Properties

**URL:** <https://www.ruby-forum.com/t/loop-of-properties/195458>\
**Category:** Rails\
**Created:** [September 23, 2010, 2:02pm UTC](https://www.ruby-forum.com/t/loop-of-properties/195458 "2010-09-23T14:02:07Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Saulo\_Brust](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/8491ac/32.png) [@Saulo\_Brust](https://www.ruby-forum.com/u/Saulo_Brust)\
**Post date:** [September 23, 2010, 2:02pm UTC](https://www.ruby-forum.com/t/loop-of-properties/195458/1 "2010-09-23T14:02:07Z")

</div>

I’m starting in RoR, sorry if this question seems too basic.

See the code below. The second parameter of the method Rails3AMF:  
IntermediateModel.new must pass ALL properties “field”. How do I  
implement a loop that does this?

Thanks,

Saulo

* * *

class User  
include Mongoid::Document  
include ActiveRecord::Serialization

field :name, :type =\> String  
field :email, :type =\> String  
field :username, :type =\> String  
field :password, :type =\> String

def to\_amf options=nil  
Rails3AMF::IntermediateModel.new(self, {“name” =\> self[:name],  
“email” =\> self[:email], … } )  
end

end

---

<div class="post-metadata">

**Author:** ![Saulo\_Brust](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/8491ac/32.png) [@Saulo\_Brust](https://www.ruby-forum.com/u/Saulo_Brust)\
**Post date:** [September 23, 2010, 4:31pm UTC](https://www.ruby-forum.com/t/loop-of-properties/195458/2 "2010-09-23T16:31:05Z")

</div>

Saulo Brust wrote:

> I’m starting in RoR, sorry if this question seems too basic.
> 
> See the code below. The second parameter of the method Rails3AMF:  
> IntermediateModel.new must pass ALL properties “field”. How do I  
> implement a loop that does this?
> 
> Thanks,
> 
> Saulo
> 
> * * *
> 
> class User  
> include Mongoid::Document  
> include ActiveRecord::Serialization
> 
> field :name, :type =\> String  
> field :email, :type =\> String  
> field :username, :type =\> String  
> field :password, :type =\> String
> 
> def to\_amf options=nil  
> Rails3AMF::IntermediateModel.new(self, {“name” =\> self[:name],  
> “email” =\> self[:email], … } )  
> end

Can’t you just use Rails’ validations for this? Am I missing something?

> end

## Best,

Marnen Laibow-Koser  
[http://www.marnen.org](http://www.marnen.org)  
removed\_email\_address@domain.invalid
