显示上次修改的表/记录 Rails 3.2 [英] Show Last modified tables/records Rails 3.2

查看:27
本文介绍了显示上次修改的表/记录 Rails 3.2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我仍然不知道如何实现这一点,因为我是一个新手.有些人帮助我并说我必须使用审计,所以确实如此.这是我的控制器:

I still can't figure out how to implement this as i am a newbie with this. some people helpt me and said i had to use audited, so it did. this is my controller:

  def show

    add_breadcrumb 'Contract Bekijken', :contracten_path

    @contracten = Contracten.find(params[:id])

    @audits = @contracten.audits.collect { |a| a.created_at }

    respond_to do |format|
      format.html # show.html.erb
      format.json { render json: @contracten }
    end
  end

这是我的整个控制器的馅饼.http://pastie.org/4270702

Here's a pastie of my whole controller. http://pastie.org/4270702

但我不知道这是否正确,或者如何将其落实到我的观点中.

But i don't know if this is right or how to implement this to my views.

我希望有人真的可以提供帮助,因为我这周真的需要它来工作.

I hope someone really can help because i really need this to work this week.

谢谢.

我有一个 rails 应用程序,我可以在其中将合同存储在数据库中,它还在数据库中包含人员和工厂表.现在我想要一个最后修改的表.

i have a rails app where i can store contracts in a database, it also has persons and factories tables in the database. Now i would like to have a last modified table.

我希望当人们更新/添加新记录到数据库时,它会在屏幕截图的 div 中显示修改.

I would like when people update/add a new record to the database, that it will show the modifications in the div right on the screenshot.

谢谢:D

推荐答案

从您的问题来看,您似乎只需要一个基于 updated_at 字段的列表.

From your question it seems like you just need a list based on the updated_at field.

怎么样 - @contract_list = Contract.all.order( "updated_at DESC").limit(10)

然后你可以遍历视图中的列表.

Then you can iterate over the list in the view.

漂亮的页面!

这篇关于显示上次修改的表/记录 Rails 3.2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