简体   繁体   English

如何在Active scaffold rails 3中添加新链接

[英]How to add a new link in Active scaffold rails 3

I need to add a new link 'map' in my Taxis listing page, I am using active-scaffold and Rails 3.2.1. 我需要在我的出租车列表页面中添加一个新链接'map',我使用的是active-scaffold和Rails 3.2.1。 My current page looks like the below. 我当前的页面如下所示。 I need to show a link 'map' similar to edit/delete/show in each record. 我需要在每条记录中显示类似于编辑/删除/显示的链接“地图”。 In my database I have fields name, lat, lng. 在我的数据库中,我有字段名称,lat,lng。

在此输入图像描述

How can this be done. 如何才能做到这一点。 Please help. 请帮忙。

You have to add your link in the configure part in your controller. 您必须在控制器的配置部分中添加链接。

I did it like this: 我是这样做的:

controller Admin::TaxisController < Admin::ApplicationController
  active_scaffold :taxi do |config|
    config.action_links << ActiveScaffold::DataStructures::ActionLink.new('map', :label => I18n.t('map'), :type => :member, :inline => false, :position => true)
  end
end

Of course you'll need to define this method in your controller as well. 当然,您还需要在控制器中定义此方法。

def map
  # do something here
end

You can read more about it here . 你可以在这里阅读更多相关信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM