i would like to perform an action on some of my routes, the problem is they are not in a 'resources' block because I need named methods for each. I want to be able to toggle the state of each an attribute in each item in an index type view. I wwas attempting to incorporate this tutorial.
devise_for :admins # The priority is based upon order of creation: first created -> highest priority.
root 'home#index'
resources :entries, :only => [:index, :new, :create]
namespace :admin do
namespace :entries do
match :pending, :via => [:get, :post], :collection => { :toggle_approve => :put}
match :rejected, :via => [:get, :post], :collection => { :toggle_approve => :put}
match :approved, :via => [:get, :post], :collection => { :toggle_approve => :put}
end
end
entries controller
class Admin::EntriesController < ApplicationController
expose(:entries){#entries}
def index
end
def show
end
def approved
#entries = Photo.with_approved_state
end
def pending
#entries = Photo.with_pending_state
end
def rejected
#entries = Photo.with_rejected_state
end
def toggle_approve
#a = Photo.find(params[:id])
#a.toggle!(:workflow_state)
render :nothing => true
end
rake routes
Prefix Verb URI Pattern Controller#Action
new_admin_session GET /admins/sign_in(.:format) devise/sessions#new
admin_session POST /admins/sign_in(.:format) devise/sessions#create
destroy_admin_session DELETE /admins/sign_out(.:format) devise/sessions#destroy
admin_password POST /admins/password(.:format) devise/passwords#create
new_admin_password GET /admins/password/new(.:format) devise/passwords#new
edit_admin_password GET /admins/password/edit(.:format) devise/passwords#edit
PATCH /admins/password(.:format) devise/passwords#update
PUT /admins/password(.:format) devise/passwords#update
cancel_admin_registration GET /admins/cancel(.:format) devise/registrations#cancel
admin_registration POST /admins(.:format) devise/registrations#create
new_admin_registration GET /admins/sign_up(.:format) devise/registrations#new
edit_admin_registration GET /admins/edit(.:format) devise/registrations#edit
PATCH /admins(.:format) devise/registrations#update
PUT /admins(.:format) devise/registrations#update
DELETE /admins(.:format) devise/registrations#destroy
root GET / home#index
entries GET /entries(.:format) entries#index
POST /entries(.:format) entries#create
new_entry GET /entries/new(.:format) entries#new
admin_entries_pending GET|POST /admin/entries/pending(.:format) admin/entries#pending {:collection=>{:toggle_approve_article=>:put}}
admin_entries_rejected GET|POST /admin/entries/rejected(.:format) admin/entries#rejected {:collection=>{:toggle_approve_article=>:put}}
admin_entries_approved GET|POST /admin/entries/approved(.:format) admin/entries#approved {:collection=>{:toggle_approve_article=>:put}}
I don't know where the collection option is from (I literally can't find reference to it anywhere)
Implementing non-resourceful routes is actually relatively simple:
#config/routes.rb
resources :entries, only: [:index, :new, :create] do
collection do
match :pending, via: [:get, :post] #-> domain.com/entries/pending
match :rejected, via: [:get, :post] #-> domain.com/entries/rejected
match :approved, via: [:get, :post] #-> domain.com/entries/approved
end
end
I don't understand the collection option - I don't think that belongs in your routes. Although having thought about it, I guess you're trying to make it so that if you receive a request to domain.com/entries/toggle_approve_article/pending you'll want to handle the reqeust?
If that's the case, why not just do this:
#config/routes.rb
resources :entries, only: [:index, :new, :create] do
put :toggle_approve #-> domain.com/entries/15/toggle_approve
collection do
match :pending, via: [:get, :post] #-> domain.com/entries/pending
match :rejected, via: [:get, :post] #-> domain.com/entries/rejected
match :approved, via: [:get, :post] #-> domain.com/entries/approved
end
end
i had to understand the difference between member and collections. collections are routes additional to a resource (eg, the restful actions). members are extra routes which can perform actions on their the block.
This...
resources :entries, :only => [:index, :new, :create]
namespace :admin do
resources :entries do
get :pending, on: :collection
get :approved, on: :collection
get :rejected, on: :collection
member do
get :toggle_approve_field
get :toggle_reject_field
end
end
end
yielded this rake routes
entries GET /entries(.:format) entries#index
POST /entries(.:format) entries#create
new_entry GET /entries/new(.:format) entries#new
pending_admin_entries GET /admin/entries/pending(.:format) admin/entries#pending
approved_admin_entries GET /admin/entries/approved(.:format) admin/entries#approved
rejected_admin_entries GET /admin/entries/rejected(.:format) admin/entries#rejected
toggle_approve_field_admin_entry GET /admin/entries/:id/toggle_approve_field(.:format) admin/entries#toggle_approve_field
toggle_reject_field_admin_entry GET /admin/entries/:id/toggle_reject_field(.:format) admin/entries#toggle_reject_field
admin_entries GET /admin/entries(.:format) admin/entries#index
POST /admin/entries(.:format) admin/entries#create
new_admin_entry GET /admin/entries/new(.:format) admin/entries#new
edit_admin_entry GET /admin/entries/:id/edit(.:format) admin/entries#edit
admin_entry GET /admin/entries/:id(.:format) admin/entries#show
PATCH /admin/entries/:id(.:format) admin/entries#update
PUT /admin/entries/:id(.:format) admin/entries#update
DELETE /admin/entries/:id(.:format) admin/entries#destroy
It took a lot of faffing around and I not sure I'd be able to do it upon request without more headache but I certainly have a better idea of rails routing all together. Thanks for the help from #RichPeck
Related
I am using Ruby on Rails 4.2 and I would like to route "nested" paths by using namespace or scope :module / scope :path within the block of a resource.
That is, I have the following route:
resources :users, :only => [:show]
that matches
user_path GET /users/:id(.:format) users#show
I would like to match the following paths
users_sessions_path POST /users/sessions users/sessions#create
user_session_path GET /users/:id/session users/sessions#show
delete_user_session_path GET /users/:id/session/delete users/sessions#delete
user_session_path DELETE /users/:id/session users/sessions#destroy
I read the official documentation and I tried to state something like
resources :users, :only => [:show] do
scope :module => :users do
scope :module => :sessions do
# scope :path => :sessions do
# namespace :sessions do
...
end
end
end
but no attempt has been successful. How should I state routes?
Update after the #dgilperez answer
I tried the following code
resources :users, :only => [:show] do
scope :module => :users do
resource :session, :only => [:show, :new, :create, :destroy] do
get :delete, :on => :collection, :to => 'sessions#delete'
end
end
end
that matches
delete_user_session_path GET /users/:user_id/session/delete(.:format) users/sessions#delete
new_user_session_path GET /users/:user_id/session/new(.:format) users/sessions#new
user_session_path POST /users/:user_id/session(.:format) users/sessions#create
user_session_path GET /users/:user_id/session(.:format) users/sessions#show
DELETE /users/:user_id/session(.:format) users/sessions#destroy
but I still need to map new and create actions without needing to pass the :user_id parameter. That is, I would like to map something like
new_user_session_path GET /users/session/new(.:format) users/sessions#new
user_session_path POST /users/session(.:format) users/sessions#create
I think you are overcomplicating it: you don't need to use scope or path to render nested resources. You just nest them:
resources :users, :only => [:show] do
resources :sessions
end
will render the following routes:
user_sessions GET /users/:user_id/sessions(.:format) sessions#index
POST /users/:user_id/sessions(.:format) sessions#create
new_user_session GET /users/:user_id/sessions/new(.:format) sessions#new
edit_user_session GET /users/:user_id/sessions/:id/edit(.:format) sessions#edit
user_session GET /users/:user_id/sessions/:id(.:format) sessions#show
PATCH /users/:user_id/sessions/:id(.:format) sessions#update
PUT /users/:user_id/sessions/:id(.:format) sessions#update
DELETE /users/:user_id/sessions/:id(.:format) sessions#destroy
user GET /users/:id(.:format) users#show
Those are not the routes you mention you need, but I'd like you to reconsider if you really need them like that, with namespaced controllers and custom names such as delete_user_ or you prefer to go more standard. If you really need those exact routes, let me know.
UPDATE after OP's update
To get the two routes missing you need to get them out the rested resource. I'd just write them directly like this:
resources :users, :only => [:show] do
scope :module => :users do
resource :session, :only => [:show, :destroy] do
get :delete, :on => :collection, :to => 'sessions#delete'
end
end
end
get 'users/session/new', to: 'users/sessions#new', as: :new_user_session
post 'users/session', to: 'users/sessions#create'
I have encountered a routing issue with rails. I'll explain as best as I can.
a user can use the create and index actions of the entries controller.
authenticated with devise, an admin can perform the rest of the restful actions on the entries controller. Furthermore, there are an additional three pages which I wish to add, 'pending, approved, rejected', so I added these to my entries controller like so:
class EntriesController < ApplicationController
before_action :get_entries, only: [:index, :pending, :approved, :rejected]
expose(:entry){#entry}
expose(:entries){#entries}
def create
#entry = Photo.new(params_entry)
if #entry.save
record_saved
return redirect_to(entries_path)
else
check_for_errors
return render('new')
end
end
def index
end
def new
#entry = Photo.new
end
def show
end
def pending
end
def approved
end
def rejected
end
private
def params_photo
params.require(:photo).permit!
end
def get_photos
#entries = Entry.all
end
end
(note, this controller is incomplete, but for the purposes of my question it suffices)
I am trying to configure my routes so that the path to view these pages are like
http://localhost:3000/admin/entries/pending
so I have configured my routes like so:
devise_for :admins # The priority is based upon order of creation: first created -> highest priority.
root 'home#index'
resources :entries, :only => [:index, :new]
namespace :admin do
resources :entries do
collection do
match :pending, :via => [:get, :post]
match :rejected, :via => [:get, :post]
match :approved, :via => [:get, :post]
end
end
end
except I am getting the error
uninitialized constant Admin::EntriesController
expect if i change 'admin' to plural 'admins' and configure my view path accordingly I get this error:
No route matches [GET] "/admin/entries/pending"
why is this happening? Am i making the correct use of 'namespace' and 'collection'. How do I fix this issue?
rake routes:
Prefix Verb URI Pattern Controller#Action
new_admin_session GET /admins/sign_in(.:format) devise/sessions#new
admin_session POST /admins/sign_in(.:format) devise/sessions#create
destroy_admin_session DELETE /admins/sign_out(.:format) devise/sessions#destroy
admin_password POST /admins/password(.:format) devise/passwords#create
new_admin_password GET /admins/password/new(.:format) devise/passwords#new
edit_admin_password GET /admins/password/edit(.:format) devise/passwords#edit
PATCH /admins/password(.:format) devise/passwords#update
PUT /admins/password(.:format) devise/passwords#update
cancel_admin_registration GET /admins/cancel(.:format) devise/registrations#cancel
admin_registration POST /admins(.:format) devise/registrations#create
new_admin_registration GET /admins/sign_up(.:format) devise/registrations#new
edit_admin_registration GET /admins/edit(.:format) devise/registrations#edit
PATCH /admins(.:format) devise/registrations#update
PUT /admins(.:format) devise/registrations#update
DELETE /admins(.:format) devise/registrations#destroy
root GET / home#index
entries GET /entries(.:format) entries#index
new_entry GET /entries/new(.:format) entries#new
pending_admin_entries GET|POST /admin/entries/pending(.:format) admin/entries#pending
rejected_admin_entries GET|POST /admin/entries/rejected(.:format) admin/entries#rejected
approved_admin_entries GET|POST /admin/entries/approved(.:format) admin/entries#approved
admin_entries GET /admin/entries(.:format) admin/entries#index
POST /admin/entries(.:format) admin/entries#create
new_admin_entry GET /admin/entries/new(.:format) admin/entries#new
edit_admin_entry GET /admin/entries/:id/edit(.:format) admin/entries#edit
admin_entry GET /admin/entries/:id(.:format) admin/entries#show
PATCH /admin/entries/:id(.:format) admin/entries#update
PUT /admin/entries/:id(.:format) admin/entries#update
DELETE /admin/entries/:id(.:format) admin/entries#destroy
FOLDER STRUCTURE
controllers > admin_controller.rb
admin > entries_controller.rb (this is the one with pending etc)
entries_controller.rb (this is the public one with index etc)
views > admins > index.html.erb
entries > pending.html.erb, rejected.html.erb etc
Thanks
I have two models for devise. Client, and Engineer.
The Client belongs to the Engineer. From the Engineer#show page, I'm trying to link to the client but I'm getting a devise mapping error.
Could not find devise mapping for path "/clients/10".
I have two controllers, one for devise and one regular (controllers/client/registration_controller and controllers/client_controller)
My routes file looks like this...
devise_for :clients, :controllers => {:registrations => "client/registrations"}
resources :clients, :only => [:show, :new, :create]
devise_for :engineers, :controllers => {:registrations => "engineer/registrations"}
resources :engineers, :only => [:show]
devise_scope :client do
get "clients/:id", to: "clients#show"
end
Are the resources :clients competing with the scope declaration?
For good measure my rake routes:
new_client_session GET /clients/sign_in(.:format) devise/sessions#new
client_session POST /clients/sign_in(.:format) devise/sessions#create
destroy_client_session DELETE /clients/sign_out(.:format) devise/sessions#destroy
client_password POST /clients/password(.:format) devise/passwords#create
new_client_password GET /clients/password/new(.:format) devise/passwords#new
edit_client_password GET /clients/password/edit(.:format) devise/passwords#edit
PATCH /clients/password(.:format) devise/passwords#update
PUT /clients/password(.:format) devise/passwords#update
cancel_client_registration GET /clients/cancel(.:format) client/registrations#cancel
client_registration POST /clients(.:format) client/registrations#create
new_client_registration GET /clients/sign_up(.:format) client/registrations#new
edit_client_registration GET /clients/edit(.:format) client/registrations#edit
PATCH /clients(.:format) client/registrations#update
PUT /clients(.:format) client/registrations#update
DELETE /clients(.:format) client/registrations#destroy
clients POST /clients(.:format) clients#create
new_client GET /clients/new(.:format) clients#new
client GET /clients/:id(.:format) clients#show
new_engineer_session GET /engineers/sign_in(.:format) devise/sessions#new
engineer_session POST /engineers/sign_in(.:format) devise/sessions#create
destroy_engineer_session DELETE /engineers/sign_out(.:format) devise/sessions#destroy
engineer_password POST /engineers/password(.:format) devise/passwords#create
new_engineer_password GET /engineers/password/new(.:format) devise/passwords#new
edit_engineer_password GET /engineers/password/edit(.:format) devise/passwords#edit
PATCH /engineers/password(.:format) devise/passwords#update
PUT /engineers/password(.:format) devise/passwords#update
engineer GET /engineers/:id(.:format) engineers#show
GET /clients/:id(.:format) clients#show
root GET / pages#home
pages_clients GET /pages/clients(.:format) pages#clients
pages_engineers GET /pages/engineers(.:format) pages#engineers
I'm pretty sure you should just drop your devise_scope block, since you have the following line:
resources :clients, :only => [:show, :new, :create]
This line already gives you client_path:
client GET /clients/:id(.:format) clients#show
but your devise_scope gives you a duplicate (but unnamed) path:
GET /clients/:id(.:format) clients#show
So, your routes file should look like:
devise_for :clients, :controllers => {:registrations => "client/registrations"}
resources :clients, :only => [:show, :new, :create]
devise_for :engineers, :controllers => {:registrations => "engineer/registrations"}
resources :engineers, :only => [:show]
I wish to map new_user path of the user resource to 'ROOT_DOMAIN/new' URL. My routes.rb looks something like this:
#new_user GET /users/new(.:format) users#new
# User Resource
match 'new', :to => 'users#new', via: [:get, :post]
resources :users do
collection do
match 'new', :to => 'users#new', via: [:get, :post]
end
end
So while I'm able to hit the /new URL to the desired action with
match 'new', :to => 'users#new', via: [:get, :post]
but the new_user path still leads to '/users/new'. How to remove the controller_name from the new_user method?
Your new_user_path takes you to user#new because that's how rails build resourceful routes. Have a look at rails guides to learn more. You need to pass the as: option to your routes in order to give them proper helper methods like:
post '/home' => "home#index", as: :home
This will give you two helpers home_path and home_url
Now you have
resources :users do
collection do
match 'new', :to => 'users#new', via: [:get, :post]
end
end
If you do rake routes in your terminal you'll see that new_user helpers are assigned to user#new. You need to give it a different path helper and then assign your new_user helpers to your custom route
resources :users do
collection do
match 'new', :to => 'users#new', via: [:get, :post], as: :old_new_user
end
end
and then you can use your new_user helper for your custom route
match 'new', :to => 'users#new', via: [:get, :post], as: :new_user
You can check your path helper by doing rake routes in terminal
Hi im doing a kind of blog to learn Rails, using the Getting started tutorials like these
http://guides.rubyonrails.org/getting_started.html
http://guides.rubyonrails.org/routing.html
I have manage to do the posts sections and i also do a admin/posts section, this is the problem now..
Ths system is "conflicting" and admin goes to domain.com/posts instead of admin/posts.
I think the problem is the way i build the links..
In the tutorial to link a item yo do
<h2><%= link_to post.title, post %></h2>
I have tried
<h2><%= link_to post.title, admin_post_path %></h2>
And similars but i get
undefined local variable or method `admin_post_path' for #<#<Class:0x007fe3e990ef28>:0x007fe3e6e3b508>
How does this works i mean i have done rake routes and i see there the routes, but i cant use them
new_user_session GET /users/sign_in(.:format) devise/sessions#new
user_session POST /users/sign_in(.:format) devise/sessions#create
destroy_user_session DELETE /users/sign_out(.:format) devise/sessions#destroy
user_password POST /users/password(.:format) devise/passwords#create
new_user_password GET /users/password/new(.:format) devise/passwords#new
edit_user_password GET /users/password/edit(.:format) devise/passwords#edit
PUT /users/password(.:format) devise/passwords#update
cancel_user_registration GET /users/cancel(.:format) registrations#cancel
user_registration POST /users(.:format) registrations#create
new_user_registration GET /users/sign_up(.:format) registrations#new
edit_user_registration GET /users/edit(.:format) registrations#edit
PUT /users(.:format) registrations#update
DELETE /users(.:format) registrations#destroy
users GET /admin/users(.:format) admin/users#index
POST /admin/users(.:format) admin/users#create
new_user GET /admin/users/new(.:format) admin/users#new
edit_user GET /admin/users/:id/edit(.:format) admin/users#edit
user GET /admin/users/:id(.:format) admin/users#show
PUT /admin/users/:id(.:format) admin/users#update
DELETE /admin/users/:id(.:format) admin/users#destroy
posts GET /admin/posts(.:format) admin/posts#index
POST /admin/posts(.:format) admin/posts#create
new_post GET /admin/posts/new(.:format) admin/posts#new
edit_post GET /admin/posts/:id/edit(.:format) admin/posts#edit
post GET /admin/posts/:id(.:format) admin/posts#show
PUT /admin/posts/:id(.:format) admin/posts#update
DELETE /admin/posts/:id(.:format) admin/posts#destroy
players GET /players(.:format) players#index
POST /players(.:format) players#create
new_player GET /players/new(.:format) players#new
edit_player GET /players/:id/edit(.:format) players#edit
player GET /players/:id(.:format) players#show
PUT /players/:id(.:format) players#update
DELETE /players/:id(.:format) players#destroy
player_steps GET /player_steps(.:format) player_steps#index
POST /player_steps(.:format) player_steps#create
new_player_step GET /player_steps/new(.:format) player_steps#new
edit_player_step GET /player_steps/:id/edit(.:format) player_steps#edit
player_step GET /player_steps/:id(.:format) player_steps#show
PUT /player_steps/:id(.:format) player_steps#update
DELETE /player_steps/:id(.:format) player_steps#destroy
coach_steps GET /coach_steps(.:format) coach_steps#index
POST /coach_steps(.:format) coach_steps#create
new_coach_step GET /coach_steps/new(.:format) coach_steps#new
edit_coach_step GET /coach_steps/:id/edit(.:format) coach_steps#edit
coach_step GET /coach_steps/:id(.:format) coach_steps#show
PUT /coach_steps/:id(.:format) coach_steps#update
DELETE /coach_steps/:id(.:format) coach_steps#destroy
candidates GET /candidates(.:format) candidates#index
POST /candidates(.:format) candidates#create
new_candidate GET /candidates/new(.:format) candidates#new
edit_candidate GET /candidates/:id/edit(.:format) candidates#edit
candidate GET /candidates/:id(.:format) candidates#show
PUT /candidates/:id(.:format) candidates#update
DELETE /candidates/:id(.:format) candidates#destroy
payment_notifications GET /payment_notifications(.:format) payment_notifications#show
post GET /posts/:id(.:format) posts#show
posts GET /posts(.:format) posts#index
admin_posts_path GET /admin/posts(.:format) admin/posts#index
admin_posts_path POST /admin/posts(.:format) admin/posts#index
admin_post_path GET /admin/posts/:id(.:format) admin/posts#show
new_admin_post_path GET /admin/posts/new(.:format) admin/posts#new
/*a(.:format) errors#routing
choose GET /user_type(.:format) home#user_type
root / devise/sessions#new
Also tried this
<h2><%= link_to post.title, url_for([#post]) %></h2>
this throw:::: Nil location provided. Can't build URI.
=( any documentation on doing this, ?? do you know where i can find it
Routes.rb
Consult::Application.routes.draw do
devise_for :users, :controllers => { :registrations => "registrations" }
scope "/admin" do
resources :users, :controller => 'admin/users'
resources :posts, :controller => 'admin/posts'
end
resources :players
resources :player_steps
resources :coach_steps
resources :candidates
resource :payment_notifications, :only => :show
#match 'candidates' => 'candidates#index'
#resources :posts
get '/posts/:id', to: 'posts#show', as: 'post'
get '/posts/', to: 'posts#index', as: 'posts'
get '/admin/posts/', to: 'admin/posts#index', as: 'admin_posts_path'
post '/admin/posts/', to: 'admin/posts#index', as: 'admin_posts_path'
get '/admin/posts/:id', to: 'admin/posts#show', as: 'admin_post_path'
get '/admin/posts/new', to: 'admin/posts#new', as: 'new_admin_post_path'
match '*a', :to => 'errors#routing'
# The priority is based upon order of creation:
# first created -> highest priority.
# Sample of regular route:
# match 'products/:id' => 'catalog#view'
# Keep in mind you can assign values other than :controller and :action
# Sample of named route:
# match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase
# This route can be invoked with purchase_url(:id => product.id)
# Sample resource route (maps HTTP verbs to controller actions automatically):
# resources :products
# Sample resource route with options:
# resources :products do
# member do
# get 'short'
# post 'toggle'
# end
#
# collection do
# get 'sold'
# end
# end
# Sample resource route with sub-resources:
# resources :products do
# resources :comments, :sales
# resource :seller
# end
# Sample resource route with more complex sub-resources
# resources :products do
# resources :comments
# resources :sales do
# get 'recent', :on => :collection
# end
# end
# Sample resource route within a namespace:
# namespace :admin do
# # Directs /admin/products/* to Admin::ProductsController
# # (app/controllers/admin/products_controller.rb)
# resources :products
# end
# You can have the root of your site routed with "root"
# just remember to delete public/index.html.
#root :to => "devise/sessions#new"
get 'user_type', to: 'home#user_type', as: :choose
devise_scope :user do
root :to => "devise/sessions#new"
end
# See how all your routes lay out with "rake routes"
# This is a legacy wild controller route that's not recommended for RESTful applications.
# Note: This route will make all actions in every controller accessible via GET requests.
# match ':controller(/:action(/:id))(.:format)'
end
Try using namespace, as opposed to the scope, as the namespace is much better for nesting. your routes file should look something like this.
namespace :admin do
resources :users
resources :posts
end
resources :players
resources :player_steps
resources :coach_steps
resources :candidates
resource :payment_notifications, :only => :show
#match 'candidates' => 'candidates#index'
resources :posts
you can remove
get '/posts/:id', to: 'posts#show', as: 'post'
get '/posts/', to: 'posts#index', as: 'posts'
get '/admin/posts/', to: 'admin/posts#index', as: 'admin_posts_path'
post '/admin/posts/', to: 'admin/posts#index', as: 'admin_posts_path'
get '/admin/posts/:id', to: 'admin/posts#show', as: 'admin_post_path'
get '/admin/posts/new', to: 'admin/posts#new', as: 'new_admin_post_path'
as the namespace and the resources handle their generation
full routes file should be
Consult::Application.routes.draw do
devise_for :users, :controllers => { :registrations => "registrations" }
namespace :admin do
resources :users
resources :posts
end
resources :players
resources :player_steps
resources :coach_steps
resources :candidates
resources :posts
resource :payment_notifications, :only => :show
get 'user_type', to: 'home#user_type', as: :choose
devise_scope :user do
root :to => "devise/sessions#new"
end
end