维斯塔版本 -
我在这里使用 Vestal Version Fork 来支持 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 正在数据库中为用户字段插入 NULL,我需要填充的是 user_id
想法?
谢谢
I'm using the Vestal Version Fork here for Rails 3 support: http://github.com/adamcooper/vestal_versions/
The issue I'm having is that the updated_by => current_user is not storing in the versions table on update.
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
I checked the logs, there is no error, Rails is INSERTING NULLs in the DB for the user fields, the one I need to populate is user_id
Ideas?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将以下内容添加到您的模型类中应该可以使其工作
Add the following to your model class should make it work