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.k
Mobile - +91-9894991640

Karthik Kantharaj wrote:
#> how can i access the contract_id which is in another table

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

On Sat, Aug 8, 2009 at 1:47 PM, James W.
<[email protected]

wrote:

Karthik Kantharaj wrote:
#> how can i access the contract_id which is in another table

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

hi James W.

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