uninitialized constant Users::RegistrationsController::Shortener Devise + Gem - ruby-on-rails

I'm using a gem called Shortener: https://github.com/jpmcgrath/shortener
Its goal is to shorten some urls of my website such as www.mywebsite.com/users/sign_up?&invitcode="test" would become www.mywebsite.com/shorturl.
I meet a problem in my Devise registration_controller.rb where I'm trying to use this gem. When I called it with Shortener::ShortenedUrl.generate("www.example.com") I get a uninitialized constant Users::RegistrationsController::Shortener.
If I do the same command in my console, it's working perfectly. I guess it's because Rails cannot find Shortener in my devise module? Can you tell me how I should solve this?

Related

block in load_missing_constant': uninitialized constant API::V1::Users (NameError)

Im trying to set up api endpoints for my rails application and keep receiving this error my environment is Ruby 2.6 and Rails 5.2 and im using the 'grape' gem for the api here is the blog I followed to set it up. https://medium.com/#ryanwaldorf/how-to-add-an-api-to-an-existing-rails-app-1d2419ba91bd
here is a link to my repo https://github.com/jslack2537/apiDemoApp
I believe the issue is wither in my config/routes.rb or my application.rb files.
But I could be totally wrong. This is a challenge app and not going to be used in production.
This mainly occurs when naming conventions doesn't match. Try changing api/v1/user.rb to api/v1/users.rb which also the blog suggests. You missed a 's'.

Can I use Rails gem from another gem?

I am developing a simple gem. as part of it, I want data-caching to which I need rails gem. I included the required statements in gemspec. But still, it is not loading Rails. I am getting below error
NameError:
uninitialized constant FormattingHelper::Rails
Instead of using Rails for caching, I used below class and fixed the problem
ActiveSupport::Cache

Rails Unable to configure simple_form gem

I'm trying to start a new rails app with devise and simple_form.
After adding the simple_form gem to my gemfile and bundling, when I try to configure simple_form by running rails generate simple_form:install from the command line I get the following error:
[Simple Form] Simple Form is not configured in the application and will use the default values. Use `rails generate simple_form:install` to generate the Simple Form configuration.
~/.gem/ruby/2.3.0/gems/activesupport-4.2.6/lib/active_support/inflector/methods.rb:261:in `const_get': uninitialized constant View (NameError)
Anybody know what's going on?
It seems like the it's just a warning.
The underlying error is: ~/.gem/ruby/2.3.0/gems/activesupport-4.2.6/lib/active_support/inflector/methods.rb:261:inconst_get': uninitialized constant View (NameError)`
Is View one of your devise models? If yes, does it exist?
Try running:
rails generate devise View

gem google cloud messaging for rails browser

when i'm following this guide gcm_on_rails, i get some error
when i try execute 'rails generate gcm_migrations' on my console, i get error like below :
while trying to load the gem 'gcm_on_rails'.
Gem Load Error is: undefined method `attr_accessible' for #<Class:0x0000000121c298>
Did you mean? attr_accessor
how to fix it?
i'm trying to implements google cloud messaging on browser
need help
As mentioned in A Guide for Upgrading Ruby on Rails:
Rails 4.0 has removed attr_accessible and attr_protected feature in favor of Strong Parameters.
So if you're into Rails 4.0, you can use Protected Attributes gem for a smooth upgrade path or you can also do what was suggested in this related SO post - Undefined Method attr_accessible by using strong parameters.
I hope those given options work for you.

Devise Suspendable gem failure due to reliance to Activatable module

I get the following error trying to use the devise_suspendable gem.
/home/graeme/.rvm/gems/ree-1.8.7-2011.03#epra/gems/devise-1.4.5/lib/devise/models.rb:60:in `const_get': uninitialized constant Devise::Models::Activatable (NameError)
It's trying to use the activatable module in Devise but I have a feeling it's been deprecrated.
I've tried running with the suspendable module included, but ignoring the activatable module. I don't get any errors, but it doesn't stop a suspended user from logging in either.
While I haven't found a solution for this problem exactly, it turns out to be quite easy to use the lockable module in Devise instead.

Resources