P
P
Pavel Grudinkin2016-07-25 04:05:32
Ruby on Rails
Pavel Grudinkin, 2016-07-25 04:05:32

Why is the Meta tag not updated when following links to pages of the same controller?

The situation is as follows:
1) I define a variable in the controller @info = Info.find_by slug: params[:id]
2) I define two methods in the helper:

def title_for_info
    if @info.present?
      @info.title
    else
      "Текст"
    end
  end

  def description_for_info
    # @info = Info.find_by slug: params[:id]
    if @info.present?
      @info.description
    else
      "Текст"
    end
  end

3) In the appropriate layout I prescribe:
%meta{:content => "#{description_for_info}",:name => "description"}/
%title= title_for_info

There is a page with a list of links, when you click on any one, the following happens: the title is always loaded correctly, but the description always goes along the branch to "Text". If you copy the link on this original page and open it in a new tab (or stupidly refresh the page), then the description is loaded correctly. Everything also works correctly if it is stupid to output before the meta tag. = @info.description
Why is this behavior observed and what to do about it?
Update
In general, these are the features of Turbolinks , while I'm thinking how to do without gems.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Pavel Grudinkin, 2016-07-25
@Hunt666

In my case, it helped to add to the links on the home page:target => '_self'

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question