Answer the question
In order to leave comments, you need to log in
How to make a redirect from a 3rd level domain to a 2nd one when selecting a tag?
I use gem 'acts-as-taggable-on' for tags.
On the main page, the tags have the address simple.com/tag/:tag, as I understand it, /tag/:tag is substituted for the root of the site.
When I go to the record of the selected tag, I get to the 3rd level domain test.simple.com.
On the same page, I try to select another tag, but it is already substituted with the address test.simple.com/tag/:tag, respectively, to the root of the site.
How can I make the tag address simple.com/tag/:tag when selecting a tag on the 3rd level domain?
View - display tags
- tag_cloud Model.tags.tag_counts, %w[css] do |tag, css_class|
= active_link_to tag.name, tag_path(tag.name), class: css_class, active: :exclusive
get 'tag/:tag', to: 'home#index', as: :tag
Answer the question
In order to leave comments, you need to log in
I did this, but something tells me that there are better ways
unless request.subdomain.blank?
tag_path_url = tag_path.gsub!('/tag', 'tag') - здесь потому что при редиректе он добавляет два слеша перед 'tag'
root = root_url(subdomain: false) + tag_path_url
redirect_to root
end
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question