0
在我的活性管理应用我有2种模式,以将链接添加到在节目画面另一个控制器的方法,按照实施例:车辆和前(前有许多车辆)想要使用主动管理
在。:显示Front的视图,它列出属于它的所有车辆。对于它列出的每辆车,它都有一个“删除”的链接,将相应的车辆从该前线移除。下面是我的代码如下所示:
ActiveAdmin.register Front do
show do
panel "Vehicles in this Front" do
table_for(front.vehicles) do |vehicle|
vehicle.column("id") {|vehicle| auto_link frente.vehicles}
vehicle.column("category") {|vehicle| vehicle.descricao}
vehicle.column("status") {|vehicle| vehicle.status}
vehicle.column {link_to "Remove" , remove_admin_vehicle_path(vehicle.id), :method => :post}
end
end
而且从车辆删除方法:
member_action :remove , :method => :post do
vehicle = Vehicle.find(params[:id])
vehicle.front = null
vehicle.save!
flash[:notice] = "vehicle removed"
redirect_to :action => :show
end
但是当我点击删除链接上,那里有一个错误:它不是从车辆发送的ID。我怎样才能从车辆发送ID?
我试过这种方式,但它仍然发送Front ID而不是车辆ID ...路线是:/ admin/vehicle/id/remove POST 我认为问题出现在路线中,但我不知道如何解决它。 – 2012-08-17 16:30:58
hm,尝试为您的方法的1行使用'render text:params.inspect'。你会看到你的身份证号码,以及你如何接受它。 – achempion 2012-08-17 23:27:59