Rails 6.1.5: uninitialized constant Mail::TestMailer - ruby-on-rails

Why am i getting 'uninitialized constant Mail::TestMailer' error with "Rails 6.1.5 & Ruby 3.1.0" while working without problems "Rails 6.1.5 & Ruby 3.0.1" ?

Found following from NEWS for Ruby 3.1.0.
The following default gems are now bundled gems.
net-ftp 0.1.3
net-imap 0.2.2
net-pop 0.1.1
net-smtp 0.3.1
matrix 0.4.2
prime 0.1.2
debug 1.4.0
So, i just added next 3 lines into GemFile. It worked fine.
gem 'net-smtp' # to send email
gem 'net-imap' # for rspec
gem 'net-pop' # for rspec

I had similar issue, after debugging and troubleshooting. I made changes to the Rails version to 6.1.1.4 instead of 6.1.7. The I got similar error stating that it could not load some .rb files from the mail gem.
What I did was to give them the read perssion to others.
chmod 644 .rb
and the application loaded fine after that.

I was getting same issue after deploying the code on server.
Version details-
Rails 6.1.5
ruby 3.1.2p20
I just install a new gem as-
gem 'net-smtp'
and issue got resolved.

Related

error while open rails console or while doing rake db:create

I'm getting this error , able to do bundle install sucessfully.
Note- Application uses ruby.2.2.0 and rails 4.2
It seems like the gem uniform_notifier (1.12.0) use Here Documents with a squiggly line. This feature is introduced in Ruby 2.3.0. This means that you have to upgrade your Ruby version, or downgrade the uniform_notifier gem.

Upgrading to Rails 4.2 issues

I'm trying to upgrade to Rails 4.2 from Rails 4.1.9 and when I attempt to run the console or the server i get the following error. Any thoughts? I thought the html-scanner gem was included with Action::View
gems/activesupport-4.2.0/lib/active_support/dependencies.rb:274:in `require': cannot load such file -- action_view/vendor/html-scanner (LoadError)
The OP's issue (and mine) was to do with an incompatibility in the prototype-rails gem. This can be fixed by using the "4.2" branch of prototype-rails directly from github. Modify your Gemfile entry as follows:
gem 'prototype-rails', github: 'rails/prototype-rails', branch: '4.2'
Note that the prototype-rails gem will not be supported from Rails 5 onwards, so now would be as good a time as any to remove this dependency.
I believe they removed html-scanner from rails in 4.2 when they switched to rails-html-sanitizer according to the upgrade guide but it seems you can use the rails-deprecated_sanitizer gem to your Gemfile to then re-include the html-scanner library
gem 'rails-deprecated_sanitizer'
Hope this helps!
I've also had this problem on a legacy project. It's a bundler 1.17.3 / ruby 2.4 / rails 4.2.11.3 and it was driving me up the wall.
The following nasty hack worked:
Gemfile:
gem 'rails-deprecated_sanitizer'
gem 'prototype-rails', git: 'https://github.com/rails/prototype-rails.git', branch: '4.2'
but that wasn't enough. I then had to get rails-deprecated_sanitizer to appear where the gems wanted it.
So in my project, I created lib/action_view/vendor/html-scanner.rb:
require 'rails-deprecated_sanitizer'
require 'rails/deprecated_sanitizer/railtie'
require 'rails/deprecated_sanitizer/html-scanner'
(I doubt all three are needed, mind)
This depends on lib being in your load paths of course.
That fixed the problem, and I was finally able to reset the db and launch the server.

Deploying rails, paperclip error, no such file to load -- cocaine

Using the paperclip-cloudfiles fork of paperclip:
gem 'paperclip-cloudfiles', '~>2.3', :require => 'paperclip'
Using passenger and I get the following load error: no such file to load -- cocaine
Key part of stack trace:
.rvm/gems/ruby-1.9.2-p180/gems/paperclip-cloudfiles-2.3.10.1/lib/paperclip.rb 43 in `'
Paperclip works fine locally on the development server. Haven't been able to find any reference to this problem. Any ideas?
I would add
gem require 'cocaine'
to your Gemfile then run bundle install again.
Extra credit . . . add the dependency to the gem itself and send it back to the community at large.
Updated: per this issue, you should specify version 0.3.2 of cocaine or Paperclip will break. Paperclip currently relies on an older Cocaine API, so specifying the version (0.3.2) in the gemfile in necessary or paperclip won't work.
gem "cocaine", "0.3.2"
[SOLVED]: Downgraded paperclip-cloudfiles to '2.3.8' and it works. Must be a problem with the current version.
Have you already run bundle install on your production server?
You can simply install the missing cocaine gem by
'gem install cocaine'
and everything works.
This might be related to this issue. Paperclip currently relies on an older Cocaine API, so specifying the version (0.3.2) in the gemfile in necessary or paperclip won't work.

