apache - Deploy rails app to non-root context - restful_auth not working -
I'm running a rail app. I do great work. When I log in to the app using restful_authentication
, then I'm taken instead of an app. strange.
It looks like I have some wrongly configured. Apart from this, there are some places where I'm putting some URL in hand, and I need access to the "Application Reference Route" (i.e. in my case) to make the URL properly.
Apache Conf:
Code> & lt; VirtualHost 69.89.3.135:80> DocumentRoot / Locally Local / Nellivedivinne 5 / html Server Name naildrivin5.com RailbusBassuri / Scalotor PassengerPull Idle Time 5 # Other things are not related & lt; / VirtualHost & gt;
passenger.cconf
:
loadmodel passenger_model / user / sher / pecergear / expat / appase 2 / mod_prepar. Pass / PassengerRuby / usr / bin / ruby PassengerLogLevel 2
/somewhere/naildrivin5.com/html/scalatour
My Rail App app
The app is okay, for authentication using restful_authentication
, except . After I log in, I'm taken to the web server root, not the application root.
How can I configure it, how can I access it at runtime, and how best can I configure my local dev environment to do this (or care about it) No)?
short answer
> Modifying the code config.action_controller.relative_url_root = "/ scalatour"
In my opinion, here is the description of your description There is a controller / route problem and the possible solution may be the next:
1) I will configure this route:
Executives :: routing :: Routes.draw do | Map | [...] map.home 'home',: admin = & gt; 'Welcome',: Action => 'Show' map.login "login",: admin = & gt; "User_sessions" ,: verb = & gt; "New" map.logout "logout",: admin = & gt; "User_sessions" ,: verb = & gt; "Destroy" map.root: login end
2) Then user session controller will look like this:
class UserSessionsController & lt; ApplicationController before_filter: require_no_user ,: only = & gt; [: New,: create] first_filter: require_user ,: only = & gt; : Def new @user_session = Make UserSession.new end def @user_session = UserSession.new (params [: user_session]) if @ user_session.save redirect_back_or_default home_path else flash [: error] = "Sorry, unknown user name or password." Render: Action = & gt; : New end-end def, current_user_session.error redirect_back_or_default login_url reset_session () and end
3) For just completion, the methods of "require_user" and "require_no_user" can be placed on the ApplicationController And may be:
def require_user current_user flash [: error] = t ("You must be logged in to access this page") redirect_to login_path return false end end def_fixed_no_user if Current_user redirect_ home_path return end of false end
best regards
config.action_controller.relative_url_root = "/ scalatour"
In my opinion, here is the description of your description There is a controller / route problem and the possible solution may be the next:
1) I will configure this route:
Executives :: routing :: Routes.draw do | Map | [...] map.home 'home',: admin = & gt; 'Welcome',: Action => 'Show' map.login "login",: admin = & gt; "User_sessions" ,: verb = & gt; "New" map.logout "logout",: admin = & gt; "User_sessions" ,: verb = & gt; "Destroy" map.root: login end
2) Then user session controller will look like this:
class UserSessionsController & lt; ApplicationController before_filter: require_no_user ,: only = & gt; [: New,: create] first_filter: require_user ,: only = & gt; : Def new @user_session = Make UserSession.new end def @user_session = UserSession.new (params [: user_session]) if @ user_session.save redirect_back_or_default home_path else flash [: error] = "Sorry, unknown user name or password." Render: Action = & gt; : New end-end def, current_user_session.error redirect_back_or_default login_url reset_session () and end
3) For just completion, the methods of "require_user" and "require_no_user" can be placed on the ApplicationController And may be:
def require_user current_user flash [: error] = t ("You must be logged in to access this page") redirect_to login_path return false end end def_fixed_no_user if Current_user redirect_ home_path return end of false end
best regards
Comments
Post a Comment