简体   繁体   中英

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. 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.

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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