Jump to content

The ultimate community for Ruby on Rails developers.


How do I access Users Views and Users controller with Devise ?

devise rails rails 4

  • Please log in to reply
3 replies to this topic

#1 jim_2002



  • Members
  • 13 posts

Posted 25 February 2014 - 04:00 AM

I am using Rails 4.0.2 and Devise 3.2.2 to handle user registration / authentication.

I have created a User model using -->

rails generate devise User

The question is how do I add actions to my users_controller.rb and Users Views ?


There's no actions in my users_controller.rb , and if I add a show action to my users_controller.rb , I get an error Cannot find user with id=sign_up when I try to sign up.


Please help.




class UsersController < ApplicationController

    def show
        @user = User.find(params[:id])



App::Application.routes.draw do

  resources :posts
  resources :questions
  resources :users

  get "registrations/update"
  get "pages/home"
  get "pages/privacy"
  get "pages/terms"
  get "pages/success"

  devise_scope :user do
    match "/", to: "devise/registrations#new", via: 'get'


  devise_for :users, :controllers => { :registrations => "registrations" }



#2 Bharat Soni

Bharat Soni


  • Members
  • 55 posts
  • LocationAhmedabad

Posted 25 February 2014 - 04:59 AM

Hey dude,

resources :users

The above line will generate seven restful routes for doing CRUD operation on the user controller. I have attached the link where you can find more information about it.And if you really wants to give your own route to application then remove this line from you routes.


This will defiantly work according to your application need. 



Fun with Ruby on Rails

#3 jim_2002



  • Members
  • 13 posts

Posted 25 February 2014 - 05:45 AM

Hi Bharat


Thanks for the reply.


I have tried   get "users/:id", to: "users#show"  ,  when I type http://localhost:3000/users/1   it will show the user with id = 1 but when I try to sign in using devise it says

Couldn't find User with id=sign_in

def show
@user = User.find(params[:id])



and the URL for sign in is   http://localhost:3000/users/sign_in

#4 JoezCool2



  • Members
  • 2 posts

Posted 11 March 2014 - 02:31 AM

type:   rails generate devise:views


that will install your view pages so you can edit them

Also tagged with one or more of these keywords: devise, rails, rails 4

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users