I am trying to make a login page for my rails application that looks like "www.domain.com" and when you log in you are still in the domain "www.domain.com". Is there a way that I can map 2 different actions to the same URL using routes. Twitter does it this way, you log in to twitter.com, and after you logged in, you are still on twitter.com.
You cannot do this by simply changing the routes, but you can make some kind of conditional statement in your controller.
def index if logged_in render :action => 'show' else render :action => 'new' end end def show ... end def new ... end
, .
URL.
routes.rb
map.resources :landings # let assume that, home page corresponds to landings/index map.root :controller => "landings", :action => "index"
UserSessionsController
def create @user_session = UserSession.new(params[:user_session]) if @user_session.save redirect_to root_url else render :action => :new end end
Source: https://habr.com/ru/post/1737045/More articles:Is it common practice to add keywords to html markup for SEO? - htmlCreating CMS Extensible by Plugins - Examples - phpWhy should I use PropertyProxyValidator? ASP.NET - validationWhat is the equivalent of Lua Twisted Python, Eventmachine for Ruby, NIO for Java, etc.? - twistedGetting a generic pointer to a derived class when the base class inherits from enable_shared_from_this - c ++https://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1737046/how-to-persist-and-load-an-object-which-conforms-to-nscoding-protocol&usg=ALkJrhjrf4-c11Z7i7NaqAyT68JDRGqmTAOperator overload F #: (+) for user type - operator-overloadingdecrypt excel files - pythonJava Swing: write a cross-platform application (mostly CRUD) - javaIs Oracle AQ / Streams any use in my situation? - oracleAll Articles