Rails 3.0.3, rails_admin gem, generator not found

I am getting error installing Rails_admin with rails 3.0.3. Command line log shown below -
C:\rorprj\app>gem uninstall rails_admin
Successfully uninstalled rails_admin-0.0.0
C:\rorprj\app>gem install rails_admin
Temporarily enhancing PATH to include DevKit...
Successfully installed rails_admin-0.0.0 1 gem installed
Installing ri documentation for rails_admin-0.0.0...
Installing RDoc documentation for rails_admin-0.0.0...
C:\rorprj\app>rails generate rails_admin:install_admin
**Could not find generator rails_admin:install_admin.**
C:\rorprj\app>rails -v
Rails 3.0.3
Anything I can do fix this?
Try this
gem 'rails_admin', :git => 'git://github.com/sferik/rails_admin.git'
Sometimes the actual github repo has an different version. I have it running on 3.0.3 and that is what is in my gemfile.
If you call
rails generate rails_admin
the 'help' returns
*Hello, to install rails_admin into your app you need to ru*n:
rake rails_admin:install
And this works. I just encountered the same problem as you. (Keep in mind that you need to add the gem to the gemfile too)
Did you add this gem to your Gemfile? This file is responsible for loading all gems that your application depends on, and if this gem isn't specified in it then it will not be loaded.

1 error prohibited this {{model}} from being saved

Rails is showing the validation messages on the page as such:
1 error prohibited this {{model}} from being saved
There were problems with the following fields:
{{attribute}} {{message}}
Wanting it to show the model names not these these brackets.
How do I fix it and why's it doing this?
This is a problem with internationalization in rails. One solution that has worked for some is to downgrade the internationalization gem from 0.5.0 to 0.4.2, like so:
sudo gem uninstall i18n
sudo gem install i18n -v 0.4.2
Of course, if you're using RVM to manage your gems, you don't need sudo in the commands above.
The proper solution involves using bundler to manage your gems instead of using the system defaults and the old Rails 2.x method of embedding it into environment.rb. Bundler segregates your application gems from your system gems properly and removes the problems that occur when using i18n versions 0.4.2 and 0.5 along with Rails 2.x and 3.x.
Steps:
Setup bundler for your Rails 2.3 app
http://gembundler.com/rails23.html
In your Gemfile, just completely leave out i18t.
Run 'bundle'
Note: If you do need i18n, just specify the correct version in the Gemfile. Bundler properly segregates your app's gems from your system gems so there will never be the strange behaviors of having both 0.4.2 and 0.5 installed on your system.
if you want to leave both gems installed, another solution is to create config/preinitializers.rb and add the line
gem 'i18n', '0.4.2'
While using Rails 2.3.5, even with config/preinitializers.rb containing
gem 'i18n', '0.4.2
and environment.rb containing
config.gem "i18n", :version => '0.4.2'
I had to uninstall version 0.5.0 of the i18n gem to make this work.

Resources