Last active
August 29, 2015 14:14
-
-
Save mdunbavan/e28b866d172618d721a7 to your computer and use it in GitHub Desktop.
Code for devise users
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Started GET "/users/" for 127.0.0.1 at 2015-02-02 13:07:58 +0000 | |
| Processing by UsersController#index as JSON | |
| User Load (1.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = 42 ORDER BY "users"."id" ASC LIMIT 1 | |
| DEPRECATION WARNING: Relation#all is deprecated. If you want to eager-load a relation, you can call #load (e.g. `Post.where(published: true).load`). If you want to get an array of records from a relation, you can call #to_a (e.g. `Post.where(published: true).to_a`). (called from index at /Freelance/Current Projects/Pop Up Hub Project/build/popup-hub/app/controllers/users_controller.rb:4) | |
| User Load (1.8ms) SELECT "users".* FROM "users" ORDER BY created_at DESC | |
| Rendered users/index.html.erb within layouts/application (2.9ms) | |
| Role Load (0.7ms) SELECT "roles".* FROM "roles" WHERE "roles"."id" = $1 ORDER BY "roles"."id" ASC LIMIT 1 [["id", 2]] | |
| Rendered partials/_admin_menu.html.erb (0.3ms) | |
| Rendered partials/_components.html.erb (1.5ms) | |
| Rendered partials/_footer.html.erb (0.2ms) | |
| Completed 200 OK in 258ms (Views: 247.1ms | ActiveRecord: 3.6ms) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| GET /users/:id/edit(.:format) devise/registrations#edit | |
| 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 | |
| PATCH /users/password(.:format) devise/passwords#update | |
| PUT /users/password(.:format) devise/passwords#update | |
| cancel_user_registration GET /users/cancel(.:format) devise/registrations#cancel | |
| user_registration POST /users(.:format) devise/registrations#create | |
| new_user_registration GET /users/register(.:format) devise/registrations#new | |
| edit_user_registration GET /users/edit(.:format) devise/registrations#edit | |
| PATCH /users(.:format) devise/registrations#update | |
| PUT /users(.:format) devise/registrations#update | |
| DELETE /users(.:format) devise/registrations#destroy | |
| user_confirmation POST /users/confirmation(.:format) devise/confirmations#create | |
| new_user_confirmation GET /users/confirmation/new(.:format) devise/confirmations#new | |
| GET /users/confirmation(.:format) devise/confirmations#show | |
| admin_users GET /admin/users(.:format) admin/users#index | |
| POST /admin/users(.:format) admin/users#create | |
| new_admin_user GET /admin/users/new(.:format) admin/users#new | |
| edit_admin_user GET /admin/users/:id/edit(.:format) admin/users#edit | |
| admin_user GET /admin/users/:id(.:format) admin/users#show | |
| PATCH /admin/users/:id(.:format) admin/users#update | |
| PUT /admin/users/:id(.:format) admin/users#update | |
| DELETE /admin/users/:id(.:format) admin/users#destroy | |
| admin_destroy_user DELETE /users/:id(.:format) users#destroy | |
| ckeditor /ckeditor Ckeditor::Engine | |
| root GET / home#index | |
| users GET /users(.:format) users#index | |
| POST /users(.:format) users#create | |
| new_user GET /users/new(.:format) users#new | |
| edit_user GET /users/:id/edit(.:format) users#edit | |
| user GET /users/:id(.:format) users#show | |
| PATCH /users/:id(.:format) users#update | |
| PUT /users/:id(.:format) users#update | |
| DELETE /users/:id(.:format) users#destroy |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class UsersController < ApplicationController | |
| before_filter :authenticate_user!, only: [:index, :new, :edit, :update, :destroy] | |
| def index | |
| @users = User.order('created_at DESC').all | |
| end | |
| def show | |
| @user = User.friendly.find(params[:id]) | |
| @users_authors = User.all_authors | |
| end | |
| # get authors index in here | |
| def authors | |
| end | |
| def create | |
| @user = User.create(user_params) | |
| end | |
| def edit | |
| @user = User.find(params[:id]) | |
| end | |
| def update | |
| respond_to do |format| | |
| if @user.update(user_params) | |
| format.html { redirect_to @user, notice: 'User was successfully updated.' } | |
| format.json { head :no_content } | |
| else | |
| format.html { render action: 'edit' } | |
| format.json { render json: @user.errors, status: :unprocessable_entity } | |
| end | |
| end | |
| end | |
| def destroy | |
| @user = User.find(params[:id]) | |
| @user.destroy | |
| if @user.destroy | |
| redirect_to users_url, notice: "User deleted." | |
| end | |
| end | |
| private | |
| def user_params | |
| params.require(:user).permit(:avatar, :email, :name, :biography, :role_id, :book_id, :username, :password, :password_confirmation) | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment