0

in my active admin app i have 2 models, per example: Vehicle and Front.(Front has many Vehicles)

In the :show view of an Front, it lists all the vehicles that belong to it. And for each Vehicle it lists, it have a link "Remove" that removes the corresponding Vehicle from that Front. Here's what my code looks like:

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

And the Remove method from Vehicle:

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

But when I click on the Remove link, theres an error: Its not sending the id from the vehicle. How can I send the id from the Vehicle?

4

1 回答 1

0

使用删除方法和销毁动作,这是正确的方法。
所以..
尝试使用

vehicle.column {link_to "Remove" , remove_admin_vehicle_path(vehicle), :method => :post}

并显示rake routes结果。

于 2012-08-15T22:42:05.217 回答