Tag: 自动保存

has_one belongs_to association autosave => true不保存

我有两个型号 Board has_one :pref, :autosave => true, :dependent => :destroy Pref belongs_to :board pref对象具有在数据库中设置的默认值,因此在创建板时不需要使用信息来创建对象。 电路板的ID在pref表中。 由于:autosave => true,我认为当我创建并保存新的Board对象时,将自动创建并保存pref对象。 这不是这样的,所以我一定是误会。 有没有办法在保存电路板时自动保存pref对象? 先感谢您

什么是保存草稿post的RESTful方式?

我在一个小型测试网站上有一个post控制器。 我希望在网站上有一个“保存草稿”/组合自动保存function,因为该网站会有很长的post,用户可能想要离开并返回完成。 但是,我从未在(或任何应用程序)之前将自动保存/保存function构建到Rails应用程序中。 什么是好的,RESTful方式呢? 这是我当前的控制器操作: posts_controller.rb def create @post = params[:post] if @post.save flash.now[:success] = “Post created!” else render_errors_now(@post) end respond_to do |format| format.html {redirect_to Discussion.find(session[:discussion_id])} format.js end end 如您所见,用户远程发布。 这是当前的post.rb模型: attr_accessible :content, :title validates :title, :presence => true validate :title_character_length validates :content, :length => { :maximum => 10000 } validates :user_id, :presence => true […]