On Sep 23, 12:00 pm, PalaniKannan K <[email protected]> wrote:
> Dear all,
>
> I included models, controller and View. Please, find the mistake in it and
> tell me. I need to fetch the data of included tables "city and country"
> using the query of "first name and second name" of table 'name'.

You could start by stating what the problem is rather than leaving
people to guess.

Fred
> *name model*
> has_many :city, :foreign_key => "name_id"
> has_many :country, :foreign_key => "name_id"
> *
> city model*
> belongs_to :name
>
> *country model*
> belongs_to :name
>
> *In Name Controller*
> @names = Name.find(:all, :conditions=>{:first_name => params[:gm],
> :second_name => params[:sp]}, :include => [ :city, :country ])
>
> *In Name View*
>
> <% @names.each do |name| %>
> <%= name.age %>
> <% end %>
>
> <% @names.cities.each do |city| %>
> <%= city.local_area %>
> <% end %>
>
> <% @names.countries.each do |country| %>
> <%= country.state %>
> <% end %>
>
> --
> With Regards
> Palani Kannan. K

-- 
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