i use acts-as-taggable-on for tagging.
apartments_controller
def index
if params[:tag]
@apartments = Apartment.tagged_with(params[:tag])
else
@apartments = Apartment.all
end
end
routes
resources :apartments do
#...
collection do
get ':tag', to: 'apartments#index', as: :tag
end
#...
I get nice urls by example /apartments/tag1
etc.
I want to show custom content based on the tag name in the apartments index
template.
Apartment
's index
view:
- @appartments.each do |tags|
- case tags.tag_list
- when "tag1"
%p tag1 content
- when "tag2"
%p tag2 content
- else
%p default content
When i go to url apartments/tag1
the text "default content"
is show and not "tag1 content"
.
What am I doing wrong?