Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7950919
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T02:24:45+00:00 2026-06-04T02:24:45+00:00

I am using Devise gem for authentication in my current project. I am stuck

  • 0

I am using Devise gem for authentication in my current project. I am stuck with an issue to use devise registration and login form inside my custom form and I am not sure how to implementation it in my project.

This custom form has 20-25 fields and if current user is not logged in, I want to include device login and registration forms as well on same view. So when user hit save button of the form, controller will first authenticate or register the user and then later save the form.

class BookController < ApplicationController
    def new
        @book = Shop::Book.new
    end

    def create
        @book = Book.new(params[:book])

        # TODO::
        # validate / register the user if not currently logged-in

        if @book.save
            redirect_to :action => 'list'
        else
            @subjects = Subject.find(:all)
            render :action => 'new'
        end   
    end
end
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T02:24:46+00:00Added an answer on June 4, 2026 at 2:24 am

    check out Digi_Cazter’s link then add the form after checking for signed_in?

    In your create method something like this should work:

       @user = User.new(:email => 'test@example.com', :password => 'password',    #values from params   
       :password_confirmation => 'password')
       @user.save
       sign_in @user  #if you want to do this
    
           if @book.save
                redirect_to :action => 'list'
            else
                @subjects = Subject.find(:all)
                render :action => 'new'
            end 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using the devise gem for authentication and have the following before_filter in
Devise, the authentication gem for Ruby based on Warden (another auth gem) does not
I am using the devise gem to make authentication work in my app. Here's
I using devise gem for registration but i have problem. my table include: first_name,
I'm using devise gem for login functionality in my Rails3 application.The gem as provides
I'm using Devise for user registration. It automatically gives me the form for a
I've employed devise as the user-authentication gem for my rails web-app. Using this pre-generated
I am developing a Rails 3 app using the Devise gem for authentication. I'm
i'm currently buidling my own blog using rails 3. and use devise gem for
I'm using Devise authentication gem with Rails. How to display the message from devise.en.yml:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.