# Creating & Validating w/ has\_many :through

**URL:** <https://www.ruby-forum.com/t/creating-validating-w-has-many-through/166586>\
**Category:** Rails\
**Created:** [April 27, 2009, 4:58pm UTC](https://www.ruby-forum.com/t/creating-validating-w-has-many-through/166586 "2009-04-27T16:58:17Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![snowbird122](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c68b51/32.png) [@snowbird122](https://www.ruby-forum.com/u/snowbird122)\
**Post date:** [April 27, 2009, 4:58pm UTC](https://www.ruby-forum.com/t/creating-validating-w-has-many-through/166586/1 "2009-04-27T16:58:17Z")

</div>

I don’t have a full grasp on has\_many :through associations. I’ve  
detailed my models below and am trying to figure out how to do the  
following in the proper manner.

1. Add the selected software (only one selectable) to the current  
ticket. I have @ticket.software \<\< @software working just fine.
2. Validate that A) 1 or more systems have been selected, B) A  
:software\_status has been selected. I’m not sure where these  
validations should go.
3. Create the software to system association (w/ sofware\_status value)  
through the join model
4. How to setup the new/edit form to manage all of this.

Thanks in advance.

Ticket.rb

has\_and\_belongs\_to\_many :software

Software.rb

has\_many :system\_software  
has\_many :systems, :through =\> :system\_software

System.rb

has\_many :system\_software  
has\_many :software, :through =\> :system\_software

SystemSoftware.rb

belongs\_to :system  
belongs\_to :software  
belongs\_to :software\_status

SoftwareStatus.rb

has\_many :system\_software
