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
Related
So I have a question, about using ActiveAdmin without Devise, the documentation is not clear on this for my needs and I see a lot of people not answering this question clearly. And to be clear, I am using Rails 5.1
To install without using devise you run
rails g active_admin:install --skip-users
In my case, I already have a User class and my own authentication. The docs say:
If you want to use an existing user class, provide it as an argument:
rails g active_admin:install User
this is where the confusion for me lies. Since, I already have a User class and DO NOT want to use Devise, and the generator above does install Devise, would I run
rails g active_admin:install User --skip-users
or
rails g active_admin:install --skip-users
The official documentation states:
After installing the gem, you need to run the generator. Here are your options:
If you don’t want to use Devise, run it with --skip-users:
rails g active_admin:install --skip-users
Further reading:
https://activeadmin.info/0-installation.html#setting-up-active-admin
After that create your own User model, as described in the docs. You can handle authentication as described here:
https://activeadmin.info/1-general-configuration.html#authentication
Normally it incorporates defining some controller method like authenticate_admin_user!.
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
The options for rails is being displayed
I am new to rails. I went through a tutorial and it generated a scaffold. I tried the same as shown in the picture but could not generate it.
In the image that you posted, it seems that you didn't create your project first. Do this steps:
rails new AppName
After the app auto-bundled, go to your app directory and,
rails g scaffold Todo title:string notes:text
You can follow the following tutorial from Ruby on Rails Guides
We are using devise for our rails application. I have run the following commands to install and generate devise into the app.
rails generate devise:install
rails generate devise user
Now I want to generate the views for the User model at app/views/users/ instead of app/views/devise
rails generate devise:views users
I know that this error has been discussed elsewhere on the web, and this may seem like a stupid question, but I've got a very strange situation on my hands here.
I'm running on Snow Leopard, with fully updated Ruby and Rails gems. I created a new Rails project using ruby new testing, then navigated into that folder using cd ~/testing, and tried to create a basic scaffolding using ruby script/generate scaffold newtest name:string, and I got this error back:
ruby: No such file or directory -- script/generate (LoadError)
I have searched Google thoroughly and tried to implement every solution that I could, but nothing has been working. I don't understand why I have this error or how to fix it.
If you are on rails 3 then the command is:
rails generate scaffold newtest name:string
Or the slightly shorter:
rails g scaffold newtest name:string
Notice rails not ruby.
If you're on Rails 3, you need to use the rails command instead, which now does much of the scripting.
(This is according to another StackOverflow question.)
If you're using the latest version of rails then you no longer use script/generate.
In Rails 3 try using something like this instead:
cd ~/testing
rails generate scaffold Post name:string title:string content:text
You can find more info on the difference between rails 2 and rails 3 here if you like:
http://www.viget.com/extend/rails-3-generators-scaffolding/