`method_missing': undefined method `action_mailer' for #<Rails::Application::Configuration:0x00> - ruby-on-rails

I am building a rails app and was using rails 4.0.1.
I had an error and noticed that it was mentioned as a bug on rails 3 months ago so I decided to: bundle update and got rails 4.0.3
after doing so neither the tests nor the server would start and they throw an error:
gems/railties-4.0.3/lib/rails/railtie/configuration.rb:95:in `method_missing': undefined method `action_mailer' for # (NoMethodError)
For the moment I commented out the action_mailer lines in the config/environments/* but it would be good to find a real solution.
Searching on Google didn't yield anything regarding this specific error.
Please let me know if I can provide any more detail.
Thank you very much.
UPDATE: here is my Gemfile
source 'https://rubygems.org'
ruby '2.0.0'
gem 'bootstrap-sass'
gem 'bootstrap_form'
gem 'coffee-rails'
gem 'rails'
gem 'haml-rails'
gem 'sass-rails'
gem 'uglifier'
gem 'jquery-rails'
gem 'bcrypt-ruby', '~> 3.1.2'
group :development do
gem 'sqlite3'
gem 'thin'
# gem "better_errors"
gem "binding_of_caller"
end
group :production do
gem 'pg'
gem 'rails_12factor'
end
group :development, :test do
gem 'rspec-rails'
gem 'pry'
gem 'pry-nav'
end
group :test do
gem "faker"
gem "capybara"
gem "database_cleaner"
gem "launchy"
gem 'shoulda-matchers'
gem "selenium-webdriver"
gem "fivemat"
gem 'fabrication'
end

Solution found, in case anyone lands here:
The main issue was that in my Gemfile as you can see no specific gem version was set (apart from bcrypt)
Somehow this makes bundle installs outdated versions under circumstances that are not yet clear to me.
Steps to fix:
completely remove the gemset (if you are using one) or uninstall all
gems
remove the Gemfile.lock
specifiy what version of rails you need e.g. 'rails', '~> 4.0.3'
bundle install
you are set :)

in my case I had installed the gems and since the devkit was not installed properly the gems did not compile.
After setting up the devkit I had to uninstall all of the rails gems (actionmailer, activerecord, actioncable......) and then install rails again.
Then it worked.

Related

Issue with rails s (with sass apparently)

I tried to run rails s but sudently I'm getting an error message:
/home/leiver/.rbenv/versions/2.4.5/lib/ruby/gems/2.4.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require': cannot load such file -- sass (LoadError)
from /home/leiver/.rbenv/versions/2.4.5/lib/ruby/gems/2.4.0/gems/activesupport-5.2.1/lib/active_support/dependencies.rb:287:in `block in require'
from /home/leiver/.rbenv/versions/2.4.5/lib/ruby/gems/2.4.0/gems/activesupport-5.2.1/lib/active_support/dependencies.rb:253:in `load_dependency'
from
.....
I know that there's something about sass about how it's going to disapear or something and I don't know if it's linked
Thanks if you can help :)
EDIT
here's my full Gemfile:
source 'https://rubygems.org'
ruby '2.4.5'
gem 'bootsnap', require: false
gem 'jbuilder', '~> 2.0'
gem 'pg', '~> 0.21'
gem 'puma'
gem 'rails', '5.2.1'
gem 'redis'
gem 'autoprefixer-rails'
gem 'bootstrap-sass', '~> 3.3'
gem 'font-awesome-sass', '~> 5.0.9'
gem 'sassc-rails'
gem 'simple_form'
gem 'uglifier'
gem 'webpacker'
gem 'devise'
gem 'money-rails'
gem "pundit"
group :development do
gem 'web-console', '>= 3.3.0'
end
group :development, :test do
gem 'pry-byebug'
gem 'pry-rails'
gem 'listen', '~> 3.0.5'
gem 'spring'
gem 'spring-watcher-listen', '~> 2.0.0'
gem 'dotenv-rails'
end
Have tried bundle or bundle install before running the rails s.
Still not working try to replace that gem with thisgem 'sassc' and bundle or just do gem install sassc
Ok so I couldn't resolve the problem, so I deleted my local directory and re-cloned it from GitHub.
I don't know if it's good practice but it resolved the problem for me, so if anyone else is having this issue and don't find a proper solution, try doing that.
The problem may be exists in gems. The problem founded by OP (and described in his answer) appears in the application files. However same problem problem may be caused in gems. The same problem in gems with same reason has identical solution.
In details. The problem during installation or some else may corrupt some gem so it is visible as installed but actually has missed or corrupted files. Check before that hard drive has enough free space.
So solution is fully reinstall bundle gems:
bundle install --force
I deleted all of the files within the tmp folder.
And it worked!

Bundler::GemNotFound when executing delayed job stop during cap deploy

I'm doing some work with an old code base that was running Ruby 1.9.3 and Rails 3.2.3. However, I had to update to Ruby 2 (I chose 2.1.5, because I've used it in the past) to fix an SSL error that arose when using the PayPal API (my task was to implement PayPal for credit card processing). This caused an error with the asset pipeline, and after some investigation I discovered that Rails 3.2.3 didn't support Ruby 2.1.5, so I had to upgrade to Rails 3.2.19.
Everything was working fine on my local machine. When it came time to deploy, I installed rbenv on the server (it didn't have RVM or rbenv) and installed Ruby 2.1.5.
Now, the deploy script gets past bundle install, but when it tries to execute cd /var/www/cappwww/current && RAILS_ENV=production script/delayed_job stop, it chokes and says Could not find *** in any of the sources (Bundler::GemNotFound).
"***" is just a placeholder; this happened first with i18n, then multi_json. I manually changed the requested versions of these gems and ran bundle update, and it seemed to work. However, it is now requesting activesupport 3.2.3, and I can't force it to use that because Rails 3.2.19 requires activesupport 3.2.19.
As far as I can tell, this isn't an issue of delayed_job actually requiring these gems, because 1) they would be installed during bundle install, or bundle install would complain if there was an unresolvable dependency, and 2) delayed_job requires activesupport >= 3 according to rubygems, so 3.2.19 should do just fine.
It seems that for some reason, the delayed_job script is looking for a very specific gemset, specifically the old gemset. However, I have no idea what could be causing it to do that.
My Gemfile is
source 'http://rubygems.org'
gem 'rake', '10.1.1'
gem 'rmagick'
gem 'rails', '3.2.19'
gem 'devise', '2.0'
gem 'haml', '3.1.4'
gem 'sass', '3.2.3'
gem 'formtastic', '2.1.0.rc'
gem 'cocaine', '0.3.2'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
#gem 'mysql2', '0.2.6'
gem 'mysql2', '0.3.11'
#gem 'less', '~> 2.0.8'
gem 'less', '~> 2.2.1'
gem 'tinymce-rails', '3.5.8'
gem 'will_paginate', '3.0.3'
gem 'country_select', '1.0.1'
gem 'paypal-sdk-rest'
# Use unicorn as the web server
gem 'unicorn'
gem 'jquery-rails', '2.1.4'
gem 'paperclip', '3.2.1'
gem 'feedzirra', '0.0.24'
gem 'delayed_job', '4.1.0'
gem 'delayed_job_active_record', '4.1.0'
gem 'daemons', '1.1.9'
gem 'therubyracer', '0.12.0'
# To use debugger (ruby-debug for Ruby 1.8.7+, ruby-debug19 for Ruby 1.9.2+)
# gem 'ruby-debug'
# gem 'ruby-debug19'
# Bundle the extra gems:
# gem 'bj'
# gem 'nokogiri'
# gem 'sqlite3-ruby', :require => 'sqlite3'
# gem 'aws-s3', :require => 'aws/s3'
gem 'rsolr', '1.0.7'
gem 'sunspot', '1.3.3'
gem 'sunspot_solr', '1.3.3'
gem 'sunspot_rails', '1.3.3'
gem 'hpricot', '0.8.6'
gem 'roadie', '2.3.4'
group :assets do
gem 'sass-rails'
gem 'uglifier'
end
# Bundle gems for the local environment. Make sure to
# put test-only gems in this group so their generators
# and rake tasks are available in development mode:
group :development, :test do
# Deploy with Capistrano
gem 'capistrano', '2.13.5'
gem 'capistrano-rbenv'
gem 'rspec-rails', '~> 2.6'
gem 'machinist', '2.0'
gem 'faker', '1.0.1'
gem 'syntax', '1.0.0'
gem 'progress_bar', '0.4.0'
end
group :development do
gem 'active_record_query_trace', '1.1'
end
Any help would be greatly appreciated, as I'm in pretty far over my head.
Well, I figured it out. The RAILS_ENV=production script/delayed_job stop command was executing in the current folder, which is the previous release. Since I was using rbenv to force Ruby 2.1.5, the gems for the previous release had not been installed for the current version of Ruby, which is why delayed_job was complaining. Running bundle install in the current directory fixed the issue.

Ruby on Rails installed on windows getting ExecJS::ProgramError

I'm working on a project which I normally work on Mac OSX. I'm on ruby MRI V.1.9.3-p194 and rails v.3.2.8.
but, for the time being, there has been a need to collaborate the project source code with another team member who's using windows.
I proceeded on to set up everything on my colleague's windows machine and almost everything seems to work quite well, the same ruby and rails framework version are used. I managed to get 'bundle install' to pass by having most of their dependencies resolved. (So, you can imagine that the versions of gems have got updated from those on my Mac Machine)
I also have node.js installed on my colleague's machine in order to make ruby able to run javascript.
A while later, it seemed I was able to start the web server using "bundle exec thin start" and it's starting without any error. The other reason, I'm quite sure my setup's been coming in the right way
because I can retrieve model records via rail console beautifully. But I'm only getting one error, every time I try to browse to the app on the web browser.
Every time I'm getting node.js dependency error "cannot find module 'stylus'"
that even prevents me from getting the login page loaded.
here is a snapshot of the error I get:
also, I'm happy to share you my Gemfile, so it could give you more clues what actually goes wrong? it can be found below:
source 'http://rubygems.org'
gem 'rails', '3.2.8'
gem 'rubyzip', '< 1.0.0'
gem 'roo','1.12.1'
gem 'mysql2', '0.3.11'
gem 'jquery-rails', '2.1.2'
gem 'haml', '3.1.7'
gem 'thin', '1.4.1'
group :development do
gem 'capistrano', '2.13.4'
end
gem 'devise', '2.1.2'
gem 'devise-async', '0.5.0'
gem 'cancan', '1.6.8'
gem 'simple_form', '2.0.4'
gem 'cocoon', '1.1.1'
gem 'inherited_resources', '1.3.1'
gem 'will_paginate', '3.0.3'
gem 'bootstrap-will_paginate', '0.0.9'
gem 'mechanize', '2.5.1'
gem 'delayed_job', '3.0.4'
gem 'paperclip', '3.4.0'
gem 'spreadsheet', '0.6.4.1'
gem 'geocoder', '1.1.6'
gem 'whenever', '0.8.2'
gem 'american_date', '1.0.0'
gem 'money','5.1.1'
gem 'rets','0.5.1'
gem 'haversine','0.3.0'
gem 'capybara'
gem 'poltergeist'
gem 'selenium-webdriver'
gem 'redis'
gem 'execjs','2.0.0'
group :assets do
gem 'stylus', '0.7.1'
gem 'coffee-rails', '3.2.2'
gem 'uglifier', '1.3.0'
end
What should I do to get this to work? Any help would be greatly appreciated.
Updated:
I updated my question rgrd Brad suggestion accordingly.
I've performed as suggested. but when I have node.js uninstalled, I rather got another error like below "The node.js runtime is not available". any idea?
You can see the answer here
I changed from coffee-script-source 1.12.2 to 1.8.0 in Gemfile.lock file.
ex) coffee-script-source (1.8.0)
And then, in cmd, I put a command like 'bundle install'.
If you do not have a bundle, you can install bundle such as
gem install bundle
Finally, turn off your rails server and turn on again.
Thank you.

Upgrade from Rails 3.2 to Rails 4

I have an application in Rails 3.2 which is ready to deploy. I am wondering should I upgrade it to Rails 4 or not. I also not sure about which of the gems might give issues with while upgrading.
Below is my Gemfile with several common gems.
Gemfile.rb
source 'https://rubygems.org'
gem 'rails', '3.2.8'
gem 'pg', '0.12.2'
gem 'bcrypt-ruby', '3.0.1'
gem 'will_paginate', '3.0.3'
gem 'bootstrap-will_paginate', '0.0.6'
gem 'simple_form', '2.0'
gem 'rails3-jquery-autocomplete', '1.0.10'
gem 'show_for', '0.1'
gem 'paperclip', '3.3.1'
gem 'cocoon', '1.1.1'
gem 'google_visualr', '2.1.0'
gem 'axlsx', '1.3.4'
gem 'acts_as_xlsx', '1.0.6'
gem 'devise' ,'2.1.2'
gem 'cancan', '1.6.8'
gem 'bootstrap-datepicker-rails', "0.6.32"
gem 'country_select', '1.1.3'
gem 'jquery-rails', '2.1.4'
gem 'annotate', '2.5.0', group: :development
gem 'ransack', '0.7.2'
gem "audited-activerecord", "3.0.0"
gem 'prawn', '1.0.0.rc2'
gem 'exception_notification', '3.0.1'
gem 'daemons', '1.1.9'
gem 'delayed_job_active_record', '0.4.3'
gem "delayed_job_web", '1.1.2'
gem "less-rails"
gem "therubyracer"
gem 'twitter-bootstrap-rails', '~>2.1.9'
gem "spreadsheet", "~> 0.8.8"
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '3.2.5'
gem 'coffee-rails', '3.2.2'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', :platforms => :ruby
gem 'uglifier', '1.2.3'
end
# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'
# To use Jbuilder templates for JSON
# gem 'jbuilder'
# Use unicorn as the app server
# gem 'unicorn'
# Deploy with Capistrano
# gem 'capistrano'
# To use debugger
# gem 'debugger'
group :development, :test do
gem 'rspec-rails', '2.11.0'
end
group :test do
gem 'capybara', '1.1.2'
gem 'factory_girl_rails', '4.1.0'
gem 'faker', '1.0.1'
end
I started working on this application last year (Nov 2012) after reading this great book at
http://ruby.railstutorial.org/. I have also checked out what's new in Rails 4 like strong parameters and it's all very tempting to try an upgrade.
But I am concerned about compatibility of these gems and effort it may take.
I need some advice from experienced guys in the community or someone who has tried upgrading before I move ahead.
I uploaded your gemfile to Ready for Rails 4, and it appears that you only have a couple gems that are not ready and one gem that is unknown. For some of the gems listed that do not have notes, I would suggest checking out their GitHub page (if they have one), and see if the gem has been updated recently on rubygems, just to confirm whether or not the gem works.
This brief handbook was worth every cent in our recent 3.2 to 4 migration.
https://leanpub.com/upgradetorails4
https://github.com/alindeman/upgradingtorails4
It lists in details how to handle gem upgrades, as well as individual details (with clear examples) of what's changed and how to manage your current Rails app through the upgrade.
To address your gem-specific concerns: Almost all our 40+ gems, except perhaps 5, had active either Rails 4 releases (or Github branches for Rails 4), or worked just fine with Rails 4 when left intact.
Having a healthy unit/functional test suite in your codebase would be vital for your confidence in the upgrade being successful.
The asset pipeline has changed a bit, so you'll need to upgrade those gems. I had to use a fork of ransack in the context of active_admin, but you might be fine.
I'd recommend that you create a branch, bump to Rails 4, and see what happens. It took me a day or two to upgrade from 3.2 to 4 a couple weeks ago on a fairly small (but production-with-customers) application. The upgrade guide is pretty solid.

Passenger says Bundler:GemNotFound error while the bundle install says it's there

i get Passenger error on shared hosting
Could not find i18n-0.6.0 in any of the sources (Bundler::GemNotFound)
but if i run "bundle install" it says everything is ok :(
and the contents of the Gemfile are:
source 'http://rubygems.org'
gem 'rake', '0.8.7'
gem 'tzinfo', '0.3.27'
gem 'mail', '2.2.16'
gem 'arel', '2.0.9'
gem 'rack', '1.2.2'
gem 'i18n', '0.6.0'
gem 'rails', '3.0.5'
gem 'mysql2'
gem 'paperclip'
gem 'devise'
gem 'jquery-rails'
gem 'acts-as-taggable-on'
gem "will_paginate", "~> 3.0.pre2"
gem 'tiny_mce'
gem "oa-oauth", :require => "omniauth/oauth"
gem "acts_as_list"
"bundle show i18n" gives
/usr/lib/ruby/gems/1.8/gems/i18n-0.6.0
is it the error in my app or error of the hosting? how do i solve it?
it was hosting service bug. here's their reply:
"Passenger and the shell are on two different servers. i18n was installed on
Passenger, however the version was not 0.6.0."
so as i suspected different gems were used for passenger than the ones bundler used

Resources