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

查看:91
本文介绍了显示最近修改的表/记录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天全站免登陆