Forum: Ruby on Rails Multiple Check Box

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
77b62b33c21ad22b897eebbb6c24fe46?d=identicon&s=25 Naveen Naveen (psnavaneethan)
on 2009-04-17 06:20
I had given like

Java<%=check_box_tag "employees", "skills[]",  "Java" %>
Rails<%=check_box_tag "employees", "skills[]",  "Rails" %>
C<%=check_box_tag "employees", "skills[]",  "C" %>

since it belongs to the "employee" object. So both the checkboxes (Java
and Rails) are selected in the "new" page.


In the controller, I had given

@employees = Employees.new(@params['employees'])
@employees.save

Also in the DB, I am having a table called as "employees" and in that
"skills" is a column.

Is it possible in DB to have a single column "skills" for multiple
checkboxes
(Java, Rails and C)

Could you please suggest what needs to be done.
81b61875e41eaa58887543635d556fca?d=identicon&s=25 Frederick Cheung (Guest)
on 2009-04-17 10:04
(Received via mailing list)
On Apr 17, 5:20 am, Naveen Naveen <rails-mailing-l...@andreas-s.net>
wrote:
>
> @employees = Employees.new(@params['employees'])
> @employees.save
>
> Also in the DB, I am having a table called as "employees" and in that
> "skills" is a column.
>
> Is it possible in DB to have a single column "skills" for multiple
> checkboxes
> (Java, Rails and C)
>
Well ActiveRecord will serialize stuff into a single column (see the
serialize method), but typically the way you would do this would be to
have a skills table and then a has many through between employees and
skills.

Fred
This topic is locked and can not be replied to.