所以我已经设置了best_in_place gem [https://github.com/bernat/best_in_place]但是当我尝试编辑的专栏看起来像title_name
并且发生错误时它显示它时我遇到了一个小问题
'title_name can't be blank,is too short (minimum is 1 characters)'
我想编辑 gem 处理错误显示的方式,以便它将_
替换space
为user-friendly
编辑:
检查我通过Firebug得到的响应是:
{"title_name":["can't be blank","is too short (minimum is 1 characters)"]}
在 gem 演示中 http://bipapp.heroku.com/users/59
["Last name has invalid length","Last name can't be blank"]
这有点不同......
编辑2:
post.rb
class Post < ActiveRecord::Base
attr_accessible :post_id, :title_name, :total_items, :user_id
validates :title_name, :presence => true, :length => { :in => 1..50 }
belongs_to :user, :foreign_key => 'post_id'
self.primary_key = :post_id
def to_param
"#{post_id}"
end
end