Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You can use <code>authenticated</code> and <code>unauthenticated</code> resources.</p> <p>Like this:</p> <pre><code>authenticated :user do root to: "users#show", as: :authenticated_root, via: :get end unauthenticated do root 'site#index' end </code></pre> <p>Then in your users controller you'll need to make sure to check for the devise helper <code>current_user</code> instead of the <code>id</code> because you aren't passing one.</p> <p>like</p> <pre><code>if params[:id] @user = User.find params[:id] else @user = current_user end </code></pre> <p>If you don't want users to be able to access this route, its easier to manage in the controller. Just modify the if statement, something like</p> <pre><code>if params[:id] if current_user @user = current_user else flash[:notice] = "This page is not available" redirect_to root_path end else @user = current_user end </code></pre> <p>Updated routes:</p> <pre><code>devise_for :users, :path =&gt; '', :path_names =&gt; { :sign_in =&gt; 'login', :sign_out =&gt; 'logout', :password =&gt; 'password', :confirmation =&gt; 'verification', :unlock =&gt; 'unblock', :registration =&gt; 'signup', :sign_up =&gt; 'new' } get 'login' =&gt; 'users/login' devise_scope :user do get 'login', to: 'devise/sessions#new' get 'users/login', to: 'devise/sessions#new' get 'logout', to: 'devise/sessions#destroy' get 'signup', to: 'devise/registrations#new' get 'password', to: 'devise/passwords#new' match 'users/secret', to: "devise/passwords#create", via: :post match 'sessions/user', to: 'devise/sessions#create', via: :post match 'users/signup', to: 'devise/registrations#create', via: :post match 'users/signup', to: 'devise/registrations#create', via: :post end #resources :users resources :sessions # Authenticated Users: authenticated :user do root to: "users#show", as: :authenticated_root end # Non-Authenticated Users root to: 'site#index' get '', to: 'users#show', as: 'user' get 'edit', to: 'users#edit' as: 'user' </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload