How to add a new link in Active scaffold rails 3

风格不统一 提交于 2019-12-10 21:18:22

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/9801519/how-to-add-a-new-link-in-active-scaffold-rails-3

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!