项目摘抄

belongs_to :user, :inverse_of => :topics

counter_cache :name => :user, :inverse_of => :topics



受保护属性,不能接受页面参数

attr_protected :user_id

scope :last_actived, desc("replied_at").desc("created_at")



controller:

caches_page :feed, :node_feed, :expires_in => 1.hours




国际化:

初始化:

I18n.default_locale = :en


LANGUAGES = [
['English', 'en'],
["Español".html_safe, 'es']
]


气质过滤器:

def set_i18n_locale_from_params
if params[:locale]
if I18n.available_locales.include?(params[:locale].to_sym)
I18n.locale = params[:locale]
else
flash.now[:notice] =
"#{params[:locale]} translation not available"
logger.error flash.now[:notice]
end
end



自增:(计数器)

@topic.hits.incr(1)

counter :hits, :default => 0



防止crsf攻击:

protect_from_forgery ----controller

<%= csrf_meta_tag %> --layout


发起其他方式提交:标签用

auto_discovery_link_tag(type = :rss, url_options = {}, tag_options = {})


分词插件:RMMSeg::Algorithm


input=text 默认显示字体 设置 :placeholder =>"xianshi"

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值