# Catching data in model

**URL:** <https://www.ruby-forum.com/t/catching-data-in-model/112070>\
**Category:** Rails\
**Created:** [August 14, 2007, 11:09pm UTC](https://www.ruby-forum.com/t/catching-data-in-model/112070 "2007-08-14T23:09:09Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [August 14, 2007, 11:09pm UTC](https://www.ruby-forum.com/t/catching-data-in-model/112070/1 "2007-08-14T23:09:09Z")

</div>

Hello everybody,  
I am new to ruby on rails so please don’t laugh on my silly doubts.

Problem :

I am creating check boxes in rhtml file. All the items which are being  
checked, i am able to catch it in the controller class. but i am not  
being able to catch values from controller to model.

supplier.rhtml file  
\<%= check\_box(‘hotel\_’, ‘’, {}, hotel.group\_name+"^"+hotel.pid, ‘’)  
%\>

contoller class

def supplier  
@temp = @params[‘hotel\_’]  
end

I want to catch @temp in the concern model class…how can do that…

thanks a lot in advance  
Czar

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [August 15, 2007, 5:24am UTC](https://www.ruby-forum.com/t/catching-data-in-model/112070/2 "2007-08-15T05:24:32Z")

</div>

You need to instantiate a new class object. Your not referencing your  
class at all, so none of your model methods are available to you  
unless your using an object of that class. So instead try something  
like:(NB not tested code)

In your controller:  
def supplier  
@temp = Hotel.new(params[:hotel\_])  
end

Then within that suppler method you’ll be able to use methods written  
in the Hotel class to manipulate that data, for instance if you have a  
method called say write\_to\_screen in your Hotel class

class Hotel\<ActiveRecord::Base

def self.write\_to\_screen  
puts self.group\_name  
end

end

then you could go  
@temp.write\_to\_screen  
and that would execute the method on that @temp instance variable,  
because @temp is an instance of the object Hotel, and Hotel is an  
instance of the object Class.

Does that help? It’s Object Orientation 101, so it might be worth  
having a good read up on OOP, it’s help to get your head around that  
stuff.

Cam
