Jacob_Anandam Jacob_Anandam - 3 months ago 25
MySQL Question

NoMethodError in StaticPages#home

I get the following error. Can someone help me figure this out for me, please?

Showing /home/bdme551/bdme21/app/views/layouts/application.html.erb where line #4 raised:

undefined method `full_title' for #<#<Class:0x000000048c7d60>:0x000000048be210>


Please let me know, if you additional info.

From application.html.erb

<title><%= full_title(yield(:title)) %></title>

Answer

From the information you provided. You have not defined the method full_title you should define the method in helpers/application_helper.rb so the method will be accessible throughout your pages.

application_helper.rb

  def full_title(title)
    default_title = "My Website 2.0"
    if title.empty?
      default_title
    else
      "#{title}"
    end
  end

application.html.erb

<title><%= full_title(yield(:title)) %></title>

To change the title page call provide

<% provide(:title, "Inbox") %>

hope that helps!