我收到以下错误。有人可以帮我解决这个问题吗?
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") %>
希望有帮助!
关于mysql - StaticPages 中的 NoMethodError#home,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39196032/