2010-09-12 70 views
0

我在這裏使用的維斯塔版本叉爲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正在插入空值在DB用戶領域,一個我需要填充是USER_ID

想法?

感謝

+0

我想這不用說,你其實記錄這段代碼運行時? – brad 2010-09-12 18:18:48

+0

好問題:)是的,current_user正在控制器中的其他方法中使用,以達到我可以更新書籍的位置 – AnApprentice 2010-09-12 19:48:51

+0

這方面的進展如何?我正在經歷同樣的行爲。 – 2010-11-26 21:16:20

回答

1

以下內容添加到您的模型類應該使其工作

attr_accessible :updated_by