I've noticed, that "index" action of my controller is called twice.
The action has following structure:
def index
if params[:tags].nil?
# [fork #1] just return the whole collection of model
@items = Item.all
else
# [fork #2] filter items by tags
@items = Item.select_by_tags params[:tags]
end
# Another operations with @items
# The result will be incorrect, because, when tags in params are specified,
# controller action will be first executed for fork #2, and then for fork #1.
# In view, i get @items from fork #2 and result of THIS piece of code for fork #1
end
On the page i have links with URLs, like "/items?tags=tag1, tag2", clicking on them i get "index" action, called twice
I have no idea, why this happens ...