My project uses Rails 5.2, Ruby 2.4.1p111.
rails 5.2 comes with active_record "preinstalled", I ran the rails active_storage:install
that generated the migrations, then rails db:migrate
everything right, in the Category.rb model I put has_one_attached :image
.
But has_one_attached is not recognized.
In my config / application.rb I have require 'rails/all'
that imports active_record together.
config / storage.yml looks like this
test:
service: Disk
root: <%= Rails.root.join("tmp/storage") %>
local:
service: Disk
root: <%= Rails.root.join("storage") %>
Does anyone have any idea what it might be?
This is the error that returns me:
/Users/carlos/.rvm/gems/ruby-2.4.1/gems/activerecord-5.2.0/lib/active_record/dynamic_matchers.rb:22:in 'method_missing': undefined method 'has_one_attached' for Category (call 'Category.connection' to establish a connection):Class (NoMethodError)
from /Users/carlos/Downloads/mysalon/app/models/category.rb:4:in '<class:Category>'
from /Users/carlos/Downloads/mysalon/app/models/category.rb:1:in '<main>'
from /Users/carlos/.rvm/gems/ruby-2.4.1/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:100:in 'load'
from /Users/carlos/.rvm/gems/ruby-2.4.1/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:100:in 'load'
from /Users/carlos/.rvm/gems/ruby-2.4.1/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:468:in 'block in load_file'
from /Users/carlos/.rvm/gems/ruby-2.4.1/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:653:in 'new_constants_in'
from /Users/carlos/.rvm/gems/ruby-2.4.1/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:467:in 'load_file'
from /Users/carlos/.rvm/gems/ruby-2.4.1/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:365:in 'block in require_or_load'
from /Users/carlos/.rvm/gems/ruby-2.4.1/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:37:in 'block in load_interlock'
from /Users/carlos/.rvm/gems/ruby-2.4.1/gems/activesupport-5.2.0/lib/active_support/dependencies/interlock.rb:14:in 'block in loading'
from /Users/carlos/.rvm/gems/ruby-2.4.1/gems/activesupport-5.2.0/lib/active_support/concurrency/share_lock.rb:151:in 'exclusive'
from /Users/carlos/.rvm/gems/ruby-2.4.1/gems/activesupport-5.2.0/lib/active_support/dependencies/interlock.rb:13:in 'loading'
from /Users/carlos/.rvm/gems/ruby-2.4.1/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:37:in 'load_interlock'
from /Users/carlos/.rvm/gems/ruby-2.4.1/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:348:in 'require_or_load'
from /Users/carlos/.rvm/gems/ruby-2.4.1/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:502:in 'load_missing_constant'
from /Users/carlos/.rvm/gems/ruby-2.4.1/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/core_ext/active_support.rb:43:in 'load_missing_constant'
from /Users/carlos/.rvm/gems/ruby-2.4.1/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:193:in 'const_missing'
from /Users/carlos/Downloads/mysalon/config/initializers/rails_admin.rb:249:in 'block in <main>'
from /Users/carlos/.rvm/gems/ruby-2.4.1/gems/rails_admin-1.3.0/lib/rails_admin.rb:32:in 'config'
from /Users/carlos/Downloads/mysalon/config/initializers/rails_admin.rb:1:in '<main>'
from /Users/carlos/.rvm/gems/ruby-2.4.1/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:50:in 'load'
from /Users/carlos/.rvm/gems/ruby-2.4.1/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:50:in 'load'
from /Users/carlos/.rvm/gems/ruby-2.4.1/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:277:in 'block in load'
from /Users/carlos/.rvm/gems/ruby-2.4.1/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:249:in 'load_dependency'
from /Users/carlos/.rvm/gems/ruby-2.4.1/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:277:in 'load'
from /Users/carlos/.rvm/gems/ruby-2.4.1/gems/railties-5.2.0/lib/rails/engine.rb:657:in 'block in load_config_initializer'
from /Users/carlos/.rvm/gems/ruby-2.4.1/gems/activesupport-5.2.0/lib/active_support/notifications.rb:170:in 'instrument'
from /Users/carlos/.rvm/gems/ruby-2.4.1/gems/railties-5.2.0/lib/rails/engine.rb:656:in 'load_config_initializer'
from /Users/carlos/.rvm/gems/ruby-2.4.1/gems/railties-5.2.0/lib/rails/engine.rb:614:in 'block (2 levels) in <class:Engine>'
from /Users/carlos/.rvm/gems/ruby-2.4.1/gems/railties-5.2.0/lib/rails/engine.rb:613:in 'each'
from /Users/carlos/.rvm/gems/ruby-2.4.1/gems/railties-5.2.0/lib/rails/engine.rb:613:in 'block in <class:Engine>'
from /Users/carlos/.rvm/gems/ruby-2.4.1/gems/railties-5.2.0/lib/rails/initializable.rb:32:in 'instance_exec'
from /Users/carlos/.rvm/gems/ruby-2.4.1/gems/railties-5.2.0/lib/rails/initializable.rb:32:in 'run'
from /Users/carlos/.rvm/gems/ruby-2.4.1/gems/railties-5.2.0/lib/rails/initializable.rb:61:in 'block in run_initializers'
from /Users/carlos/.rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/tsort.rb:228:in 'block in tsort_each'
from /Users/carlos/.rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/tsort.rb:350:in 'block (2 levels) in each_strongly_connected_component'
from /Users/carlos/.rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/tsort.rb:422:in 'block (2 levels) in each_strongly_connected_component_from'
from /Users/carlos/.rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/tsort.rb:431:in 'each_strongly_connected_component_from'
from /Users/carlos/.rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/tsort.rb:421:in 'block in each_strongly_connected_component_from'
from /Users/carlos/.rvm/gems/ruby-2.4.1/gems/railties-5.2.0/lib/rails/initializable.rb:50:in 'each'
from /Users/carlos/.rvm/gems/ruby-2.4.1/gems/railties-5.2.0/lib/rails/initializable.rb:50:in 'tsort_each_child'
from /Users/carlos/.rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/tsort.rb:415:in 'call'
from /Users/carlos/.rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/tsort.rb:415:in 'each_strongly_connected_component_from'
from /Users/carlos/.rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/tsort.rb:349:in 'block in each_strongly_connected_component'
from /Users/carlos/.rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/tsort.rb:347:in 'each'
from /Users/carlos/.rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/tsort.rb:347:in 'call'
from /Users/carlos/.rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/tsort.rb:347:in 'each_strongly_connected_component'
from /Users/carlos/.rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/tsort.rb:226:in 'tsort_each'
from /Users/carlos/.rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/tsort.rb:205:in 'tsort_each'
from /Users/carlos/.rvm/gems/ruby-2.4.1/gems/railties-5.2.0/lib/rails/initializable.rb:60:in 'run_initializers'
from /Users/carlos/.rvm/gems/ruby-2.4.1/gems/railties-5.2.0/lib/rails/application.rb:361:in 'initialize!'
from /Users/carlos/Downloads/mysalon/config/environment.rb:5:in '<main>'
from /Users/carlos/.rvm/gems/ruby-2.4.1/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in 'require'
from /Users/carlos/.rvm/gems/ruby-2.4.1/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in 'block in require_with_bootsnap_lfi'
from /Users/carlos/.rvm/gems/ruby-2.4.1/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/loaded_features_index.rb:65:in 'register'
from /Users/carlos/.rvm/gems/ruby-2.4.1/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:20:in 'require_with_bootsnap_lfi'
from /Users/carlos/.rvm/gems/ruby-2.4.1/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:29:in 'require'
from /Users/carlos/.rvm/gems/ruby-2.4.1/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:283:in 'block in require'
from /Users/carlos/.rvm/gems/ruby-2.4.1/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:249:in 'load_dependency'
from /Users/carlos/.rvm/gems/ruby-2.4.1/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:283:in 'require'
from /Users/carlos/.rvm/gems/ruby-2.4.1/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:44:in 'require_relative'
from config.ru:3:in 'block in <main>'
from /Users/carlos/.rvm/gems/ruby-2.4.1/gems/rack-2.0.5/lib/rack/builder.rb:55:in 'instance_eval'
from /Users/carlos/.rvm/gems/ruby-2.4.1/gems/rack-2.0.5/lib/rack/builder.rb:55:in 'initialize'
from config.ru:in 'new'
from config.ru:in '<main>'
from /Users/carlos/.rvm/gems/ruby-2.4.1/gems/rack-2.0.5/lib/rack/builder.rb:49:in 'eval'
from /Users/carlos/.rvm/gems/ruby-2.4.1/gems/rack-2.0.5/lib/rack/builder.rb:49:in 'new_from_string'
from /Users/carlos/.rvm/gems/ruby-2.4.1/gems/rack-2.0.5/lib/rack/builder.rb:40:in 'parse_file'
from /Users/carlos/.rvm/gems/ruby-2.4.1/gems/rack-2.0.5/lib/rack/server.rb:319:in 'build_app_and_options_from_config'
from /Users/carlos/.rvm/gems/ruby-2.4.1/gems/rack-2.0.5/lib/rack/server.rb:219:in 'app'
from /Users/carlos/.rvm/gems/ruby-2.4.1/gems/railties-5.2.0/lib/rails/commands/server/server_command.rb:27:in 'app'
from /Users/carlos/.rvm/gems/ruby-2.4.1/gems/rack-2.0.5/lib/rack/server.rb:354:in 'wrapped_app'
from /Users/carlos/.rvm/gems/ruby-2.4.1/gems/railties-5.2.0/lib/rails/commands/server/server_command.rb:89:in 'log_to_stdout'
from /Users/carlos/.rvm/gems/ruby-2.4.1/gems/railties-5.2.0/lib/rails/commands/server/server_command.rb:51:in 'start'
from /Users/carlos/.rvm/gems/ruby-2.4.1/gems/railties-5.2.0/lib/rails/commands/server/server_command.rb:147:in 'block in perform'
from /Users/carlos/.rvm/gems/ruby-2.4.1/gems/railties-5.2.0/lib/rails/commands/server/server_command.rb:142:in 'tap'
from /Users/carlos/.rvm/gems/ruby-2.4.1/gems/railties-5.2.0/lib/rails/commands/server/server_command.rb:142:in 'perform'
from /Users/carlos/.rvm/gems/ruby-2.4.1/gems/thor-0.20.0/lib/thor/command.rb:27:in 'run'
from /Users/carlos/.rvm/gems/ruby-2.4.1/gems/thor-0.20.0/lib/thor/invocation.rb:126:in 'invoke_command'
from /Users/carlos/.rvm/gems/ruby-2.4.1/gems/thor-0.20.0/lib/thor.rb:387:in 'dispatch'
from /Users/carlos/.rvm/gems/ruby-2.4.1/gems/railties-5.2.0/lib/rails/command/base.rb:65:in 'perform'
from /Users/carlos/.rvm/gems/ruby-2.4.1/gems/railties-5.2.0/lib/rails/command.rb:46:in 'invoke'
from /Users/carlos/.rvm/gems/ruby-2.4.1/gems/railties-5.2.0/lib/rails/commands.rb:18:in '<main>'
from /Users/carlos/.rvm/gems/ruby-2.4.1/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in 'require'
from /Users/carlos/.rvm/gems/ruby-2.4.1/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in 'block in require_with_bootsnap_lfi'
from /Users/carlos/.rvm/gems/ruby-2.4.1/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/loaded_features_index.rb:65:in 'register'
from /Users/carlos/.rvm/gems/ruby-2.4.1/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:20:in 'require_with_bootsnap_lfi'
from /Users/carlos/.rvm/gems/ruby-2.4.1/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:29:in 'require'
from /Users/carlos/.rvm/gems/ruby-2.4.1/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:283:in 'block in require'
from /Users/carlos/.rvm/gems/ruby-2.4.1/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:249:in 'load_dependency'
from /Users/carlos/.rvm/gems/ruby-2.4.1/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:283:in 'require'
from /Users/carlos/Downloads/mysalon/bin/rails:9:in '<top (required)>'
from /Users/carlos/.rvm/gems/ruby-2.4.1/gems/spring-2.0.2/lib/spring/client/rails.rb:28:in 'load'
from /Users/carlos/.rvm/gems/ruby-2.4.1/gems/spring-2.0.2/lib/spring/client/rails.rb:28:in 'call'
from /Users/carlos/.rvm/gems/ruby-2.4.1/gems/spring-2.0.2/lib/spring/client/command.rb:7:in 'call'
from /Users/carlos/.rvm/gems/ruby-2.4.1/gems/spring-2.0.2/lib/spring/client.rb:30:in 'run'
from /Users/carlos/.rvm/gems/ruby-2.4.1/gems/spring-2.0.2/bin/spring:49:in '<top (required)>'
from /Users/carlos/.rvm/gems/ruby-2.4.1/gems/spring-2.0.2/lib/spring/binstub.rb:31:in 'load'
from /Users/carlos/.rvm/gems/ruby-2.4.1/gems/spring-2.0.2/lib/spring/binstub.rb:31:in '<top (required)>'
from /Users/carlos/Downloads/mysalon/bin/spring:15:in 'require'
from /Users/carlos/Downloads/mysalon/bin/spring:15:in '<top (required)>'
from bin/rails:3:in 'load'
from bin/rails:3:in '<main>'