相关疑难解决方法(0)

Rails 3 - 设置页面标题的理想方式

什么是在rails 3中设置页面标题的正确方法.目前我正在做以下事情:

应用程序/视图/布局/ application.html:

<head>
  <title><%= render_title %></title>
  <%= csrf_meta_tag %>
Run Code Online (Sandbox Code Playgroud)

应用程序/佣工/ application_helper.rb:

def render_title
  return @title if defined?(@title)
  "Generic Page Title"
end
Run Code Online (Sandbox Code Playgroud)

应用程序/控制器/ some_controller.rb:

def show
  @title = "some custom page title"
end
Run Code Online (Sandbox Code Playgroud)

有没有其他/更好的方法来做上述事情?

ruby-on-rails-3

71
推荐指数
3
解决办法
4万
查看次数

在Rails中生成slugs(人类可读ID)的最佳方法

你知道,比如myblog.com/posts/donald-e-knuth.

我应该使用内置parameterize方法吗?

插件怎么样?我可以想象一个插件很适合处理重复的slug等.这里有一些流行的Github插件 - 有没有人对它们有任何经验?

  1. http://github.com/rsl/stringex/tree/master
  2. http://github.com/norman/friendly_id/tree/master

基本上看起来slu is是一个完全解决的问题,我不会重新发明轮子.

ruby-on-rails slug

61
推荐指数
7
解决办法
5万
查看次数

标签 统计

ruby-on-rails ×1

ruby-on-rails-3 ×1

slug ×1