I am trying to implement a basic upload form in my rails app using Carrierwave. I have a model called image with an uploader called image_path and am getting the error:
undefined method `images_path' for #<#<Class:0x0000010369ea20>:0x00000103765288>
I'm not sure why it thinks it should be finding "images_path" instead of "image_path" - I searched for "images_path" in my app and found nothing.
This is what everything currently looks like:
html.erb:
<%= form_for Image.new do |f| %>
<%= f.error_messages %>
<%= f.hidden_field :spin_id %>
<p>
<%= f.file_field :image_path, multiple: true %>
<%= f.submit %>
</p>
<% end %>
image.rb
class Image < ActiveRecord::Base
belongs_to :spin
mount_uploader :image_path, ImagePathUploader
end
image_path_uploader.rb
class ImagePathUploader < CarrierWave::Uploader::Base
storage :file
def store_dir
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
end
Would really appreciate any help as I am completely stumped.
Here is the full error:
ActionView::Template::Error (undefined method `images_path' for #<#<Class:0x00000104f36da8>:0x000001037e4ec0>):
40:
41: </div>
42: <%# add file input stuff here %>
43: <%= form_for Image.new, :html => {:multipart => true} do |f| %>
44: <%= f.error_messages %>
45: <%= f.hidden_field :spin_id %>
46: <p>
app/views/home/index.html.erb:43:in `block (2 levels) in _app_views_home_index_html_erb__3305799271767470298_2188818660'
app/views/home/index.html.erb:30:in `block in _app_views_home_index_html_erb__3305799271767470298_2188818660'
app/views/home/index.html.erb:26:in `_app_views_home_index_html_erb__3305799271767470298_2188818660'
Rendered /Users/[]/.rvm/gems/ruby-2.1.1/gems/actionpack-4.1.6/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb (1.2ms)
Rendered /Users/[]/.rvm/gems/ruby-2.1.1/gems/actionpack-4.1.6/lib/action_dispatch/middleware/templates/rescues/_request_and_response.html.erb (0.9ms)
Rendered /Users/[]/.rvm/gems/ruby-2.1.1/gems/actionpack-4.1.6/lib/action_dispatch/middleware/templates/rescues/template_error.html.erb within rescues/layout (11.1ms)
image_filefor example and try to reproduce error again. - Maxim