Advertisement
Guest User

Untitled

a guest
May 22nd, 2018
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.99 KB | None | 0 0
  1. gem 'jquery-datatables-rails', '~> 3.3.0'
  2.  
  3. //
  4. //= require_self
  5. //= require jquery
  6. //= require jquery_ujs
  7. //= require dataTables/jquery.dataTables
  8. //= require jquery.turbolinks
  9. //= require turbolinks
  10. //= require_tree .
  11.  
  12. *= require_tree .
  13. *= require dataTables/jquery.dataTables
  14. *= require_self
  15.  
  16. <p id="notice"><%= notice %></p>
  17.  
  18. <h1>Users</h1>
  19.  
  20. <table id="users">
  21. <thead>
  22. <tr>
  23. <th>Name</th>
  24. <th>Email</th>
  25. <th colspan="3"></th>
  26. </tr>
  27. </thead>
  28. <tbody>
  29. <% @users.each do |user| %>
  30. <tr>
  31. <td><%= user.name %></td>
  32. <td><%= user.email %></td>
  33. <td><%= link_to 'Show', user %></td>
  34. <td><%= link_to 'Edit', edit_user_path(user) %></td>
  35. <td><%= link_to 'Destroy', user, method: :delete, data: { confirm: 'Are you sure?' } %></td>
  36. </tr>
  37. <% end %>
  38. </tbody>
  39. </table>
  40.  
  41. <br>
  42.  
  43. <%= link_to 'New User', new_user_path %>
  44.  
  45. # Place all the behaviors and hooks related to the matching controller here.
  46. # All this logic will automatically be available in application.js.
  47. # You can use CoffeeScript in this file: http://coffeescript.org/
  48. jQuery ->
  49. $('#users').dataTable()
  50. "sPaginationType": "bootstrap"
  51.  
  52. Rails.application.routes.draw do
  53. resources :users
  54. root 'users#index'
  55. # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
  56. end
  57.  
  58. class UsersController < ApplicationController
  59. before_action :set_user, only: [:show, :edit, :update, :destroy]
  60.  
  61. # GET /users
  62. # GET /users.json
  63. def index
  64. @users = User.all
  65. end
  66.  
  67. # GET /users/1
  68. # GET /users/1.json
  69. def show
  70. end
  71.  
  72. # GET /users/new
  73. def new
  74. @user = User.new
  75. end
  76.  
  77. <link rel="stylesheet" type="text/css" href="http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.4/css/jquery.dataTables.css">
  78.  
  79. <script>
  80. $(function(){
  81. $("#user-table").dataTable();
  82. });
  83. </script>
  84.  
  85. require dataTables/bootstrap/3/jquery.dataTables.bootstrap
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement