# Newbie, reciving a hash from the view

**URL:** <https://www.ruby-forum.com/t/newbie-reciving-a-hash-from-the-view/191814>\
**Category:** Rails\
**Created:** [July 19, 2010, 10:14am UTC](https://www.ruby-forum.com/t/newbie-reciving-a-hash-from-the-view/191814 "2010-07-19T10:14:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![maese](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e56c9b/32.png) [@maese](https://www.ruby-forum.com/u/maese)\
**Post date:** [July 19, 2010, 10:14am UTC](https://www.ruby-forum.com/t/newbie-reciving-a-hash-from-the-view/191814/1 "2010-07-19T10:14:20Z")

</div>

hi, i am new in ruby, i have to do the next

Send a hash (key are strings and values are booleans) to the view, show  
it like check box in the view, using string like nome and the value like  
check or not checked, and recover this hash modified to the controller  
for work with it  
so i wrote this

in the view

\<removed\_email\_address@domain.invalid do |key, value| %\>  
\<%=key.to\_s%\> \<%=check\_box(key, value, {}, true, false) %\>  
\<%end%\>

in the controller

before\_filter loadArchitectures #here load @architectures  
def create  
if request.post?  
begin  
@architectures.each do |key, value|  
if value  
newArchitecture=Architecture.new()  
newArchitecture.nombre=clave  
newArchitecture.project\_id=@project.id  
newArchitecture.save

```
        end
      end

```

But when i see the values of @architectures after request.post? they are  
the originals values.  
Some help please (and sorry for my english)

---

<div class="post-metadata">

**Author:** ![maese](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e56c9b/32.png) [@maese](https://www.ruby-forum.com/u/maese)\
**Post date:** [July 19, 2010, 12:07pm UTC](https://www.ruby-forum.com/t/newbie-reciving-a-hash-from-the-view/191814/2 "2010-07-19T12:07:29Z")

</div>

On Jul 19, 9:14 am, Ignacio T. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> But when i see the values of @architectures after request.post? they are  
> the originals values.  
> Some help please (and sorry for my english)

It doesn’t look like you are changing the objects in @architectures at  
all (or indeed using the values at all (apart from controlling how  
many new architectures you create)  
Also you appear to be misusing check\_box slightly - the intent is that  
the first argument is the name of an instance variable and the second  
the name of a boolean attribute.

Fred

---

<div class="post-metadata">

**Author:** ![maese](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e56c9b/32.png) [@maese](https://www.ruby-forum.com/u/maese)\
**Post date:** [July 19, 2010, 1:01pm UTC](https://www.ruby-forum.com/t/newbie-reciving-a-hash-from-the-view/191814/3 "2010-07-19T13:01:20Z")

</div>

i use the hash @architectures, just for create news Architectures,  
because the names of the architectures can change dinamically, so with  
the hash i collect the possibles names and, in the view, if the user  
check it, i create the new architecture, or if the user unchecked i  
delete it (but this part is not show in the post)

could you suggest me some code please?  
Thanks a lot
