我正在尝试跟踪外部链接上的点击次数(不使用"重定向页面").
无论用户是否使用以下内容,如何在用户关注链接时捕获事件:
onClick事件仅适用于第一个事件.
如果设置href="javascript:fireEventAndFollowLink()"用户将无法在新窗口中打开链接(2),那么这不是解决方案.
我正在寻找一种方法来编辑/添加与文章相关的关键字,内联在Activeadmin中.
我已经定义了一个简单的多对多设置:
class Area < ActiveRecord::Base
has_many :area_keywords
has_many :keywords, :through => :area_keywords
accepts_nested_attributes_for :keywords, :reject_if => :all_blank, :allow_destroy => true
end
class AreaKeyword < ActiveRecord::Base
belongs_to :area
belongs_to :keyword
end
class Keyword < ActiveRecord::Base
has_many :area_keywords
has_many :areas, :through => :area_keywords
end
Run Code Online (Sandbox Code Playgroud)
我想在"区域"表单中添加和编辑关键字,因此我在Aciveadmin中设置了这个:
ActiveAdmin.register Area do
form do |f|
f.inputs "Area details" do
f.input :title
f.input :description
end
f.has_many :keywords do |k|
if k.object.nil?
k.input :word, :label => 'Keyword'
else
k.input :word, :label => k.object.word
k.input :_destroy, :as => …Run Code Online (Sandbox Code Playgroud)