如何在活动脚手架轨道中添加新链接3 [英] How to add a new link in Active scaffold rails 3
本文介绍了如何在活动脚手架轨道中添加新链接3的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要在我的出租车列表页面中添加一个新的链接地图,我使用的是主动脚手架和Rails 3.2.1。
我目前的页面如下所示。我需要显示一个链接地图,类似于每条记录中的编辑/删除/显示。在我的数据库中,我有字段名称,lat,lng。
I need to add a new link 'map' in my Taxis listing page, I am using active-scaffold and 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.
这怎么能做到。请帮助。
How can this be done. Please help.
推荐答案
您必须将您的链接添加到您的控制器中的配置部分。
You have to add your link in the configure part in your controller.
我是这样做的:
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.
这篇关于如何在活动脚手架轨道中添加新链接3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文