Rails, Devise - send user back after submitting form -


when user adds products cart not mandatory him logged in. when goes created cart , hits "checkout" check if logged in:

<%=     link_to_if(current_user.nil?, "checkout", new_user_session_path)      link_to( "checkout", new_order_path, method: :get)    end %> 

so if not logged in, redirect new_user_session_path. problem after logging in being redirected index_path. , want him redirected cart. same logging up.

i using devise, should generate devise controllers , there? how should done?

note: using module current cart:

module currentcart    private      def set_cart       @cart = cart.find(session[:cart_id])     rescue activerecord::recordnotfound       @cart = cart.create       session[:cart_id] = @cart.id     end   end 

i think code you:

class applicationcontroller < actioncontroller::base   def after_sign_in_path_for(resource)      #place route here   end end 

Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -