Rails Unable to configure simple_form gem - ruby-on-rails

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

Related

Apartment: uninitialized constant Tenant (NameError)

I am using the Apartment Gem for the first time for Multitenancy in a Ruby on Rails project. I am trying to create multiple tenants for users in your digital library Rails application.
I am using Devise Gem for the authentication of the application, and I have generated the and I have generated config file by running the code below in my terminal
rails generate devise:install
I have also generated a User model for Devise using the code below in my terminal
rails generate devise User
And for the Apartment Gem, I have installed it and generated the config file by running the code below in my terminal
bundle exec rails generate apartment:install
I have also configured the config/initializers/apartment.rb initializer file as needed using the documentation provided, but when I run the command below in my terminal
rails generate devise:views
to generate the views for Devise, I get the error below
uninitialized constant Tenant (NameError)
I have tried to figure out the cause of the issue, but I still haven't been fortunate to get it fixed. I need some help. Thank you in advance.
I later realized that the issue was from the configuration that I made initially to Apartment Gem's config/initializers/apartment.rb initializer file.
After creating the User model, I also added it to the excluded models list in the config/initializers/apartment.rb initializer file.
config.excluded_models = %w[Tenant User]
I was supposed to instead replace Tenant in the excluded models list with the User model.
config.excluded_models = %w[User]
And that fixed the issue for me.
N/B: If I named the model name of my subdomain for the multiple tenants as Tenant, then I the configuration can be left like this
config.excluded_models = %w[Tenant]
But for my case, I named the model name of my subdomain for the multiple tenants as User
That's all.
I hope this helps

uninitialized constant Users::RegistrationsController::Shortener Devise + Gem

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?

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

Rubymine using generator from rails console

I am currently using Rubymine for ruby on rails development.
After enjoying the console for testing purposes, I want to use the console instead of the build-in Rails Generator for creating new models and such.
But I can't figure out how to use the rails console (Tools | Run Rails Console) for generating -lets say- a new model "user".
rails generate model user name:string
gives me
NameError: undefined local variable or method `string' for main:Object
I think I'm just missing something very basic here but I couldn't come up with a solution by myself after several tries :/
I hope you can help me out.
Greets
If you feel that you really must use the console to do this, you have a few options to get to the system.
You can use backticks.
or
You can use system()
Your command would then look like system("rails generate model user name:string") or it would look like `rails generate model user name:string`
The command you are trying to run is not something that should be run from a ruby console. It is a bash command. The error you are getting is because you are trying to run something that is not ruby in a ruby environment.

rails generate devise:views NameError: uninitialized constant View

I have followed the #209 tutorial of railscast http://railscasts.com/episodes/209-introducing-devise?view=asciicast. It was working good until I tried to generate the devise views to customize it (tutorial #210 of railscast)
I did :
rails generate devise:views
rails generate devise_views
Got the following error :
NameError: uninitialized constant View
I am using rails 3.1.3, & devise 1.4.7 with warden 1.0.6.
Any ideas ?
Tks Matt
I ran into this issue myself. I accidentally typed rails g devise views which actually created a new model for devise, and added routes for them. I deleted all of the files that were created, then corrected myself and typed rails g devise:views and started getting your exact error.
After a bit of head scratching I ran a git diff to see if anything else was different, and indeed it had added a route for "views". Upon deleting that route, and running rails g devise:views again, all was well!
Hope this helps!
You can find out a list of all the generators by running rails generate or rails g
The correct generator is:
rails g devise:views
I can only think that you are having some sort of version conflict.
Does the following work:
bundle exec rails g devise:views
If not, have you already run:
rails g devise:install
rails g devise User

Resources