Reputation: 9145
I have a form that contains a file upload field named "application_path". I installed "Paperclip" GEM. But when i simply submit my form without selecting any file then i get error
undefined method `application_path_file_name' for #<ApplicationInstance:0x0000000561bc28>
Here are my request parameters shown in that error page
{"utf8"=>"✓",
"authenticity_token"=>"p3Y0SZT6wIonrrnzughybh8hywnkE1i3uBnxwrU4u9w=",
"application_instance"=>{"device_id"=>"",
"application_version_profile_id"=>""},
"commit"=>"Create Application instance"}
The above parameter does not contain "application_path" with blank value. Here is my Model
class ApplicationInstance < ActiveRecord::Base
attr_accessible :application_version_profile_id, :device_id, :is_deleted, :application_path
# Validations
validates :application_version_profile_id, :presence => true
validates :device_id, :presence => true
validates_attachment_presence :application_path
validates_attachment_size :application_path, :less_than=>1.megabyte
What i am missing here?
Upvotes: 0
Views: 94
Reputation: 29599
You are missing the line that sets up paperclip for ApplicationInstance
. in your application_instance.rb
has_attached_file :application_path, styles: { medium: '300x300>', thumb: '100x100>' }
You may also be missing the required columns for paperclip which you can generate by
rails g paperclip application_instance application_path
Upvotes: 2
Reputation: 2653
Following link may help you
Upload image using paperclip in Rails
Upvotes: 2