StaticPages#home 中的 NoMethodError

NoMethodError in StaticPages#home

我收到以下错误。有人可以帮我解决这个问题吗?

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

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

如果您有更多信息,请告诉我。

来自application.html.erb

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

根据您提供的信息。您尚未定义方法 full_title,您应该在 helpers/application_helper.rb 中定义方法,以便在整个页面中都可以访问该方法。

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>

改扉页调用provide

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

希望对您有所帮助!