If you are using rails 2.1 then you can use a named scope on the Item
model like such
== in Item
belongs_to :category
named_scope :same_category, :include => :category, :conditions =>
{ ''category.name'' => category.name }
then you can do
== IteamsController (i suppose)
def edit
@iteams = Item.same_category
@item = ...
end
and it will do the find for you.
have a look at: http://railscasts.com/episodes/108
On Jul 10, 10:16 am, Seb <ebs...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> i have 2 models items and categories..in items listing i have category
> name,title...etc..
> In item edit page i want to display the title of all item having the
> same category name.means when clicking on edit field of one item it
> should show edit details and the title of the items which have the
> same catoegory name.how can i do this ...so i think have to use some
> find method or something..then where should i write the code? in item
> controller ?then how can i call it from my listing items ?somebody
> help me pls.........
--~--~---------~--~----~------------~-------~--~----~
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
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---