I'm attempting to follow the documentation for the Mail_form gem to add a custom email template. The documentation states:
To customize the e-mail template that is used create a file called contact.erb in app/views/mail_form. Take a look at lib/mail_form/views/mail_form/contact.erb in this repo to see how the default template works.
Also, I found this issue in the repo and did the same:
I created a mail_for.rb file in initializers and added MailForm::Notifier.template_root = File.join(Rails.root, "app", "views"), to the file.
I created a mail_form directory in views and added a contact.erb file and copied the default template to it.
However, when I restart the server I get the following error:
Booting WEBrick
=> Rails 4.2.5 application starting in development on http://localhost:3000
=> Run rails server -h for more startup options
=> Ctrl-C to shutdown server Exiting /Users/Tony/.rvm/gems/ruby-2.2.1/gems/actionmailer-4.2.5/lib/action_mailer/base.rb:569:in
method_missing': undefined methodtemplate_root=' for
MailForm::Notifier:Class (NoMethodError) from
/Users/Tony/Desktop/Corner_Stone/vagrant/src/cornerstone/config/initializers/mail_form.rb:1:in
<top (required)>' from
/Users/Tony/.rvm/gems/ruby-2.2.1/gems/activesupport-4.2.5/lib/active_support/dependencies.rb:268:inload' from
/Users/Tony/.rvm/gems/ruby-2.2.1/gems/activesupport-4.2.5/lib/active_support/dependencies.rb:268:in block in load' from
/Users/Tony/.rvm/gems/ruby-2.2.1/gems/activesupport-4.2.5/lib/active_support/dependencies.rb:240:inload_dependency' from
/Users/Tony/.rvm/gems/ruby-2.2.1/gems/activesupport-4.2.5/lib/active_support/dependencies.rb:268:in load' from
/Users/Tony/.rvm/gems/ruby-2.2.1/gems/railties-4.2.5/lib/rails/engine.rb:652:in
block in load_config_initializer' from
/Users/Tony/.rvm/gems/ruby-2.2.1/gems/activesupport-4.2.5/lib/active_support/notifications.rb:166:in
instrument' from
/Users/Tony/.rvm/gems/ruby-2.2.1/gems/railties-4.2.5/lib/rails/engine.rb:651:in
load_config_initializer' from
/Users/Tony/.rvm/gems/ruby-2.2.1/gems/railties-4.2.5/lib/rails/engine.rb:616:in
block (2 levels) in <class:Engine>' from
/Users/Tony/.rvm/gems/ruby-2.2.1/gems/railties-4.2.5/lib/rails/engine.rb:615:in
each' from
/Users/Tony/.rvm/gems/ruby-2.2.1/gems/railties-4.2.5/lib/rails/engine.rb:615:in
block in <class:Engine>' from
/Users/Tony/.rvm/gems/ruby-2.2.1/gems/railties-4.2.5/lib/rails/initializable.rb:30:in
instance_exec' from
/Users/Tony/.rvm/gems/ruby-2.2.1/gems/railties-4.2.5/lib/rails/initializable.rb:30:in
run' from
/Users/Tony/.rvm/gems/ruby-2.2.1/gems/railties-4.2.5/lib/rails/initializable.rb:55:in
block in run_initializers' from
/Users/Tony/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/tsort.rb:226:in
block in tsort_each' from
/Users/Tony/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/tsort.rb:348:in
block (2 levels) in each_strongly_connected_component' from
/Users/Tony/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/tsort.rb:420:in
block (2 levels) in each_strongly_connected_component_from' from
/Users/Tony/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/tsort.rb:429:in
each_strongly_connected_component_from' from
/Users/Tony/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/tsort.rb:419:in
block in each_strongly_connected_component_from' from
/Users/Tony/.rvm/gems/ruby-2.2.1/gems/railties-4.2.5/lib/rails/initializable.rb:44:in
each' from
/Users/Tony/.rvm/gems/ruby-2.2.1/gems/railties-4.2.5/lib/rails/initializable.rb:44:in
tsort_each_child' from
/Users/Tony/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/tsort.rb:413:in
call' from
/Users/Tony/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/tsort.rb:413:in
each_strongly_connected_component_from' from
/Users/Tony/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/tsort.rb:347:in
block in each_strongly_connected_component' from
/Users/Tony/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/tsort.rb:345:in
each' from
/Users/Tony/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/tsort.rb:345:in
call' from
/Users/Tony/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/tsort.rb:345:in
each_strongly_connected_component' from
/Users/Tony/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/tsort.rb:224:in
tsort_each' from
/Users/Tony/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/tsort.rb:203:in
tsort_each' from
/Users/Tony/.rvm/gems/ruby-2.2.1/gems/railties-4.2.5/lib/rails/initializable.rb:54:in
run_initializers' from
/Users/Tony/.rvm/gems/ruby-2.2.1/gems/railties-4.2.5/lib/rails/application.rb:352:in
initialize!' from
/Users/Tony/Desktop/Corner_Stone/vagrant/src/cornerstone/config/environment.rb:5:in
' from
/Users/Tony/Desktop/Corner_Stone/vagrant/src/cornerstone/config.ru:3:in
require' from
/Users/Tony/Desktop/Corner_Stone/vagrant/src/cornerstone/config.ru:3:in
block in ' from
/Users/Tony/.rvm/gems/ruby-2.2.1/gems/rack-1.6.4/lib/rack/builder.rb:55:in
instance_eval' from
/Users/Tony/.rvm/gems/ruby-2.2.1/gems/rack-1.6.4/lib/rack/builder.rb:55:in
initialize' from
/Users/Tony/Desktop/Corner_Stone/vagrant/src/cornerstone/config.ru:in
new' from
/Users/Tony/Desktop/Corner_Stone/vagrant/src/cornerstone/config.ru:in
' from
/Users/Tony/.rvm/gems/ruby-2.2.1/gems/rack-1.6.4/lib/rack/builder.rb:49:in
eval' from
/Users/Tony/.rvm/gems/ruby-2.2.1/gems/rack-1.6.4/lib/rack/builder.rb:49:in
new_from_string' from
/Users/Tony/.rvm/gems/ruby-2.2.1/gems/rack-1.6.4/lib/rack/builder.rb:40:in
parse_file' from
/Users/Tony/.rvm/gems/ruby-2.2.1/gems/rack-1.6.4/lib/rack/server.rb:299:in
build_app_and_options_from_config' from
/Users/Tony/.rvm/gems/ruby-2.2.1/gems/rack-1.6.4/lib/rack/server.rb:208:in
app' from
/Users/Tony/.rvm/gems/ruby-2.2.1/gems/railties-4.2.5/lib/rails/commands/server.rb:61:in
app' from
/Users/Tony/.rvm/gems/ruby-2.2.1/gems/rack-1.6.4/lib/rack/server.rb:336:in
wrapped_app' from
/Users/Tony/.rvm/gems/ruby-2.2.1/gems/railties-4.2.5/lib/rails/commands/server.rb:139:in
log_to_stdout' from
/Users/Tony/.rvm/gems/ruby-2.2.1/gems/railties-4.2.5/lib/rails/commands/server.rb:78:in
start' from
/Users/Tony/.rvm/gems/ruby-2.2.1/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:80:in
block in server' from
/Users/Tony/.rvm/gems/ruby-2.2.1/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:75:in
tap' from
/Users/Tony/.rvm/gems/ruby-2.2.1/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:75:in
server' from
/Users/Tony/.rvm/gems/ruby-2.2.1/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:39:in
run_command!' from
/Users/Tony/.rvm/gems/ruby-2.2.1/gems/railties-4.2.5/lib/rails/commands.rb:17:in
' from
/Users/Tony/Desktop/Corner_Stone/vagrant/src/cornerstone/bin/rails:9:in
require' from
/Users/Tony/Desktop/Corner_Stone/vagrant/src/cornerstone/bin/rails:9:in
' from
/Users/Tony/.rvm/gems/ruby-2.2.1/gems/spring-1.6.4/lib/spring/client/rails.rb:28:in
load' from
/Users/Tony/.rvm/gems/ruby-2.2.1/gems/spring-1.6.4/lib/spring/client/rails.rb:28:in
call' from
/Users/Tony/.rvm/gems/ruby-2.2.1/gems/spring-1.6.4/lib/spring/client/command.rb:7:in
call' from
/Users/Tony/.rvm/gems/ruby-2.2.1/gems/spring-1.6.4/lib/spring/client.rb:28:in
run' from
/Users/Tony/.rvm/gems/ruby-2.2.1/gems/spring-1.6.4/bin/spring:49:in
<top (required)>' from
/Users/Tony/.rvm/gems/ruby-2.2.1/gems/spring-1.6.4/lib/spring/binstub.rb:11:in
load' from
/Users/Tony/.rvm/gems/ruby-2.2.1/gems/spring-1.6.4/lib/spring/binstub.rb:11:in
<top (required)>' from
/Users/Tony/Desktop/Corner_Stone/vagrant/src/cornerstone/bin/spring:13:in
require' from
/Users/Tony/Desktop/Corner_Stone/vagrant/src/cornerstone/bin/spring:13:in
<top (required)>' from bin/rails:3:inload' from bin/rails:3:in
`'
Everything works when I remove the code in the mail_form.rb file, but I want to customize the mail notification to my liking. The error says undefined method template_root=' for MailForm::Notifier:Class, but I don't know what it means. I'm still learning so this error is a little over my head, Any help would be greatly appreciated! Thanks!
I was faced with the same problem. It was quite frustrating that their documentation is lacking information about custom template. It's so nebulous. I need to give credit to a colleague of mine for finding a quick solution. He is way more skilled than me in Ruby.
Here's what he did:
Remove/delete the mail_form.rb file in initializers. My colleague thinks the gem already does this by default, and after testing this theory I guess he was right. So you don't need the file.
Expend your External Libraries folder in your project tree and find the mail_form folder. I'm using RubyMine so I don't know if your software will show this. tell me if if it doesn't and I will update my answer and paste the initial template code.
Inside the mail_form folder, expand and access the following file lib>mail_form>views>mail_form>contact.erb. This .erb file is the initial template used by the gem.
Copy/paste the content of the file accessed above into the contact.erb file that you previously created inside your mail_form directory in your views directory. This will become your custom template.
Once this is done, you now have full control over the email template, so modify the code to your liking.
Related
I am trying to run bin/rails generate migration ClientsUsersXrefTable
And I get this error:
/Users/user/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/activerecord-5.2.6/lib/active_record/
persistence.rb:138:in `destroy': wrong number of arguments (given 0, expected 1) (ArgumentError)
I am on ruby 2.7.3p183 and rails 5.2.6. What am I missing? Here is the full trace.
Your application has authenticated using end user credentials from Google Cloud SDK. We recommend that most server applications use service accounts instead. If your application continues to use end user credentials from Cloud SDK, you might receive a "quota exceeded" or "API not enabled" error. For more information about service accounts, see https://cloud.google.com/docs/authentication/. To suppress this message, set the GOOGLE_AUTH_SUPPRESS_CREDENTIALS_WARNINGS environment variable.
Note: Google::Cloud::Logging is disabled because the project ID could not be determined. Falling back to the default Rails logger.
DEPRECATION WARNING: Sprockets method `register_engine` is deprecated.
Please register a mime type using `register_mime_type` then
use `register_compressor` or `register_transformer`.
https://github.com/rails/sprockets/blob/master/guides/extending_sprockets.md#supporting-all-versions-of-sprockets-in-processors
(called from block in <class:Railtie> at /Users/user/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/less-rails-2.8.0/lib/less/rails/railtie.rb:16)
DEPRECATION WARNING: You are using a deprecated processor interface Less::Rails::ImportProcessor.
Please update your processor interface:
https://github.com/rails/sprockets/blob/master/guides/extending_sprockets.md#supporting-all-versions-of-sprockets-in-processors
(called from block in <class:Railtie> at /Users/user/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/less-rails-2.8.0/lib/less/rails/railtie.rb:21)
Your application has authenticated using end user credentials from Google Cloud SDK. We recommend that most server applications use service accounts instead. If your application continues to use end user credentials from Cloud SDK, you might receive a "quota exceeded" or "API not enabled" error. For more information about service accounts, see https://cloud.google.com/docs/authentication/. To suppress this message, set the GOOGLE_AUTH_SUPPRESS_CREDENTIALS_WARNINGS environment variable.
Your application has authenticated using end user credentials from Google Cloud SDK. We recommend that most server applications use service accounts instead. If your application continues to use end user credentials from Cloud SDK, you might receive a "quota exceeded" or "API not enabled" error. For more information about service accounts, see https://cloud.google.com/docs/authentication/. To suppress this message, set the GOOGLE_AUTH_SUPPRESS_CREDENTIALS_WARNINGS environment variable.
Note: Google::Cloud::ErrorReporting is disabled because the project ID could not be determined.
Your application has authenticated using end user credentials from Google Cloud SDK. We recommend that most server applications use service accounts instead. If your application continues to use end user credentials from Cloud SDK, you might receive a "quota exceeded" or "API not enabled" error. For more information about service accounts, see https://cloud.google.com/docs/authentication/. To suppress this message, set the GOOGLE_AUTH_SUPPRESS_CREDENTIALS_WARNINGS environment variable.
Your application has authenticated using end user credentials from Google Cloud SDK. We recommend that most server applications use service accounts instead. If your application continues to use end user credentials from Cloud SDK, you might receive a "quota exceeded" or "API not enabled" error. For more information about service accounts, see https://cloud.google.com/docs/authentication/. To suppress this message, set the GOOGLE_AUTH_SUPPRESS_CREDENTIALS_WARNINGS environment variable.
Note: Google::Cloud::Trace is disabled because the project ID could not be determined.
/Users/user/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/activerecord-5.2.6/lib/active_record/persistence.rb:138:in `destroy': wrong number of arguments (given 0, expected 1) (ArgumentError)
from /Users/user/projects/big-rain/app/models/user.rb:8:in `<class:User>'
from /Users/user/projects/big-rain/app/models/user.rb:3:in `<main>'
from /Users/user/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:59:in `load'
from /Users/user/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:59:in `load'
from /Users/user/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/activesupport-5.2.6/lib/active_support/dependencies.rb:476:in `block in load_file'
from /Users/user/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/activesupport-5.2.6/lib/active_support/dependencies.rb:661:in `new_constants_in'
from /Users/user/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/activesupport-5.2.6/lib/active_support/dependencies.rb:475:in `load_file'
from /Users/user/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/activesupport-5.2.6/lib/active_support/dependencies.rb:373:in `block in require_or_load'
from /Users/user/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/activesupport-5.2.6/lib/active_support/dependencies.rb:37:in `block in load_interlock'
from /Users/user/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/activesupport-5.2.6/lib/active_support/dependencies/interlock.rb:14:in `block in loading'
from /Users/user/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/activesupport-5.2.6/lib/active_support/concurrency/share_lock.rb:151:in `exclusive'
from /Users/user/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/activesupport-5.2.6/lib/active_support/dependencies/interlock.rb:13:in `loading'
from /Users/user/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/activesupport-5.2.6/lib/active_support/dependencies.rb:37:in `load_interlock'
from /Users/user/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/activesupport-5.2.6/lib/active_support/dependencies.rb:356:in `require_or_load'
from /Users/user/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/activesupport-5.2.6/lib/active_support/dependencies.rb:510:in `load_missing_constant'
from /Users/user/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/activesupport-5.2.6/lib/active_support/dependencies.rb:195:in `const_missing'
from /Users/user/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/activesupport-5.2.6/lib/active_support/inflector/methods.rb:283:in `const_get'
from /Users/user/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/activesupport-5.2.6/lib/active_support/inflector/methods.rb:283:in `block in constantize'
from /Users/user/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/activesupport-5.2.6/lib/active_support/inflector/methods.rb:281:in `each'
from /Users/user/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/activesupport-5.2.6/lib/active_support/inflector/methods.rb:281:in `inject'
from /Users/user/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/activesupport-5.2.6/lib/active_support/inflector/methods.rb:281:in `constantize'
from /Users/user/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/activesupport-5.2.6/lib/active_support/dependencies.rb:582:in `get'
from /Users/user/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/activesupport-5.2.6/lib/active_support/dependencies.rb:613:in `constantize'
from /Users/user/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/devise-4.8.0/lib/devise.rb:316:in `get'
from /Users/user/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/devise-4.8.0/lib/devise/mapping.rb:83:in `to'
from /Users/user/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/devise-4.8.0/lib/devise/mapping.rb:78:in `modules'
from /Users/user/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/devise-4.8.0/lib/devise/mapping.rb:95:in `routes'
from /Users/user/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/devise-4.8.0/lib/devise/mapping.rb:162:in `default_used_route'
from /Users/user/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/devise-4.8.0/lib/devise/mapping.rb:72:in `initialize'
from /Users/user/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/devise-4.8.0/lib/devise.rb:346:in `new'
from /Users/user/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/devise-4.8.0/lib/devise.rb:346:in `add_mapping'
from /Users/user/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/devise-4.8.0/lib/devise/rails/routes.rb:243:in `block in devise_for'
from /Users/user/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/devise-4.8.0/lib/devise/rails/routes.rb:242:in `each'
from /Users/user/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/devise-4.8.0/lib/devise/rails/routes.rb:242:in `devise_for'
from /Users/user/projects/big-rain/config/routes.rb:4:in `block in <main>'
from /Users/user/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/actionpack-5.2.6/lib/action_dispatch/routing/route_set.rb:432:in `instance_exec'
from /Users/user/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/actionpack-5.2.6/lib/action_dispatch/routing/route_set.rb:432:in `eval_block'
from /Users/user/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/actionpack-5.2.6/lib/action_dispatch/routing/route_set.rb:414:in `draw'
from /Users/user/projects/big-rain/config/routes.rb:1:in `<main>'
from /Users/user/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:59:in `load'
from /Users/user/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:59:in `load'
from /Users/user/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/activesupport-5.2.6/lib/active_support/dependencies.rb:285:in `block in load'
from /Users/user/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/activesupport-5.2.6/lib/active_support/dependencies.rb:257:in `load_dependency'
from /Users/user/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/activesupport-5.2.6/lib/active_support/dependencies.rb:285:in `load'
from /Users/user/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/railties-5.2.6/lib/rails/application/routes_reloader.rb:41:in `block in load_paths'
from /Users/user/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/railties-5.2.6/lib/rails/application/routes_reloader.rb:41:in `each'
from /Users/user/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/railties-5.2.6/lib/rails/application/routes_reloader.rb:41:in `load_paths'
from /Users/user/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/railties-5.2.6/lib/rails/application/routes_reloader.rb:20:in `reload!'
from /Users/user/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/railties-5.2.6/lib/rails/application/routes_reloader.rb:30:in `block in updater'
from /Users/user/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/activesupport-5.2.6/lib/active_support/file_update_checker.rb:83:in `execute'
from /Users/user/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/railties-5.2.6/lib/rails/application/routes_reloader.rb:10:in `execute'
from /Users/user/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/railties-5.2.6/lib/rails/application/finisher.rb:130:in `block in <module:Finisher>'
from /Users/user/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/railties-5.2.6/lib/rails/initializable.rb:32:in `instance_exec'
from /Users/user/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/railties-5.2.6/lib/rails/initializable.rb:32:in `run'
from /Users/user/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/railties-5.2.6/lib/rails/initializable.rb:61:in `block in run_initializers'
from /Users/user/.rbenv/versions/2.7.3/lib/ruby/2.7.0/tsort.rb:228:in `block in tsort_each'
from /Users/user/.rbenv/versions/2.7.3/lib/ruby/2.7.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
from /Users/user/.rbenv/versions/2.7.3/lib/ruby/2.7.0/tsort.rb:431:in `each_strongly_connected_component_from'
from /Users/user/.rbenv/versions/2.7.3/lib/ruby/2.7.0/tsort.rb:349:in `block in each_strongly_connected_component'
from /Users/user/.rbenv/versions/2.7.3/lib/ruby/2.7.0/tsort.rb:347:in `each'
from /Users/user/.rbenv/versions/2.7.3/lib/ruby/2.7.0/tsort.rb:347:in `call'
from /Users/user/.rbenv/versions/2.7.3/lib/ruby/2.7.0/tsort.rb:347:in `each_strongly_connected_component'
from /Users/user/.rbenv/versions/2.7.3/lib/ruby/2.7.0/tsort.rb:226:in `tsort_each'
from /Users/user/.rbenv/versions/2.7.3/lib/ruby/2.7.0/tsort.rb:205:in `tsort_each'
from /Users/user/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/railties-5.2.6/lib/rails/initializable.rb:60:in `run_initializers'
from /Users/user/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/railties-5.2.6/lib/rails/application.rb:361:in `initialize!'
from /Users/user/projects/big-rain/config/environment.rb:5:in `<main>'
from /Users/user/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
from /Users/user/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
from /Users/user/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
from /Users/user/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
from /Users/user/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
from /Users/user/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/activesupport-5.2.6/lib/active_support/dependencies.rb:291:in `block in require'
from /Users/user/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/activesupport-5.2.6/lib/active_support/dependencies.rb:257:in `load_dependency'
from /Users/user/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/activesupport-5.2.6/lib/active_support/dependencies.rb:291:in `require'
from /Users/user/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/spring-2.1.1/lib/spring/application.rb:106:in `preload'
from /Users/user/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/spring-2.1.1/lib/spring/application.rb:157:in `serve'
from /Users/user/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/spring-2.1.1/lib/spring/application.rb:145:in `block in run'
from /Users/user/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/spring-2.1.1/lib/spring/application.rb:139:in `loop'
from /Users/user/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/spring-2.1.1/lib/spring/application.rb:139:in `run'
from /Users/user/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/spring-2.1.1/lib/spring/application/boot.rb:19:in `<top (required)>'
from /Users/user/.rbenv/versions/2.7.3/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:83:in `require'
from /Users/user/.rbenv/versions/2.7.3/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:83:in `require'
from -e:1:in `<main>'
Whenever you run a Rails command, it will potentially set up a bunch of classes before doing the actual work, and unlike many other languages, in Ruby this setup is done by actual Ruby code (this is how DSLs work), and any broken code that runs during that time will prevent any commands from running.
It won't run any instance methods, but any broken class-level code will cause issues.
So the migration thing is just a red herring, presumably all your Rails commands are broken.
According to your stacktrace, app/models/user.rb:8 (which you haven't provided), is getting run during initialisation. Models getting loaded during initialisation is quite common, but in this case that code is breaking.
Looking at the ActiveRecord source code (with less -N `bundle show activerecord`/lib/active_record/persistence.rb and looking at line 138), you seem to be calling the destroy class method (e.g. User.destroy(1)) but without parameters, like you do with the destroy instance method (e.g. User.find(1).destroy). So you should make sure you understand the difference between these two.
I'm not sure why you would be calling User.destroy outside of an instance method, but not having the relevant user model code I cannot say. Is there just a stray "destroy" by itself there?
I am having trouble when i try to run this Sidekiq service on a docker container. My project is based on Ruby on Rails, and besides Sidekiq, it goes along with Mongoid, Redis, and the Rails REST API i've built.
All other services go up, but this one (actuator-controller-sidekiq) breaks with the stack below. I already checked ALL of the .yml files of the project for whitespaces, bad identation and everything else, but i can't even understand where exactly is the problem when i read this stack. Can someone help?
Im not sure which of the files from my project are relevant to put here, so if you guys could comment them, i will be editing the question with the requested files.
(<unknown>): did not find expected key while parsing a block mapping at line 8 column 11
/usr/lib/ruby/2.5.0/psych.rb:402:in `parse'
/usr/lib/ruby/2.5.0/psych.rb:402:in `parse_stream'
/usr/lib/ruby/2.5.0/psych.rb:350:in `parse'
/usr/lib/ruby/2.5.0/psych.rb:263:in `load'
/var/lib/gems/2.5.0/gems/mongoid-6.1.1/lib/mongoid/config/environment.rb:40:in `load_yaml'
/var/lib/gems/2.5.0/gems/mongoid-6.1.1/lib/mongoid/config.rb:86:in `load!'
/var/lib/gems/2.5.0/gems/mongoid-6.1.1/lib/mongoid.rb:104:in `load!'
/var/lib/gems/2.5.0/gems/mongoid-6.1.1/lib/mongoid/railtie.rb:59:in `block in <class:Railtie>'
/var/lib/gems/2.5.0/gems/railties-5.0.0/lib/rails/initializable.rb:30:in `instance_exec'
/var/lib/gems/2.5.0/gems/railties-5.0.0/lib/rails/initializable.rb:30:in `run'
/var/lib/gems/2.5.0/gems/railties-5.0.0/lib/rails/initializable.rb:55:in `block in run_initializers'
/usr/lib/ruby/2.5.0/tsort.rb:228:in `block in tsort_each'
/usr/lib/ruby/2.5.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
/usr/lib/ruby/2.5.0/tsort.rb:431:in `each_strongly_connected_component_from'
/usr/lib/ruby/2.5.0/tsort.rb:349:in `block in each_strongly_connected_component'
/usr/lib/ruby/2.5.0/tsort.rb:347:in `each'
/usr/lib/ruby/2.5.0/tsort.rb:347:in `call'
/usr/lib/ruby/2.5.0/tsort.rb:347:in `each_strongly_connected_component'
/usr/lib/ruby/2.5.0/tsort.rb:226:in `tsort_each'
/usr/lib/ruby/2.5.0/tsort.rb:205:in `tsort_each'
/var/lib/gems/2.5.0/gems/railties-5.0.0/lib/rails/initializable.rb:54:in `run_initializers'
/var/lib/gems/2.5.0/gems/railties-5.0.0/lib/rails/application.rb:352:in `initialize!'
/home/rafael/git/tcc/interscity-dev/actuator-controller/config/environment.rb:5:in `<top (required)>'
/var/lib/gems/2.5.0/gems/sidekiq-5.0.0/lib/sidekiq/cli.rb:255:in `require'
/var/lib/gems/2.5.0/gems/sidekiq-5.0.0/lib/sidekiq/cli.rb:255:in `boot_system'
/var/lib/gems/2.5.0/gems/sidekiq-5.0.0/lib/sidekiq/cli.rb:54:in `run'
/var/lib/gems/2.5.0/gems/sidekiq-5.0.0/bin/sidekiq:12:in `<top (required)>'
/usr/local/bin/sidekiq:23:in `load'
/usr/local/bin/sidekiq:23:in `<main>'
Just found the problem =)
The environment variables to the Mongoid host/port were not in the Sidekiq vars on the docker-compose file. Added them and now it works!
I am new to ruby and rails and was working to setup my first mailer, and when I run the generate command my setup is blowing up. I am currently running ruby-1.9.3-p374 and have been searching for awhile now for a fix for this. My other generate commands work fine, just this one seems to be borked. Thoughts?
rails generate mailer UserMailer
/Users/chrishough/.rvm/rubies/ruby-1.9.3-p374/lib/ruby/1.9.1/psych.rb:203:in `parse': (<unknown>): mapping values are not allowed in this context at line 4 column 12 (Psych::SyntaxError)
from /Users/chrishough/.rvm/rubies/ruby-1.9.3-p374/lib/ruby/1.9.1/psych.rb:203:in `parse_stream'
from /Users/chrishough/.rvm/rubies/ruby-1.9.3-p374/lib/ruby/1.9.1/psych.rb:151:in `parse'
from /Users/chrishough/.rvm/rubies/ruby-1.9.3-p374/lib/ruby/1.9.1/psych.rb:127:in `load'
from /Users/chrishough/.rvm/gems/ruby-1.9.3-p374#My-Application-Profiles/gems/figaro-0.6.3/lib/figaro.rb:21:in `raw'
from /Users/chrishough/.rvm/gems/ruby-1.9.3-p374#My-Application-Profiles/gems/figaro-0.6.3/lib/figaro.rb:17:in `env'
from /Users/chrishough/.rvm/gems/ruby-1.9.3-p374#My-Application-Profiles/gems/figaro-0.6.3/lib/figaro/railtie.rb:7:in `block in <class:Railtie>'
from /Users/chrishough/.rvm/gems/ruby-1.9.3-p374#My-Application-Profiles/gems/activesupport-3.2.13/lib/active_support/lazy_load_hooks.rb:34:in `call'
from /Users/chrishough/.rvm/gems/ruby-1.9.3-p374#My-Application-Profiles/gems/activesupport-3.2.13/lib/active_support/lazy_load_hooks.rb:34:in `execute_hook'
from /Users/chrishough/.rvm/gems/ruby-1.9.3-p374#My-Application-Profiles/gems/activesupport-3.2.13/lib/active_support/lazy_load_hooks.rb:43:in `block in run_load_hooks'
from /Users/chrishough/.rvm/gems/ruby-1.9.3-p374#My-Application-Profiles/gems/activesupport-3.2.13/lib/active_support/lazy_load_hooks.rb:42:in `each'
from /Users/chrishough/.rvm/gems/ruby-1.9.3-p374#My-Application-Profiles/gems/activesupport-3.2.13/lib/active_support/lazy_load_hooks.rb:42:in `run_load_hooks'
from /Users/chrishough/.rvm/gems/ruby-1.9.3-p374#My-Application-Profiles/gems/railties-3.2.13/lib/rails/application.rb:67:in `inherited'
from /Users/chrishough/Huedio/Code/Profiles/config/application.rb:27:in `<module:Profiles>'
from /Users/chrishough/Huedio/Code/Profiles/config/application.rb:26:in `<top (required)>'
from /Users/chrishough/.rvm/gems/ruby-1.9.3-p374#My-Application-Profiles/gems/railties-3.2.13/lib/rails/commands.rb:24:in `require'
from /Users/chrishough/.rvm/gems/ruby-1.9.3-p374#My-Application-Profiles/gems/railties-3.2.13/lib/rails/commands.rb:24:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
If you are using the figaro gem and your generators start blowing up, here is what killed me. In my application.yml file I had removed a space between the environment variable name and what it was set to. Instead of this =>> MY_VARIABLE:"VARIABLE" I needed to have this ==> MY_VARIABLE: "VARIABLE"
Hopefully this will save others TIME!
I have an existing application with database ready I have made all the changes in database.yml and did bundle install when I am trying to do rails s to start the WEBrick server I am getting the following error
/usr/lib/ruby/1.9.1/fileutils.rb:247:in `mkdir': File exists - /home/username/appname/app/releases/20120831125545/tmp (Errno::EEXIST)
from /usr/lib/ruby/1.9.1/fileutils.rb:247:in `fu_mkdir'
from /usr/lib/ruby/1.9.1/fileutils.rb:221:in `block (2 levels) in mkdir_p'
from /usr/lib/ruby/1.9.1/fileutils.rb:219:in `reverse_each'
from /usr/lib/ruby/1.9.1/fileutils.rb:219:in `block in mkdir_p'
from /usr/lib/ruby/1.9.1/fileutils.rb:205:in `each'
from /usr/lib/ruby/1.9.1/fileutils.rb:205:in `mkdir_p'
from /home/username/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.0.10/lib/rails/commands/server.rb:62:in `block in start'
from /home/username/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.0.10/lib/rails/commands/server.rb:61:in `each'
from /home/username/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.0.10/lib/rails/commands/server.rb:61:in `start'
from /home/username/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.0.10/lib/rails/commands.rb:30:in `block in <top (required)>'
from /home/username/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.0.10/lib/rails/commands.rb:27:in `tap'
from /home/username/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.0.10/lib/rails/commands.rb:27:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
Am I missing some step , Do I have to re run the migration (I have the database ready with me with data in it)
any help?
Apparently the tmp directory Rails uses for session store is already present. Try deleting the /tmp folder in your release directory.
I use Cucumber to test my Rails app, and thanks to a running Spork I don't have to start the whole Rails app every time I run a scenario.
I have set the TM_CUCUMBER_OPTS to --drb within TextMate, which works fine, but it results in awkward formatting of the results: it's only text, not HTML anymore.
Any way to fix that? I tried --format=html, but this results in:
Running: /Users/josh/.rvm/bin/rvm-auto-ruby /Users/josh/Documents/Work/Sientia/iq/script/cucumber
/Users/josh/Documents/Work/Sientia/iq/features/authorization/sign_out.feature --drb --format=html
Using the default profile...
Disabling profiles...
Exception encountered: #<RuntimeError: All but one formatter must use --out, only one can print to each stream (or STDOUT)>
backtrace:
/Users/josh/.rvm/gems/ruby-1.9.3-p0#iq/gems/cucumber-1.2.1/lib/cucumber/cli/configuration.rb:198:in `arrange_formats'
/Users/josh/.rvm/gems/ruby-1.9.3-p0#iq/gems/cucumber-1.2.1/lib/cucumber/cli/configuration.rb:26:in `parse!'
/Users/josh/.rvm/gems/ruby-1.9.3-p0#iq/gems/cucumber-1.2.1/lib/cucumber/cli/main.rb:55:in `configuration'
/Users/josh/.rvm/gems/ruby-1.9.3-p0#iq/gems/cucumber-1.2.1/lib/cucumber/cli/main.rb:63:in `run_drb_client'
/Users/josh/.rvm/gems/ruby-1.9.3-p0#iq/gems/cucumber-1.2.1/lib/cucumber/cli/main.rb:34:in `execute!'
/Users/josh/.rvm/gems/ruby-1.9.3-p0#iq/gems/spork-0.9.2/lib/spork/test_framework/cucumber.rb:24:in `run_tests'
/Users/josh/.rvm/gems/ruby-1.9.3-p0#iq/gems/spork-0.9.2/lib/spork/run_strategy/forking.rb:13:in `block in run'
/Users/josh/.rvm/gems/ruby-1.9.3-p0#iq/gems/spork-0.9.2/lib/spork/forker.rb:21:in `block in initialize'
/Users/josh/.rvm/gems/ruby-1.9.3-p0#iq/gems/spork-0.9.2/lib/spork/forker.rb:18:in `fork'
/Users/josh/.rvm/gems/ruby-1.9.3-p0#iq/gems/spork-0.9.2/lib/spork/forker.rb:18:in `initialize'
/Users/josh/.rvm/gems/ruby-1.9.3-p0#iq/gems/spork-0.9.2/lib/spork/run_strategy/forking.rb:9:in `new'
/Users/josh/.rvm/gems/ruby-1.9.3-p0#iq/gems/spork-0.9.2/lib/spork/run_strategy/forking.rb:9:in `run'
/Users/josh/.rvm/gems/ruby-1.9.3-p0#iq/gems/spork-0.9.2/lib/spork/server.rb:48:in `run'
/Users/josh/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/drb/drb.rb:1548:in `perform_without_block'
/Users/josh/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/drb/drb.rb:1508:in `perform'
/Users/josh/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/drb/drb.rb:1586:in `block (2 levels) in main_loop'
/Users/josh/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/drb/drb.rb:1582:in `loop'
/Users/josh/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/drb/drb.rb:1582:in `block in main_loop'
Any idea on how to fix this? Thanks.
Solution from Jim Drannbauer worked for me: http://jimdrannbauer.com/2011/02/22/cucumber-spork-textmate-drb-drbunknown/