# Display options from HABTM

**URL:** <https://www.ruby-forum.com/t/display-options-from-habtm/63635>\
**Category:** Rails\
**Created:** [January 21, 2006, 4:26am UTC](https://www.ruby-forum.com/t/display-options-from-habtm/63635 "2006-01-21T04:26:14Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![prot](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a88e57/32.png) [@prot](https://www.ruby-forum.com/u/prot)\
**Post date:** [January 21, 2006, 4:26am UTC](https://www.ruby-forum.com/t/display-options-from-habtm/63635/1 "2006-01-21T04:26:14Z")

</div>

I have a large certifications table that I would like to have a little  
more controll over, it is part of a HABTM relationship.

* * *

db’s (simplified)

> certifications  
> id  
> course

> employees  
> id  
> department\_id  
> type\_id  
> name

> departments  
> id  
> name

> types  
> id  
> kind

> certifications\_employees  
> certification\_id  
> employee\_id

* * *

Models

class Employee \< ActiveRecord::Base  
belongs\_to :type  
belongs\_to :department  
has\_and\_belongs\_to\_many :certifications  
end

class Department \< ActiveRecord::Base  
has\_many :employees  
end

class Type \< ActiveRecord::Base  
has\_many :employees  
end

* * *

## Using the following code in my employees view \_form.rhtml produces output from my certifications table, it works. The problem is, its a large table and this will potetially produce hundreds of checkboxes.

# Certification

\<% for certification in @certifications %\> checked="checked"\<% end %\> \>\<%=certification.course%\>   
\<% end %\> ----------------------------------------------------

I think I really have two questions.

Is there a way, by way of a the employees\_helper.rb to format the result  
of \<%=certification.course%\> may be into 3 or 4 columns ?

And

How could I display just the records I wanted from the table ? For  
example, I tried the following, which produced this erorr - undefined  
method `apparatus\_pump\_testing’

\<% for certification in @certifications %\>  
  
\<%=certification.apparatus\_pump\_testing%\>  
\<% end %\>

Kindest regards and many thanks.
