Search code examples
ruby-on-railsrubyhttp-redirectlink-to

link_to root_url - doesn't load objects on redirect - I have to then refresh


I'm using <%= link_to image_tag("logoi.png"), root_path %> as my main logo and it should reload (if already on homepage) or carry back users to the homepage.

It's currently redirecting to the homepage, however nothing on the homepage loads. I have to then reload the browser for my node objects to display.

routes.rb

authenticated :user do
    root :to => 'dashboard#index', as: :authenticated_root
end

dashboard_controller.rb

def index
    @family_tree = current_user.family_tree
    @nodes = @family_tree.nodes.where(:is_comment => nil)
    @video = Video.new
    @videos = Video.all.where(:is_complete => true)
    @node = Node.new
  end

Solution

  • Its possibly that turbolinks isnt working properly with any jquery being used. Try adding

    gem 'jquery-turbolinks'

    and requiring it with

    //= require jquery.turbolinks

    Not sure if this could be causing issues with node but it was the first thing I thought of after reading the question and the symptoms