Devise Security Extension - ruby-on-rails

I'm trying to use devise security extension as it has the exact methods I'm looking for for my project.
I've followed all the instructions on the github page: https://github.com/phatworx/devise_security_extension, but when I try to run my project I get this error message:
/home/felipe/ruby-example-2.4.1/ball-consulta-de-notas-fiscais/vportal/config/initializers/devise.rb:285:in block in <top (required)>': undefined methodexpire_password_after=' for Devise:Module (NoMethodError)
I've added the method :password_expirable to my user.rb and uncommented the line # Should the password expire (e.g 3.months)
config.expire_password_after = 2.months on my devise.rb
I'm running rails 5.0.
Can you please help me?

You don't have devise_security_extension in your Gemfile.lock, also there is no gem 'devise' in your Gemfile as well.
So, just add two lines gem 'devise' and gem 'devise_security_extension' to your Gemfile. Then repeat actions from documentation:
Devise
Devise Security Extension
Hope this will help you!

Related

Problems with Rails Girls Guides's Adding Authentication with Devise

I'm very new to Rails, and I'm trying to build a user authentication system with 'devise', but I am failing. I'm following Rails Girls Guides's tutorial on adding authentication using the gem 'devise'. Once I got to step 5, which is to set up the User model, I received this error after running rake db:migrate
rake aborted!
NoMethodError: undefined method `merge!' for #<ActionDispatch::Routing::Mapper::Scope:0x007fd3397a7448>
/Users/.rvm/gems/ruby-2.1.2/gems/devise-3.0.4/lib/devise/rails/routes.rb:420:in `ensure in with_devise_exclusive_scope'
/Users/.rvm/gems/ruby-2.1.2/gems/devise-3.0.4/lib/devise/rails/routes.rb:420:in `with_devise_exclusive_scope'
/Users/.rvm/gems/ruby-2.1.2/gems/devise-3.0.4/lib/devise/rails/routes.rb:233:in `block (2 levels) in devise_for'
/Users/.rvm/gems/ruby-2.1.2/gems/devise-3.0.4/lib/devise/rails/routes.rb:336:in `block in devise_scope'
Has anyone solved this error? I've looked at all solutions such as not generating user model before installing devise, running bundle install, running rails g devise:install, and more. Nothing has worked so far when I'm trying to use devise for Rails 4.0.
Also, does anyone have recommendations on what tutorials I can follow to build an authentication system? I've tried a lot so far, and none has worked.
This looks to be a know bug with prior 3.4.0 devise.
Upgrading it should make this error go away.
To do that edit your Gemfile where you have gem "devise" <might have some other stuff in front> and change it to gem "devise", '~> 3.4.1'
then run bundle update devise and you are done.

undefined method `setup' for Devise:Module (NoMethodError)

After updating Active Admin from the gregbell/active_admin repo so it works with rails > 4.1, I get this error when I start my rails app.
undefined method `setup' for Devise:Module (NoMethodError)
The setup method is used in the devise initalizer file in the initializer folder.
Whats causing this error?
After some digging around I found this commit
Make devise soft dependency
This means that I had to add devise to my own gem file. I had removed it because activeadmin installed devise as an dependency.
Solution
Gemfile
gem 'devise', '~> 3.2'

Devise not working with Rails 4.0

I took the following steps:
rails new routing_test
in Gemfile I added devise
rails devise g user
invoke active_record
create db/migrate/20130731191051_devise_create_users.rb
create app/models/user.rb
invoke rspec
create spec/models/user_spec.rb
invoke factory_girl
create spec/factories/users.rb
insert app/models/user.rb
route devise_for :users
and then, with a simple rake db:migrate, I get the following:
rake aborted!
Rails::Application::RoutesReloader#execute_if_updated delegated to updater.execute_if_updated, but updater is nil: #<Rails::Application::RoutesReloader:0x007feb823b6120 #paths=["/Users/krg07/Developer/core2/test/dummy/config/routes.rb", "/Users/krg07/Developer/core2/config/routes.rb"], #route_sets=[#<ActionDispatch::Routing::RouteSet:0x007feb82c5e700>, #<ActionDispatch::Routing::RouteSet:0x007feb82d34440>]>
/Users/krg07/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.0/lib/rails/application/routes_reloader.rb:10:in `rescue in execute_if_updated'
/Users/krg07/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.0/lib/rails/application/routes_reloader.rb:6:in `execute_if_updated'
/Users/krg07/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.0/lib/rails/application/finisher.rb:69:in `block in <module:Finisher>'
Any idea what is going on? Thanks, really appreciate it!
I had problems getting Devise to work with Rails 4 and found that most of the issues were because I was including an older version of the gem that was not updated to work with Rails 4. Specifying the latest version of the gem helped:
gem 'devise', '3.0.0'
You may need to re-run the Devise installer after the gem has been updated.
You are not the only one to have this problem, see the following issue for more informations.

undefined method 'configure' inside the initializer? added a new ruby gem

I installed the gem Bitly into my rails app
I did it by running gem install bitly
then I manually added gem 'bitly' into my gemfile
I created this inside `config\initializers\bitly.rb
Bitly.configure do |config|
config.api_version = 3
config.login = "myusername"
config.api_key = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
end
I'm trying to get my rails server running but I get this error I've never seen before
Exiting
C:/app/config/initializers/bitly.rb:1:in `<top (
required)>': undefined method `configure' for Bitly:Module (NoMethodError)
How can I resolve this issue and make this gem work?
I am trying to use the gem inside one of my models
bitly.shorten("http://mydomain.com/article/#{id}")
Bitly is currently available in version 0.8.1 on rubygems. This version does not support Bitly.configure. I recomend you use the gem from github, until someone releases a newer version on rubygems.
The bitly line in your Gemfile should look like this:
gem "bitly", :git => 'https://github.com/philnash/bitly/'
Then do a bundle install and bitly should work the way you expect.
Edit: There is even a github issue for that error :)

undefined method rails 3.2.9 and devise 1.0.11

Error:
C:/Ruby193/lib/ruby/gems/1.9.1/gems/devise-1.0.11/lib/devise.rb:89:in '': undefined method 'weeks' for 2:Fixnum (NoMethodError)
That error is thrown whenever I try to run 'rails g devise:install' in a rails project I've been working on.
Any ideas?
P.S. requiring gem 'devise' in Gemfile and running bundle install to get the devise gem
This issue was already dealt with here. Try updating to a later devise version to fix.

Resources