You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to save a file with carrierwave but when I try to read the attribute, I get an ActionDispatch::Http:UploadedFile object and can't access the file url.
irb(main):009:0> t.photo.url
NoMethodError: undefined method `url' for "#<ActionDispatch::Http::UploadedFile:0x007f77a09182e0>":String
Ticket.rb
class Ticket < ActiveRecord::Base
mount_uploader :photo, PhotoUploader
end
My action:
def create
@user = User.new(user_params)
if @user.save
puts "Saved the user"
@ticket = Ticket.new(ticket_parameters)
image_data = params[:photo]
@ticket.photo = image_data
I guess something is messed up in your code(note that "#<ActionDispatch::Http::UploadedFile:0x007f77a09182e0>":String is string representation of UploadedFile, not an instance of UploadedFile).
If you could show me full model and uploader code, I can look into them.
I'm trying to save a file with carrierwave but when I try to read the attribute, I get an
ActionDispatch::Http:UploadedFile
object and can't access the file url.Ticket.rb
My action:
And my upload:
The text was updated successfully, but these errors were encountered: