0

我在这里使用 Vestal 版本叉来支持 Rails 3:http: //github.com/adamcooper/vestal_versions/

我遇到的问题是 updated_by => current_user 在更新时没有存储在版本表中。

def update 
        @book = Book.find(params[:id]) 
  respond_to do |format| 
    if @book.update_attributes(params[:book].merge(:updated_by => current_user)) 
      format.html { redirect_to(@book, :notice => 'Book was 
successfully updated.') } 
      format.xml  { head :ok } 
    else 
      format.html { render :action => "edit" } 
      format.xml  { render :xml => @book.errors, :status => :unprocessable_entity } 
    end 
  end 
end 

我检查了日志,没有错误,Rails 在数据库中为用户字段插入空值,我需要填充的是 user_id

想法?

谢谢

4

1 回答 1

1

将以下内容添加到您的模型类中应该可以正常工作

attr_accessible  :updated_by
于 2011-08-31T11:49:43.253 回答