In general, a many-to-many relationship involves three tables. Can you
describe how you've done this relationship with Rails? Did you use a
has_and_belongs_to_many with a categories_stories table? Or did you
use a has_many :through association with a different through table?



On Wed, Mar 11, 2009 at 6:06 PM, Inderpal Bhogal
<[email protected]> wrote:
>
> Hi
>
> I have two tables Stores and Categories
>
> Relationship of these tables are: Many to Many
> Store can have many categories
> Category can also have many stores
>
> Now in the stores table I have a store_name and category_id attributes
> that links the category table to the store table via its Category_ID
> attribute.
>
> The Category table only has category_id and category_description
> attributes.
>
> I want to be able to perform a search on Categories index.html.erb page
> to find stores which fall into that particular category.
>
> Therefore I need the search function to look into the stores table and
> match the category_id to the category_id in categories table, and return
> the store names with those categories.
>
> I have tried some example but they don’t seem to be working. Can someone
> please help!!!!
> --
> Posted via http://www.ruby-forum.com/.
>
> >
>

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