要是不喜欢 bootstrap,可以看看 semantic ui,或者直接 muicss。给我女朋友用的话,只要不难看就好了吧,有功能就很好了。
对 Redis 没有深入了解过,以前做一个文章阅读应用,我们把文章的内容放到了 Redis 里。所以可以理解为,会被经常访问到,但又不经常变化,每次查数据库开销又比较大的数据可以放到 Redis 中。Redis 应该还有其他很多用法,下面肯定还会有人补充。
那为什么不在 Model 里直接加一个 validate?
目前在 Rails 4.2.4 中我使用的方法,以防有人看到
# 在Rails初始化时加入
ActiveSupport::NumberHelper::NumberToHumanConverter::DECIMAL_UNITS[4] = :wan # 万
ActiveSupport::NumberHelper::NumberToHumanConverter::DECIMAL_UNITS[8] = :yi # 亿
ActiveSupport::NumberHelper::NumberToHumanConverter::INVERTED_DECIMAL_UNITS = ActiveSupport::NumberHelper::NumberToHumanConverter::DECIMAL_UNITS.invert
在 config/locales/zh.yml 文件中加入翻译
zh:
number:
human:
decimal_units:
units:
unit: ""
thousand: "千"
wan: "万"
million: "百万"
yi: "亿"
billion: "十亿"
trillion: "万亿"
quadrillion: "千万亿"
然后调用
number_to_human(10000, locale: :zh)
# "1 万"
number_to_human(100000000, locale: :zh)
# 1 亿
谢谢,赞
#6 楼 @hooooopo 不奇怪,主要时因为看到了下面这个方法,以为是可以兼容的,但没有找到使用方式。感谢回复
# The internals of this method changed between Rails 3.x and 4.0. This method provides the glue
# to ensure that cache entries created under the old version still work with the new class definition.
def convert_version_4beta1_entry!
if defined?(@v)
@value = @v
remove_instance_variable(:@v)
end
if defined?(@c)
@compressed = @c
remove_instance_variable(:@c)
end
if defined?(@x) && @x
@created_at ||= Time.now.to_f
@expires_in = @x - @created_at
remove_instance_variable(:@x)
end
end