Search code examples
ruby-on-railsgeneratorruby-on-rails-5favicon

Rails 5.0.3 Real Favicon Generator produces local host error: ActionView::MissingTemplate in Websites#index


I am fairly new to Rails using realfavicongenerator.net to produce favicons for my Rails 5.0.3 application on my Windows machine. realfavicongenerator.net seems like the way to go - producing many favicons instead of the one-at-a-time approach.

I appear to have generated the favicons correctly: My project folder shows a "Your generated favicon_files" folder at the same level as the "app" folder. It also shows a "Your generated favicons.html" file.

I had originally placed the favicon.json file under the project folder/config, but changed it to app/assets/config/favicon.json after I realized my mistake. (realfavicongenerator.net doesn't specify which config folder to use.)

Now I am getting an error:

localhost:3000: "ActionView::MissingTemplate in Websites#index." 

The error on my rails server:

>ActionView::Template::Error (Missing partial application/_favicon with >>>{:locale=>[:en], :formats=>[:html], :variants=>[], :handlers=>[:raw, :erb, :html, :builder, :ruby, :coffee, :jbuilder]}. Searched in:
  * "C:/Sites/railsbridge/metasara/app/views"
):
    4:     <title>MetaSara</title>
    5:     <%= csrf_meta_tags %>
    6:
    7:     <%= render 'application/favicon' %>
    8:     <%= stylesheet_link_tag    'application', media: 'all', 'data-turbolinks-track': 'reload' %>
    9:     <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
   10:   </head>

Note that I have attempted to place underscores in front of several files to designate them as partials. I have not found a working combination.


Solution

  • By convention, when talking about a Rails application, config, app, etc... refer to the root of your project. So if you are working in /home/me/my_super_rails_app, the config directory is actually /home/me/my_super_rails_app/config, while app/assets actually means /home/me/my_super_rails_app/app/assets.

    favicon.json should be in config (not in app/assets/config).

    The favicon partial should be in app/views/application. In other words, app/views/application/_favicon.html.erb should exists.