this is my house model
has_many :taggings
has_many :tags, through: :taggings
def self.tagged_with(name)
Tag.find_by_name!(name).houses
end
end
this is my house controller
def index
if params[:tag]
@houses = House.tagged_with(params[:tag])
end
end
view:
- @houses.each do |house|
ect
This works fine...this filters out the houses with the current tag, like this /house/tag/tagname
But i implemented a nested resources so i need to change my view to this.
- @regions.each do |region|
- region.houses.find_all do |house|
How can i use the filter tag in the new view? I thought this
- @regions.each do |region|
- region.houses.find_tagged_with(params[:tags]) do |house|
but this wil not work...please help.