# Can i pass parameters to has\_one manually?

**URL:** <https://www.ruby-forum.com/t/can-i-pass-parameters-to-has-one-manually/135742>\
**Category:** Rails\
**Created:** [April 24, 2008, 4:02pm UTC](https://www.ruby-forum.com/t/can-i-pass-parameters-to-has-one-manually/135742 "2008-04-24T16:02:01Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jjkiesch](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/bc79bd/32.png) [@jjkiesch](https://www.ruby-forum.com/u/jjkiesch)\
**Post date:** [April 24, 2008, 4:02pm UTC](https://www.ruby-forum.com/t/can-i-pass-parameters-to-has-one-manually/135742/1 "2008-04-24T16:02:01Z")

</div>

i have an internal app being used for tracking internal jobs inside  
the shop. the company has multiple divisions, and transfers jobs back  
and forth between divisions. each division has their own job numbering  
scheme as well.

what i’ve done is set up a jobs table which has many job\_tags, which  
is the table i use to store the job number and other specific info  
relating to that division. so each time i am displaying a job, to also  
get a it’s job\_tag i started out with something like this:

job.job\_tags.find\_by\_division\_id(@division.id).name

to prevent the database getting hit each time on finding multiple  
jobs, i have something like this in the controller:

jobs = Job.find(:all, :include =\> :job\_tags, :conditions =\>  
[‘job\_tags.division\_id = ?’, @division.id])

and in the view i use:

job.job\_tags.first.name

this is proving to not be very flexible and any time i have to change  
the list ever so slightly for another page, i find myself duplicating  
a lot of code. ideally i would like to add something like

has\_one :job\_tag, :condititions =\> [‘job\_tags.division\_id = ?’,  
division.id]

to my Job model and be able to pass the current division to it, or if  
there are better ways to manage this type of thing, i am very open to  
any suggestions.
