0
0
Ruby on Railsframework~20 mins

Devise gem overview in Ruby on Rails - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Devise Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
What is the primary purpose of the Devise gem in Rails?
Devise is a popular gem used in Rails applications. What main feature does it provide?
AIt is used to optimize SQL queries for better performance.
BIt helps with database migrations and schema changes.
CIt manages user authentication and handles sign up, login, and logout.
DIt provides tools for styling Rails views with CSS.
Attempts:
2 left
💡 Hint
Think about what users need to do to access a website securely.
component_behavior
intermediate
2:00remaining
What happens when you add devise :database_authenticatable to a User model?
In a Rails app using Devise, adding devise :database_authenticatable to the User model enables what behavior?
AIt allows users to sign in using their email and encrypted password stored in the database.
BIt automatically sends welcome emails to new users.
CIt enables OAuth login with third-party providers like Google or Facebook.
DIt creates an admin dashboard for managing users.
Attempts:
2 left
💡 Hint
Think about how users prove their identity with a password.
lifecycle
advanced
2:00remaining
Which Devise callback runs after a user successfully signs in?
Devise provides callbacks during the user authentication lifecycle. Which callback is triggered right after a successful sign-in?
Abefore_authentication
Bbefore_sign_out
Cafter_sign_up_path_for
Dafter_sign_in_path_for
Attempts:
2 left
💡 Hint
This callback helps decide where to send the user after login.
📝 Syntax
advanced
2:00remaining
Which code snippet correctly adds the :confirmable module to Devise in the User model?
You want users to confirm their email address after signing up. Which code correctly enables this feature in the User model?
Ruby on Rails
class User < ApplicationRecord
  # Add devise modules here
end
Adevise :database_authenticatable, :registerable, confirmable: true
Bdevise :database_authenticatable, :registerable, :confirmable
Celbamrifnoc: ,elbaretsiger: ,elbatacitnehtua_esabatad: esived
Ddevise :database_authenticatable, :registerable, confirmable
Attempts:
2 left
💡 Hint
Devise modules are symbols separated by commas inside the devise method call.
🔧 Debug
expert
3:00remaining
Why does Devise raise a MissingSecretKeyError in production?
You deployed your Rails app with Devise to production, but it raises Devise::MissingSecretKeyError. What is the most likely cause?
AThe <code>secret_key_base</code> is not set or accessible in the production environment.
BThe database migration for users was not run.
CThe User model is missing the <code>devise</code> call.
DThe routes for Devise were not added in <code>config/routes.rb</code>.
Attempts:
2 left
💡 Hint
Devise needs a secret key to encrypt tokens and sessions securely.