先说验证问题。
按照传统的file_column :image, :magick => xxx
无论你想不想验证,file_column 都会验证上传的文件是不是图形文件,如果不是,它会在你的模型错误里面加"invalid image"。该错误验证的地方在 magick_file_column.rb里。查找
if options[:magick][:image_required]
@magick_errors ||= []
@magick_errors << "invalid image"
end
可以将第3行修改为:
@magick_errors & ...
User has_many Categories
Category has_many Posts
当Category和Post同为多态时。这样
class User < ActiveRecord::Base
has_many :categories, :as => :owner #owner_id owner_type
has_many :posts, :through => :categories
end
class Category < ActiveRecord::Base
has_many :posts, :as => :postable #post ...
换成jrails以后,基本的功能都有,但是今天突然想用到in_place_editor,却发现没有这个功能。于是乎,百度伺候,无解- -。那就只有google了。最后发现了rails_in_place_editing这个很小的插件:http://github.com/rakuto/jrails_in_place_editing/tree/master
基本用法和原来的in_place_editor一样。
但是这个先得把文件夹里的javascript下的文件拷到public/javascript下。不知道是不是我的问题,反正不拷过去我没用上。
用来text一切正常。我的应用是要用作select。 ...







评论排行榜