gregbell/active_admin — Issue #740: Custom action breaks authorisation
Author: micapam
Created: 2011-11-11 07:23:49+00:00
State: open

Hi there.

For my application I need to upload a file for mass-import some data, so I've created a custom action called "upload_pins" on my resource "product". I do it with the following (for the sake of simplicity I've removed all the working code) -

```ruby
actions :show, :index, :edit, :new, :upload_pins

member_action :upload_pins, :method => :post do
puts "YES I AM HERE!!!!"
redirect_to "/admin"
end
```

And as part of the show block (probably not the most elegant way to include a small form but you get the idea) ..

```ruby
div do
form :action => upload_pins_admin_product_path(:id => resource.id), :method => 'post',
:enctype => 'multipart/form-data' do
div do
file_field_tag 'pins'
end
input :type => 'submit', :value => 'Upload new PINs'
end
end
```

I never see the "YES" line in the logs. I get bounced straight back to the login screen - as if I haven't logged in. The route is fine, when I do rake routes I see the entry:

upload_pins_admin_product POST /admin/products/:id/upload_pins(.:format) {:action=>"upload_pins", :controller=>"admin/products"}

Any idea what might be happening?