ruby on rails 5 - When i signup, I want to be redirected to the article/new page but its redirecting to categories/index -


what want if user signin, gets redirected page can create new article. now, redirected page categories are.

here routes.rb

routes.rb

rails.application.routes.draw   root 'categories#index'   resources :articles     member         resources :comments, only: :create     end   end   resources :categories   devise_for :users    'auth/login'    # details on dsl available within file, see http://guides.rubyonrails.org/routing.html end 

here categories index page. categories/index

<p id="notice"><%= notice %></p>  <h1>categories</h1>  <table class="table">   <thead>     <tr>       <th>title</th>       <th>body</th>       <th>published</th>       <% if(current_user.admin?) %>         <th colspan="3">actions</th>       <% else %>         <th>actions</th>       <% end%>     </tr>   </thead>    <tbody>      <% @categories.each |category| %>       <tr>         <td><%= category.title %></td>         <td><%= category.body %></td>         <td><%= category.published%></td>         <% if(current_user.admin?) %>             <td><%= link_to 'show', category, class: 'btn btn-default' %></td>             <td><%= link_to 'edit', edit_category_path(category), class: 'btn btn-primary' %></td>             <td><%= link_to 'destroy', category, method: :delete, data: { confirm: 'are sure?' }, class: 'btn btn-danger' %></td>          <% else %>             <td><%= link_to 'show', category, class: 'btn btn-default' %></td>          <% end %>       </tr>     <% end %>   </tbody> </table> <%= paginate @categories %>  <br> <%if current_user.admin? %>   <%= link_to 'new category', new_category_path %> <% end %> 

you have given root 'categories#index' in routes.rb file. if want root article/new have root 'article#new'.

if using devise authentication have write in routes.rb :-

   devise_scope :user     authenticated :user       root to: "article#new", as: :authenticated_root     end     unauthenticated       root to: 'devise/sessions#new', as: :unauthenticated_root     end   end 

Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -