I get an error when trying to upload a file using carrierwave:
ActionController::InvalidAuthenticityToken in AssetsController#create
Steps:
1. rails new testapp
2. Add devise and carrierwave to Gemfile
3. rails g devise:install
4. rails g scaffold asset path:string #will mount uploader to path
5. rails g uploader asset
6. rake db:migrate
7. Edit model/asset.rb add mount_uploader :path, AssetUploader
8. modify asset form to use multipart and file_field for :path
So with that basic setup if I go to assets/new I will see the new asset form, use the file field to select an image for uploading and when I save I get the error above. I never created a devise user model and never added any before_filter authenticate_user! to the controllers.
It doesn't redirect me to a login page but it throws the error. So I tried creating a devise model with 'user' and registered and logged in and I can now use the asset form to upload even though I never set 'before_filter authenticate_user!'. If I log out and try to upload again I get the same error.
So with that information is there any reason why devise would automatically prevent me from using an upload form in my app?
<%= form_for(@asset, :html => { :multipart => true}) do |f| %>
<% if @asset.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@asset.errors.count, "error") %> prohibited this asset from being saved:</h2>
<ul>
<% @asset.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>
<div class="field">
<%= f.label :path %><br>
<%= f.file_field :path, :multiple => true %>
</div>
<div class="actions">
<%= f.submit %>
</div>
<% end %>