Rails + ActiveStorage problem when starting server = undefined method `has_one_attached'
I'm having a problem with a specific model. When I start my Ruby on Rails server rails s
I get an error which says undefined method
has_one_attached'`. Here's a strange thing:
If I comment out has_one_attached :avatar
and start the server, it starts fine. Then I can uncomment has_one_attached :avatar
, save the file and load the application, ActiveStorage functions.
But I don't want to have to comment out all active storage functions each time I start the server.
Rails version = 5.2.1
Ruby version = 2.4.4
Here's the model:
class User < ApplicationRecord
has_person_name
rolify
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :validatable
# For reasons I can't understand. This doesn't work here. I'm developing it in organizations for the time being.
has_one_attached :avatar
has_and_belongs_to_many :organizations
end
Here's the application.rb file:
require_relative 'boot'
require 'rails/all'
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)
module *ProjectName*
class Application < Rails::Application
# Initialize configuration defaults for originally generated Rails version.
config.load_defaults 5.2
config.generators do |g|
g.orm :active_record
g.template_engine :erb
g.test_framework false
g.stylesheets false
g.javascripts false
g.helper false
g.scaffold_stylesheet false
end
end
end
Here's the Error Message:
$ rails s
/Users/silverSheep/.rvm/gems/ruby-2.4.4/gems/pry-rails-0.3.6/lib/pry-rails/prompt.rb:36: warning: constant Pry::Prompt::MAP is deprecated
=> Booting Puma
=> Rails 5.2.1 application starting in development
=> Run `rails server -h` for more startup options
Exiting
/Users/silverSheep/.rvm/gems/ruby-2.4.4/gems/activerecord-5.2.1/lib/active_record/dynamic_matchers.rb:22:in `method_missing': undefined method `has_one_attached' for User (call 'User.connection' to establish a connection):Class (NoMethodError)
Did you mean? has_person_name
from /Users/silverSheep/Desktop/code/withBetter/projectName/app/models/user.rb:3:in `<class:User>'
from /Users/silverSheep/Desktop/code/withBetter/projectName/app/models/user.rb:1:in `<main>'
from /Users/silverSheep/.rvm/gems/ruby-2.4.4/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:50:in `load'
from /Users/silverSheep/.rvm/gems/ruby-2.4.4/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:50:in `load'
from /Users/silverSheep/.rvm/gems/ruby-2.4.4/gems/activesupport-5.2.1/lib/active_support/dependencies.rb:472:in `block in load_file'
from /Users/silverSheep/.rvm/gems/ruby-2.4.4/gems/activesupport-5.2.1/lib/active_support/dependencies.rb:657:in `new_constants_in'
from /Users/silverSheep/.rvm/gems/ruby-2.4.4/gems/activesupport-5.2.1/lib/active_support/dependencies.rb:471:in `load_file'
from /Users/silverSheep/.rvm/gems/ruby-2.4.4/gems/activesupport-5.2.1/lib/active_support/dependencies.rb:369:in `block in require_or_load'
from /Users/silverSheep/.rvm/gems/ruby-2.4.4/gems/activesupport-5.2.1/lib/active_support/dependencies.rb:37:in `block in load_interlock'
from /Users/silverSheep/.rvm/gems/ruby-2.4.4/gems/activesupport-5.2.1/lib/active_support/dependencies/interlock.rb:14:in `block in loading'
from /Users/silverSheep/.rvm/gems/ruby-2.4.4/gems/activesupport-5.2.1/lib/active_support/concurrency/share_lock.rb:151:in `exclusive'
from /Users/silverSheep/.rvm/gems/ruby-2.4.4/gems/activesupport-5.2.1/lib/active_support/dependencies/interlock.rb:13:in `loading'
from /Users/silverSheep/.rvm/gems/ruby-2.4.4/gems/activesupport-5.2.1/lib/active_support/dependencies.rb:37:in `load_interlock'
from /Users/silverSheep/.rvm/gems/ruby-2.4.4/gems/activesupport-5.2.1/lib/active_support/dependencies.rb:352:in `require_or_load'
from /Users/silverSheep/.rvm/gems/ruby-2.4.4/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/active_support.rb:46:in `block in require_or_load'
from /Users/silverSheep/.rvm/gems/ruby-2.4.4/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/active_support.rb:16:in `allow_bootsnap_retry'
from /Users/silverSheep/.rvm/gems/ruby-2.4.4/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/active_support.rb:45:in `require_or_load'
from /Users/silverSheep/.rvm/gems/ruby-2.4.4/gems/activesupport-5.2.1/lib/active_support/dependencies.rb:506:in `load_missing_constant'
from /Users/silverSheep/.rvm/gems/ruby-2.4.4/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/active_support.rb:58:in `block in load_missing_constant'
from /Users/silverSheep/.rvm/gems/ruby-2.4.4/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/active_support.rb:16:in `allow_bootsnap_retry'
from /Users/silverSheep/.rvm/gems/ruby-2.4.4/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/active_support.rb:57:in `load_missing_constant'
from /Users/silverSheep/.rvm/gems/ruby-2.4.4/gems/activesupport-5.2.1/lib/active_support/dependencies.rb:193:in `const_missing'
from /Users/silverSheep/.rvm/gems/ruby-2.4.4/gems/activesupport-
...(shortened for brevity)....
from bin/rails:3:in `load'
from bin/rails:3:in `<main>'
ruby-on-rails server
add a comment |
I'm having a problem with a specific model. When I start my Ruby on Rails server rails s
I get an error which says undefined method
has_one_attached'`. Here's a strange thing:
If I comment out has_one_attached :avatar
and start the server, it starts fine. Then I can uncomment has_one_attached :avatar
, save the file and load the application, ActiveStorage functions.
But I don't want to have to comment out all active storage functions each time I start the server.
Rails version = 5.2.1
Ruby version = 2.4.4
Here's the model:
class User < ApplicationRecord
has_person_name
rolify
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :validatable
# For reasons I can't understand. This doesn't work here. I'm developing it in organizations for the time being.
has_one_attached :avatar
has_and_belongs_to_many :organizations
end
Here's the application.rb file:
require_relative 'boot'
require 'rails/all'
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)
module *ProjectName*
class Application < Rails::Application
# Initialize configuration defaults for originally generated Rails version.
config.load_defaults 5.2
config.generators do |g|
g.orm :active_record
g.template_engine :erb
g.test_framework false
g.stylesheets false
g.javascripts false
g.helper false
g.scaffold_stylesheet false
end
end
end
Here's the Error Message:
$ rails s
/Users/silverSheep/.rvm/gems/ruby-2.4.4/gems/pry-rails-0.3.6/lib/pry-rails/prompt.rb:36: warning: constant Pry::Prompt::MAP is deprecated
=> Booting Puma
=> Rails 5.2.1 application starting in development
=> Run `rails server -h` for more startup options
Exiting
/Users/silverSheep/.rvm/gems/ruby-2.4.4/gems/activerecord-5.2.1/lib/active_record/dynamic_matchers.rb:22:in `method_missing': undefined method `has_one_attached' for User (call 'User.connection' to establish a connection):Class (NoMethodError)
Did you mean? has_person_name
from /Users/silverSheep/Desktop/code/withBetter/projectName/app/models/user.rb:3:in `<class:User>'
from /Users/silverSheep/Desktop/code/withBetter/projectName/app/models/user.rb:1:in `<main>'
from /Users/silverSheep/.rvm/gems/ruby-2.4.4/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:50:in `load'
from /Users/silverSheep/.rvm/gems/ruby-2.4.4/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:50:in `load'
from /Users/silverSheep/.rvm/gems/ruby-2.4.4/gems/activesupport-5.2.1/lib/active_support/dependencies.rb:472:in `block in load_file'
from /Users/silverSheep/.rvm/gems/ruby-2.4.4/gems/activesupport-5.2.1/lib/active_support/dependencies.rb:657:in `new_constants_in'
from /Users/silverSheep/.rvm/gems/ruby-2.4.4/gems/activesupport-5.2.1/lib/active_support/dependencies.rb:471:in `load_file'
from /Users/silverSheep/.rvm/gems/ruby-2.4.4/gems/activesupport-5.2.1/lib/active_support/dependencies.rb:369:in `block in require_or_load'
from /Users/silverSheep/.rvm/gems/ruby-2.4.4/gems/activesupport-5.2.1/lib/active_support/dependencies.rb:37:in `block in load_interlock'
from /Users/silverSheep/.rvm/gems/ruby-2.4.4/gems/activesupport-5.2.1/lib/active_support/dependencies/interlock.rb:14:in `block in loading'
from /Users/silverSheep/.rvm/gems/ruby-2.4.4/gems/activesupport-5.2.1/lib/active_support/concurrency/share_lock.rb:151:in `exclusive'
from /Users/silverSheep/.rvm/gems/ruby-2.4.4/gems/activesupport-5.2.1/lib/active_support/dependencies/interlock.rb:13:in `loading'
from /Users/silverSheep/.rvm/gems/ruby-2.4.4/gems/activesupport-5.2.1/lib/active_support/dependencies.rb:37:in `load_interlock'
from /Users/silverSheep/.rvm/gems/ruby-2.4.4/gems/activesupport-5.2.1/lib/active_support/dependencies.rb:352:in `require_or_load'
from /Users/silverSheep/.rvm/gems/ruby-2.4.4/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/active_support.rb:46:in `block in require_or_load'
from /Users/silverSheep/.rvm/gems/ruby-2.4.4/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/active_support.rb:16:in `allow_bootsnap_retry'
from /Users/silverSheep/.rvm/gems/ruby-2.4.4/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/active_support.rb:45:in `require_or_load'
from /Users/silverSheep/.rvm/gems/ruby-2.4.4/gems/activesupport-5.2.1/lib/active_support/dependencies.rb:506:in `load_missing_constant'
from /Users/silverSheep/.rvm/gems/ruby-2.4.4/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/active_support.rb:58:in `block in load_missing_constant'
from /Users/silverSheep/.rvm/gems/ruby-2.4.4/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/active_support.rb:16:in `allow_bootsnap_retry'
from /Users/silverSheep/.rvm/gems/ruby-2.4.4/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/active_support.rb:57:in `load_missing_constant'
from /Users/silverSheep/.rvm/gems/ruby-2.4.4/gems/activesupport-5.2.1/lib/active_support/dependencies.rb:193:in `const_missing'
from /Users/silverSheep/.rvm/gems/ruby-2.4.4/gems/activesupport-
...(shortened for brevity)....
from bin/rails:3:in `load'
from bin/rails:3:in `<main>'
ruby-on-rails server
error seems to be on line 3 which isrolify
– Lenin Raj Rajasekaran
Nov 20 '18 at 22:49
Commenting out rolify doesn't change the error... Thank you for taking a look @emaillenin
– iarobinson
Nov 20 '18 at 22:55
Have you generated the migrations necessary for ActiveStorage? You can do it by executing the following in the terminal:rails active_storage:install:migrations
, thereafterrails db:migrate
– timbillstrom
Nov 20 '18 at 23:17
Thank you @timbillstrom, but yeah... I've already done that. The weird part is that it's working fine for another (named "Organizations") model. The server will start withhas_one_attached :avatar
commented out of theUser.rb
model file. If I uncomment and save after the server has started, ActiveStorage works for the User model then. The problem is I can't start the server withhas_one_attached :avatar
in active code of the User model.
– iarobinson
Nov 20 '18 at 23:24
@iarobinson , if you're connected to a small database for development (with no crucial data, the following command will completely remove you database), I'd try to drop the database, and run the migrations(s) once again. I've encountered the same issue a while ago, too bad I can't recall my exact approach. Hint:rake db:drop db:create db:migrate
– timbillstrom
Nov 20 '18 at 23:37
add a comment |
I'm having a problem with a specific model. When I start my Ruby on Rails server rails s
I get an error which says undefined method
has_one_attached'`. Here's a strange thing:
If I comment out has_one_attached :avatar
and start the server, it starts fine. Then I can uncomment has_one_attached :avatar
, save the file and load the application, ActiveStorage functions.
But I don't want to have to comment out all active storage functions each time I start the server.
Rails version = 5.2.1
Ruby version = 2.4.4
Here's the model:
class User < ApplicationRecord
has_person_name
rolify
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :validatable
# For reasons I can't understand. This doesn't work here. I'm developing it in organizations for the time being.
has_one_attached :avatar
has_and_belongs_to_many :organizations
end
Here's the application.rb file:
require_relative 'boot'
require 'rails/all'
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)
module *ProjectName*
class Application < Rails::Application
# Initialize configuration defaults for originally generated Rails version.
config.load_defaults 5.2
config.generators do |g|
g.orm :active_record
g.template_engine :erb
g.test_framework false
g.stylesheets false
g.javascripts false
g.helper false
g.scaffold_stylesheet false
end
end
end
Here's the Error Message:
$ rails s
/Users/silverSheep/.rvm/gems/ruby-2.4.4/gems/pry-rails-0.3.6/lib/pry-rails/prompt.rb:36: warning: constant Pry::Prompt::MAP is deprecated
=> Booting Puma
=> Rails 5.2.1 application starting in development
=> Run `rails server -h` for more startup options
Exiting
/Users/silverSheep/.rvm/gems/ruby-2.4.4/gems/activerecord-5.2.1/lib/active_record/dynamic_matchers.rb:22:in `method_missing': undefined method `has_one_attached' for User (call 'User.connection' to establish a connection):Class (NoMethodError)
Did you mean? has_person_name
from /Users/silverSheep/Desktop/code/withBetter/projectName/app/models/user.rb:3:in `<class:User>'
from /Users/silverSheep/Desktop/code/withBetter/projectName/app/models/user.rb:1:in `<main>'
from /Users/silverSheep/.rvm/gems/ruby-2.4.4/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:50:in `load'
from /Users/silverSheep/.rvm/gems/ruby-2.4.4/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:50:in `load'
from /Users/silverSheep/.rvm/gems/ruby-2.4.4/gems/activesupport-5.2.1/lib/active_support/dependencies.rb:472:in `block in load_file'
from /Users/silverSheep/.rvm/gems/ruby-2.4.4/gems/activesupport-5.2.1/lib/active_support/dependencies.rb:657:in `new_constants_in'
from /Users/silverSheep/.rvm/gems/ruby-2.4.4/gems/activesupport-5.2.1/lib/active_support/dependencies.rb:471:in `load_file'
from /Users/silverSheep/.rvm/gems/ruby-2.4.4/gems/activesupport-5.2.1/lib/active_support/dependencies.rb:369:in `block in require_or_load'
from /Users/silverSheep/.rvm/gems/ruby-2.4.4/gems/activesupport-5.2.1/lib/active_support/dependencies.rb:37:in `block in load_interlock'
from /Users/silverSheep/.rvm/gems/ruby-2.4.4/gems/activesupport-5.2.1/lib/active_support/dependencies/interlock.rb:14:in `block in loading'
from /Users/silverSheep/.rvm/gems/ruby-2.4.4/gems/activesupport-5.2.1/lib/active_support/concurrency/share_lock.rb:151:in `exclusive'
from /Users/silverSheep/.rvm/gems/ruby-2.4.4/gems/activesupport-5.2.1/lib/active_support/dependencies/interlock.rb:13:in `loading'
from /Users/silverSheep/.rvm/gems/ruby-2.4.4/gems/activesupport-5.2.1/lib/active_support/dependencies.rb:37:in `load_interlock'
from /Users/silverSheep/.rvm/gems/ruby-2.4.4/gems/activesupport-5.2.1/lib/active_support/dependencies.rb:352:in `require_or_load'
from /Users/silverSheep/.rvm/gems/ruby-2.4.4/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/active_support.rb:46:in `block in require_or_load'
from /Users/silverSheep/.rvm/gems/ruby-2.4.4/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/active_support.rb:16:in `allow_bootsnap_retry'
from /Users/silverSheep/.rvm/gems/ruby-2.4.4/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/active_support.rb:45:in `require_or_load'
from /Users/silverSheep/.rvm/gems/ruby-2.4.4/gems/activesupport-5.2.1/lib/active_support/dependencies.rb:506:in `load_missing_constant'
from /Users/silverSheep/.rvm/gems/ruby-2.4.4/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/active_support.rb:58:in `block in load_missing_constant'
from /Users/silverSheep/.rvm/gems/ruby-2.4.4/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/active_support.rb:16:in `allow_bootsnap_retry'
from /Users/silverSheep/.rvm/gems/ruby-2.4.4/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/active_support.rb:57:in `load_missing_constant'
from /Users/silverSheep/.rvm/gems/ruby-2.4.4/gems/activesupport-5.2.1/lib/active_support/dependencies.rb:193:in `const_missing'
from /Users/silverSheep/.rvm/gems/ruby-2.4.4/gems/activesupport-
...(shortened for brevity)....
from bin/rails:3:in `load'
from bin/rails:3:in `<main>'
ruby-on-rails server
I'm having a problem with a specific model. When I start my Ruby on Rails server rails s
I get an error which says undefined method
has_one_attached'`. Here's a strange thing:
If I comment out has_one_attached :avatar
and start the server, it starts fine. Then I can uncomment has_one_attached :avatar
, save the file and load the application, ActiveStorage functions.
But I don't want to have to comment out all active storage functions each time I start the server.
Rails version = 5.2.1
Ruby version = 2.4.4
Here's the model:
class User < ApplicationRecord
has_person_name
rolify
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :validatable
# For reasons I can't understand. This doesn't work here. I'm developing it in organizations for the time being.
has_one_attached :avatar
has_and_belongs_to_many :organizations
end
Here's the application.rb file:
require_relative 'boot'
require 'rails/all'
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)
module *ProjectName*
class Application < Rails::Application
# Initialize configuration defaults for originally generated Rails version.
config.load_defaults 5.2
config.generators do |g|
g.orm :active_record
g.template_engine :erb
g.test_framework false
g.stylesheets false
g.javascripts false
g.helper false
g.scaffold_stylesheet false
end
end
end
Here's the Error Message:
$ rails s
/Users/silverSheep/.rvm/gems/ruby-2.4.4/gems/pry-rails-0.3.6/lib/pry-rails/prompt.rb:36: warning: constant Pry::Prompt::MAP is deprecated
=> Booting Puma
=> Rails 5.2.1 application starting in development
=> Run `rails server -h` for more startup options
Exiting
/Users/silverSheep/.rvm/gems/ruby-2.4.4/gems/activerecord-5.2.1/lib/active_record/dynamic_matchers.rb:22:in `method_missing': undefined method `has_one_attached' for User (call 'User.connection' to establish a connection):Class (NoMethodError)
Did you mean? has_person_name
from /Users/silverSheep/Desktop/code/withBetter/projectName/app/models/user.rb:3:in `<class:User>'
from /Users/silverSheep/Desktop/code/withBetter/projectName/app/models/user.rb:1:in `<main>'
from /Users/silverSheep/.rvm/gems/ruby-2.4.4/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:50:in `load'
from /Users/silverSheep/.rvm/gems/ruby-2.4.4/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:50:in `load'
from /Users/silverSheep/.rvm/gems/ruby-2.4.4/gems/activesupport-5.2.1/lib/active_support/dependencies.rb:472:in `block in load_file'
from /Users/silverSheep/.rvm/gems/ruby-2.4.4/gems/activesupport-5.2.1/lib/active_support/dependencies.rb:657:in `new_constants_in'
from /Users/silverSheep/.rvm/gems/ruby-2.4.4/gems/activesupport-5.2.1/lib/active_support/dependencies.rb:471:in `load_file'
from /Users/silverSheep/.rvm/gems/ruby-2.4.4/gems/activesupport-5.2.1/lib/active_support/dependencies.rb:369:in `block in require_or_load'
from /Users/silverSheep/.rvm/gems/ruby-2.4.4/gems/activesupport-5.2.1/lib/active_support/dependencies.rb:37:in `block in load_interlock'
from /Users/silverSheep/.rvm/gems/ruby-2.4.4/gems/activesupport-5.2.1/lib/active_support/dependencies/interlock.rb:14:in `block in loading'
from /Users/silverSheep/.rvm/gems/ruby-2.4.4/gems/activesupport-5.2.1/lib/active_support/concurrency/share_lock.rb:151:in `exclusive'
from /Users/silverSheep/.rvm/gems/ruby-2.4.4/gems/activesupport-5.2.1/lib/active_support/dependencies/interlock.rb:13:in `loading'
from /Users/silverSheep/.rvm/gems/ruby-2.4.4/gems/activesupport-5.2.1/lib/active_support/dependencies.rb:37:in `load_interlock'
from /Users/silverSheep/.rvm/gems/ruby-2.4.4/gems/activesupport-5.2.1/lib/active_support/dependencies.rb:352:in `require_or_load'
from /Users/silverSheep/.rvm/gems/ruby-2.4.4/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/active_support.rb:46:in `block in require_or_load'
from /Users/silverSheep/.rvm/gems/ruby-2.4.4/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/active_support.rb:16:in `allow_bootsnap_retry'
from /Users/silverSheep/.rvm/gems/ruby-2.4.4/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/active_support.rb:45:in `require_or_load'
from /Users/silverSheep/.rvm/gems/ruby-2.4.4/gems/activesupport-5.2.1/lib/active_support/dependencies.rb:506:in `load_missing_constant'
from /Users/silverSheep/.rvm/gems/ruby-2.4.4/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/active_support.rb:58:in `block in load_missing_constant'
from /Users/silverSheep/.rvm/gems/ruby-2.4.4/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/active_support.rb:16:in `allow_bootsnap_retry'
from /Users/silverSheep/.rvm/gems/ruby-2.4.4/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/active_support.rb:57:in `load_missing_constant'
from /Users/silverSheep/.rvm/gems/ruby-2.4.4/gems/activesupport-5.2.1/lib/active_support/dependencies.rb:193:in `const_missing'
from /Users/silverSheep/.rvm/gems/ruby-2.4.4/gems/activesupport-
...(shortened for brevity)....
from bin/rails:3:in `load'
from bin/rails:3:in `<main>'
ruby-on-rails server
ruby-on-rails server
asked Nov 20 '18 at 22:39
iarobinsoniarobinson
61
61
error seems to be on line 3 which isrolify
– Lenin Raj Rajasekaran
Nov 20 '18 at 22:49
Commenting out rolify doesn't change the error... Thank you for taking a look @emaillenin
– iarobinson
Nov 20 '18 at 22:55
Have you generated the migrations necessary for ActiveStorage? You can do it by executing the following in the terminal:rails active_storage:install:migrations
, thereafterrails db:migrate
– timbillstrom
Nov 20 '18 at 23:17
Thank you @timbillstrom, but yeah... I've already done that. The weird part is that it's working fine for another (named "Organizations") model. The server will start withhas_one_attached :avatar
commented out of theUser.rb
model file. If I uncomment and save after the server has started, ActiveStorage works for the User model then. The problem is I can't start the server withhas_one_attached :avatar
in active code of the User model.
– iarobinson
Nov 20 '18 at 23:24
@iarobinson , if you're connected to a small database for development (with no crucial data, the following command will completely remove you database), I'd try to drop the database, and run the migrations(s) once again. I've encountered the same issue a while ago, too bad I can't recall my exact approach. Hint:rake db:drop db:create db:migrate
– timbillstrom
Nov 20 '18 at 23:37
add a comment |
error seems to be on line 3 which isrolify
– Lenin Raj Rajasekaran
Nov 20 '18 at 22:49
Commenting out rolify doesn't change the error... Thank you for taking a look @emaillenin
– iarobinson
Nov 20 '18 at 22:55
Have you generated the migrations necessary for ActiveStorage? You can do it by executing the following in the terminal:rails active_storage:install:migrations
, thereafterrails db:migrate
– timbillstrom
Nov 20 '18 at 23:17
Thank you @timbillstrom, but yeah... I've already done that. The weird part is that it's working fine for another (named "Organizations") model. The server will start withhas_one_attached :avatar
commented out of theUser.rb
model file. If I uncomment and save after the server has started, ActiveStorage works for the User model then. The problem is I can't start the server withhas_one_attached :avatar
in active code of the User model.
– iarobinson
Nov 20 '18 at 23:24
@iarobinson , if you're connected to a small database for development (with no crucial data, the following command will completely remove you database), I'd try to drop the database, and run the migrations(s) once again. I've encountered the same issue a while ago, too bad I can't recall my exact approach. Hint:rake db:drop db:create db:migrate
– timbillstrom
Nov 20 '18 at 23:37
error seems to be on line 3 which is
rolify
– Lenin Raj Rajasekaran
Nov 20 '18 at 22:49
error seems to be on line 3 which is
rolify
– Lenin Raj Rajasekaran
Nov 20 '18 at 22:49
Commenting out rolify doesn't change the error... Thank you for taking a look @emaillenin
– iarobinson
Nov 20 '18 at 22:55
Commenting out rolify doesn't change the error... Thank you for taking a look @emaillenin
– iarobinson
Nov 20 '18 at 22:55
Have you generated the migrations necessary for ActiveStorage? You can do it by executing the following in the terminal:
rails active_storage:install:migrations
, thereafter rails db:migrate
– timbillstrom
Nov 20 '18 at 23:17
Have you generated the migrations necessary for ActiveStorage? You can do it by executing the following in the terminal:
rails active_storage:install:migrations
, thereafter rails db:migrate
– timbillstrom
Nov 20 '18 at 23:17
Thank you @timbillstrom, but yeah... I've already done that. The weird part is that it's working fine for another (named "Organizations") model. The server will start with
has_one_attached :avatar
commented out of the User.rb
model file. If I uncomment and save after the server has started, ActiveStorage works for the User model then. The problem is I can't start the server with has_one_attached :avatar
in active code of the User model.– iarobinson
Nov 20 '18 at 23:24
Thank you @timbillstrom, but yeah... I've already done that. The weird part is that it's working fine for another (named "Organizations") model. The server will start with
has_one_attached :avatar
commented out of the User.rb
model file. If I uncomment and save after the server has started, ActiveStorage works for the User model then. The problem is I can't start the server with has_one_attached :avatar
in active code of the User model.– iarobinson
Nov 20 '18 at 23:24
@iarobinson , if you're connected to a small database for development (with no crucial data, the following command will completely remove you database), I'd try to drop the database, and run the migrations(s) once again. I've encountered the same issue a while ago, too bad I can't recall my exact approach. Hint:
rake db:drop db:create db:migrate
– timbillstrom
Nov 20 '18 at 23:37
@iarobinson , if you're connected to a small database for development (with no crucial data, the following command will completely remove you database), I'd try to drop the database, and run the migrations(s) once again. I've encountered the same issue a while ago, too bad I can't recall my exact approach. Hint:
rake db:drop db:create db:migrate
– timbillstrom
Nov 20 '18 at 23:37
add a comment |
1 Answer
1
active
oldest
votes
Run rails active_storage:install
and add the following to the config/environments/development.rb file to store the files locally:
config.active_storage.service = :local
.
Also make sure to add the new parameter to the permitted ones to the application_controller.rb:
before_action :configure_permitted_parameters, if: :devise_controller?
protected
def configure_permitted_parameters
devise_parameter_sanitizer.permit(:sign_up, keys: [:avatar])
devise_parameter_sanitizer.permit(:account_update, keys: [:avatar])
end
And do not forget to do the migration for the new generated tables from active storage with rails db:migrate
.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53402664%2frails-activestorage-problem-when-starting-server-undefined-method-has-one-a%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Run rails active_storage:install
and add the following to the config/environments/development.rb file to store the files locally:
config.active_storage.service = :local
.
Also make sure to add the new parameter to the permitted ones to the application_controller.rb:
before_action :configure_permitted_parameters, if: :devise_controller?
protected
def configure_permitted_parameters
devise_parameter_sanitizer.permit(:sign_up, keys: [:avatar])
devise_parameter_sanitizer.permit(:account_update, keys: [:avatar])
end
And do not forget to do the migration for the new generated tables from active storage with rails db:migrate
.
add a comment |
Run rails active_storage:install
and add the following to the config/environments/development.rb file to store the files locally:
config.active_storage.service = :local
.
Also make sure to add the new parameter to the permitted ones to the application_controller.rb:
before_action :configure_permitted_parameters, if: :devise_controller?
protected
def configure_permitted_parameters
devise_parameter_sanitizer.permit(:sign_up, keys: [:avatar])
devise_parameter_sanitizer.permit(:account_update, keys: [:avatar])
end
And do not forget to do the migration for the new generated tables from active storage with rails db:migrate
.
add a comment |
Run rails active_storage:install
and add the following to the config/environments/development.rb file to store the files locally:
config.active_storage.service = :local
.
Also make sure to add the new parameter to the permitted ones to the application_controller.rb:
before_action :configure_permitted_parameters, if: :devise_controller?
protected
def configure_permitted_parameters
devise_parameter_sanitizer.permit(:sign_up, keys: [:avatar])
devise_parameter_sanitizer.permit(:account_update, keys: [:avatar])
end
And do not forget to do the migration for the new generated tables from active storage with rails db:migrate
.
Run rails active_storage:install
and add the following to the config/environments/development.rb file to store the files locally:
config.active_storage.service = :local
.
Also make sure to add the new parameter to the permitted ones to the application_controller.rb:
before_action :configure_permitted_parameters, if: :devise_controller?
protected
def configure_permitted_parameters
devise_parameter_sanitizer.permit(:sign_up, keys: [:avatar])
devise_parameter_sanitizer.permit(:account_update, keys: [:avatar])
end
And do not forget to do the migration for the new generated tables from active storage with rails db:migrate
.
answered Nov 20 '18 at 23:34
Andrea O.Andrea O.
1
1
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53402664%2frails-activestorage-problem-when-starting-server-undefined-method-has-one-a%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
error seems to be on line 3 which is
rolify
– Lenin Raj Rajasekaran
Nov 20 '18 at 22:49
Commenting out rolify doesn't change the error... Thank you for taking a look @emaillenin
– iarobinson
Nov 20 '18 at 22:55
Have you generated the migrations necessary for ActiveStorage? You can do it by executing the following in the terminal:
rails active_storage:install:migrations
, thereafterrails db:migrate
– timbillstrom
Nov 20 '18 at 23:17
Thank you @timbillstrom, but yeah... I've already done that. The weird part is that it's working fine for another (named "Organizations") model. The server will start with
has_one_attached :avatar
commented out of theUser.rb
model file. If I uncomment and save after the server has started, ActiveStorage works for the User model then. The problem is I can't start the server withhas_one_attached :avatar
in active code of the User model.– iarobinson
Nov 20 '18 at 23:24
@iarobinson , if you're connected to a small database for development (with no crucial data, the following command will completely remove you database), I'd try to drop the database, and run the migrations(s) once again. I've encountered the same issue a while ago, too bad I can't recall my exact approach. Hint:
rake db:drop db:create db:migrate
– timbillstrom
Nov 20 '18 at 23:37