Hi Karthik,
Firstly I should say you should be more specific than that, the info is not
very clear.
Secondly I will try to help you based on what I understand of your question.

Say you create a new employee this way :
@employee = Employee.new(params[:employee])

You could do this in the controller create method :
@employee.address = Address.find() #find the address you want.

Now I will also advice you, in the new.html.erb form where your filling the
Employee info, you could have a select drop down with Address data and
depending on what you select, you would then automatically assign the
address.

example:)

*employee_controller.rb*

def new
    @addresses = Address.all
end

*employee/new.html.erb*

<%= f.select :address_id, @addresses.collect {|address| [address.text,
address.id]}

the above will generate the needed select drop down for selecting the
address, the values would be the id whereas the text of the options would be
address.text assuming that text field is the field of address which holds
the address string.

Hope it helps.

Thanks & Regards,
Dhruva Sagar.


Stephen 
Leacock<http://www.brainyquote.com/quotes/authors/s/stephen_leacock.html>
- "I detest life-insurance agents: they always argue that I shall some
day
die, which is not so."

On Tue, Aug 25, 2009 at 4:23 PM, karthik k <[email protected]> wrote:

> Hi Guys
>
> I have a table with
>
> Relationship
>
> has many
> belong to
>
> Employee table
>
> employee id   addressid
> 12                  12
> 13                   13
>
> i need to access addressid data from address table
>
> please guide me
>
>
>
>
>
> --
> Karthik.k
> Mobile - +91-9894991640
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to