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
check out Digi_Cazter’s link then add the form after checking for signed_in?
In your create method something like this should work: