I'm new to ROR, I have recently included DEVISE into my Rails project but accidentally I ran a wrong command as follows:
rails g devise install
After that rails starting showing errors and not working, even the server is not running now.
Here's a screenshot showing the number of errors I'm getting and their details:
Now even the normal command for installing devise, i.e. devise:install is not working.
Does this command work for you? rails destroy devise:install
This should delete your Devise configuration.
Related
I am trying to use the simple-captcha gem with
gem "galetahub-simple_captcha", :require => "simple_captcha".
I am running Rails 5.0.0.1 and Ruby 2.3.2.
I couldn't get it to work in my app so I created a clean skin, rails new, rails generate scaffold User, rake db:migrate etc. As soon as I add the gem, I can bundle install fine, but as soon as I run rails test or rails generate or anything I get this error:
user/.rvm/gems/ruby-2.3.3/gems/galetahub-simple_captcha-0.1.5/lib/simple_captcha/form_builder.rb:7:in `included': uninitialized constant Sprockets::Helpers (NameError)
I have tried following the setup instructions for the gem, which says to run rails generate captcha after installing the gem, but as soon as I have installed the gem I get the error.
Any help would be appreciated.
On the other hand if anyone thinks there is a better captcha I should be using for form submission, let me know.
Looks like latest commit to "simple_captcha" repository was 3 years ago. It's outdated and maybe it will be not worked with Rails 5.
You can use Recaptcha from Google https://github.com/ambethia/recaptcha
You can use Recaptcha gem as advised by Alex
There is nice tutorial for this https://www.sitepoint.com/quick-tip-add-recaptcha-to-your-rails-application/
What happens after the simple captcha is installed?
I created a rails project MyProject and tried to set up Devise in it (using this tutorial). After I did some Devise stuff I could not scaffold User anymore, I ran into an error as shown below. So I wanted to start over, renamed the project to MyProject-Devise and created a new project MyProject to create User first and then do my Devise stuff. Now in my new project of the same name, when I run
rails generate scaffold user name:string email:string
I run into the same error. If I create a new app with another name, I can scaffold the user with the same command. So I guess it must be the same name thing.
Any ideas why this happens? How to get rid of the error or how to properly start the project over again?
This is the error:
/Users/luke/.rbenv/versions/2.1.4/lib/ruby/gems/2.1.0/gems/activesupport-4.1.7/lib/active_support/inflector/methods.rb:238:in `const_get': uninitialized constant User (NameError)
Full error here: http://pastebin.com/KFh4U6aS
It looks like you might not be using Bundler. The tutorial you linked to had you create a Gemfile but didn't tell you to run bundle or bundle exec. Without Bundler you may be using a Devise installed directly into your Ruby's gems.
I suspect if you run the rails generate command with bundle exec you may have different results.
bundle exec rails generate scaffold user name:string email:string
I'm trying to get user authentication with devise working, and failing.
I tried following the steps in the RailsGirls article, but after creating the simple new project, adding the gem 'devise' and running bundle install, but when I run rails generate devise:install I get a screenful of errors starting
Error:Get available generators script executes with errors:
Error:C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.1.1/lib/active_record/dynamic_matchers.rb:26:in `method_missing': undefined method `devise' for User (call 'User.connection' to establish a connection):Class (NoMethodError)
Has anybody any idea what I might be doing wrong? (I tried using the instructions in the devise wiki, but I couldn't get it working that way either).
I just ran to this same problem today, it's because you tried to generate the model before you tried to install devise it self
Stash ( or remove ) the changes for the user model and any migration file, then run this
rails generate devise:install
after that unstash and apply the migration, it should work just fine.
I installed devise 1.1.rc0 and haven't been able to get it to work in my existing application.
I changed the gem file to gem 'devise' without specifying the version. Ran bundle install. Then ran rail destroy devise_install since that's the command I used to install it.
*Then when I tried to reintall with rails generate devise:install it gives me this error:
gems/activerecord-3.2.8/lib/active_record/dynamic_matchers.rb:50:in method_missing': undefined methoddevise' for # (NoMethodError)*
Ryan Bigg helped me figure out the above error was caused by the user model making a reference to devise, which after the uninstall causes an error. So I removed that reference.
Now I have this error.
gems/activesupport-3.2.8/lib/active_support/inflector/methods.rb:230:in `block in constantize': uninitialized constant User (NameError)
What is this referring to?
You're getting this error because Devise isn't configured, yet your model references it. Remove the call to the devise method (or comment it out) in any model that references it.
I found the same issue when upgrading from 1.8.7 and Rails 3.0.7 to 1.9.3 and Rails 3.2.8. The solution involves removing:
gem 'active_reload'
I just installed Rails 3 and created my first app. The install of Rails3 + ruby 1.9 went very smoothly but I am missing the generate script in script/generate.
I have created a new app from scratch with no options to verify.
Any idea why this is happening and how to fix it?
all script/* commands has been removed from rails 3. You should use rails generate or rails g instead of script/generate, rails server or rails s instead of script/server and so on.
try
rails generate ...
the only script existing now is rails all others will be called as parameter of rails.
Take a look a the Ruby on Rails Guides: Getting Started with Rails