Doubt retrieving data?

hi

my controller has

def searchwithstatus
@agency=params[:agency][:agency_id]
@contract=params[:agency][:contracts_id]
@agencies=Agency.find(:all,:conditions=>{:deleted=>1,:contract_id=>@contract,:state_id=>@state})
end

when i am executing the code in line 3 it is saying as

__"Mysql::Error: Unknown column 'agencies.contract_id' in 'where clause': SELECT * FROM `agencies`
WHERE (`agencies`.`state_id` = '1' AND `agencies`.`contract_id` = '13' AND `agencies`.`deleted` = 1)__ "
**how can i access the contract_id which is in another table**

please help

Karthik Kantharaj wrote:

#> how can i access the contract_id which is in another table

:contract_id=>"#{@contract.id}"

hi James West

Thank you

@agencies=Agency.find(:all,:
conditions=>{:deleted=>1,:contract_id=>@contract,:state_id=>@state})

but i am not able to access :contract_id because there is no field of contract_id in agencies table

agencies and contracts contains habtm relation

i am passing this from

<% form_remote_tag(:update =>“searchagencies”,:url => {:action => :searchwithstatus}) do%>

Contract <%= collection_select(:agency,:contracts_id,@contracts,:id,:name,{:include_blank =>'All'}) %>
<% end%>        

I need to know how to access the :contract_id
and match with the contract_id in contract table and need to search