Devise is screwy - ruby-on-rails

When I put require 'devise' in application.rb, I get the error cannot load such file -- devise but when I take it out, I get the error uninitialized constant Devise (NameError) I can't win.

It turns out that my gem file was just completely messed up. I needed to restart my project.

Related

ruby gem issue uninitialized constant

Ok I'm not a pro at creating gems, but I tried my best and created this gem https://rubygems.org/gems/webpack_native/versions/0.2.0
This gem has generators and if I use it from the local folder (meaning the gem folder is in my computer) it works fine, if I type rails g in terminal it shows me the generators including my gem's generators
But using it from rubygems always give me an error uninitialized constant WebpackNative:
/home/mody/.rvm/gems/ruby-2.7.0#myapp/gems/bootsnap-1.4.8/lib/bootsnap/load_path_cache/core_ext/active_support.rb:80:in `block in load_missing_constant': uninitialized constant WebpackNative (NameError)
any thoughts on this?
I'm not sure how this happen but I get it to work after I installed devise gem and run
rails g
the output of the available generators shows up including my gem, and the generator itself is working.

NameError (uninitialized constant HomesController::Indirizzo): Heroku

I've deployed my app to Heroku and am getting the the following error:
v2014-08-29T01:59:06.582118+00:00 app[web.1]: NameError (uninitialized constant HomesController::Indirizzo):
I am using the Indirizzo gem and it's showing as being install on Heroku, but I am still getting that error. I have tried
gem 'Indirizzo', require 'Indirizzo'
in my gem file as one post suggested but that didnt work either.
Make a file (config/initializers/require_indirizzo.rb) to require it, like so:
require 'Indirizzo'
If this does not work, you may try the solution posted by gotva and use this instead:
require 'indirizzo/address'

uninitialized constant CarrierWave::Video

Error message of my server
A NameError occurred in..
uninitialized constant CarrierWave::Video app/uploaders/video_uploader.rb:7:in
<class:VideoUploader>'
video_uploader.rb:7 => include CarrierWave::Video
INFO :
In my local, it works(development & production mode)! But after deploy to server, occur that error.
But in my server rails c production,Input 'include CarrierWave::Video' then Rails Console print not 'NameError: uninitialized constant..' but 'Object'. This means 'include CarrierWave::Video' succeeded!!
Of course, these gem(gem 'carrierwave' , gem 'carrierwave-video') is in my Gemfile and Gemfile.lock and bundle install success.(when deploy) So in my_app/shared/bundle/ruby/2.0.0, GEM_HOME & GEM_PATH of my app, exist these gems
I think 'include' doesn't work. because Like this, i have been met this error at line 'include CarrierWave::RMagick' when using gem 'rmagick' to resize image file uploaded.
Of course, this is not solved yet..
Purely CarrierWave removed line 'include ~~' works well (ex : Image upload not resized..)
nginx + unicorn, linux ubuntu 12.04
Please help me.. T^T
i dont know why 'include CarrierWave::Video' not work in .rb file but work in rails console..
ADDED :
'require' about these gems not exist in my code(in application.rb.. etc..),
(require 'carrierwave/video'.)
If add "require 'carrierwave/video'" to application.rb below require 'rails/all',
occured my application is now worked all. If add to video_uploader.rb and I request page using video_uploader , then occur error cannot such file bulabula..
This error caused by your server didn't reload the module.
Just restart your rails server, and everything will go right.
Make sure you are loading CarrierWave after loading your ORM.
If you added gem 'carrierwave' do this rails generate uploader UPLOADER_NAME

ruby on rails authentication using devise gem

Am using devise gem for authentication
When i run rake db:migrate
I got the error mentioned below:
rake aborted!
User does not respond to 'devise' method.
This usually means you haven't loaded your ORM file or it's being loaded too late.
To fix it, be sure to require 'devise/orm/YOUR_ORM' inside 'config/initializers/devise.rb'
or before your application definition in 'config/application.rb'
If you know answer. Please let me know..
In the file config/initializers/devise.rb look for the line:
require 'devise/orm/active_record'
Make sure that it isn't commented out, and make sure it matches your orm.
If that file doesn't exist, then you haven't installed devise:
rails generate devise:install
Have a good read of the Getting Started instructions

Uninitialized constant ApplicationHelper::Twitter

What's up guys?
I'm using the Twitter-Text gem in my RoR project, but I'm having troubles with the ApplicationHelper. I already see another topics with this same question on StackOverflow, but no one fix my problem.
Ok, let's take a look at my project:
Gemfile
gem 'twitter-text'
Application_Helper.rb
module ApplicationHelper
require 'twitter-text'
include Twitter::Autolink
include Twitter::Extractor
end
// I really don't know why I need create the following file:
helpers/twitter.rb
module TwitterText
end
helpers/twitter_helper.rb
module TwitterText
end
controller/posts_controller.rb
require 'twitter-text'
include Twitter::Extractor
What I see in localhost error page:
Routing Error
uninitialized constant ApplicationHelper::Twitter
Try running rake routes for more information on available routes.
What I see in my console:
ActionController::RoutingError (uninitialized constant ApplicationHelper::Twitter):
app/helpers/application_helper.rb:3:in `<module:ApplicationHelper>'
app/helpers/application_helper.rb:1:in `<top (required)>'
app/controllers/application_controller.rb:1:in `<top (required)>'
It's appear to be everything ok, what can I do to fix this trouble?
Thanks a lot!
whenever installing new gems you have to restart your web server as your gems are loaded when the application environment starts. Those are installed to your global gem directory by doing a bundle install.

Resources