I have a project that is on rails 5.1.2
, and I'm trying to implement Active Storage on it, after several online learning online, I can set up Active Storage, and I can see that the data is stored inside active_storage_blobs
and active_storage_attachments
.
I also confirmed the launch user.avatar.attached?
, and in response I realized that everything was working.
I have a problem displaying the image in the field of view, I tried
<%= image_tag(url_for(user.avatar)) %>
NoMethodError: undefined method `active_storage_attachment_path '
What I did to configure Active Storage
Run the install command
rails active_storage:install
This gave an error. I don’t know how to create an active_storage task: install '
but the next team worked
rails activestorage:install
I added gem 'activestorage'
insidegemfile
, storage_services.yml
test:
service: Disk
root: <%= Rails.root.join("tmp/storage") %>
local:
service: Disk
root: <%= Rails.root.join("storage") %>
development.rb
config.active_storage.service = :local
User
has_one_attached :avatar
user.avatar.attach(params[:user][:avatar])
,
? , ?
NoMethodError: undefined `active_storage_attachment_path '