borjagvo
borjagvo

Reputation: 2071

Cannot access url for ActiveStorage::Attached::One instance when debugging

I have this controller action:

def view_pdf
  redirect_to @report.pdf.url
end

When I access the route for view_pdf everything works as expected: it redirects to the pdf URL.

However, when I open a pry-byebug session with byebug I get this error when trying to access the URL:

@report.pdf.url
#=> *** NameError Exception: uninitialized constant ActiveStorage::Blob::Analyzable

Also printing the URL works fine. I'm just confused why I cannot access it from the byebug console.

Upvotes: 0

Views: 436

Answers (1)

borjagvo
borjagvo

Reputation: 2071

Well, it was as easy as including ActiveStorage::Blob::Analyzable:

include ActiveStorage::Blob::Analyzable

That made the trick.

Upvotes: 1

Related Questions