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?