Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- gem 'jquery-datatables-rails', '~> 3.3.0'
- //
- //= require_self
- //= require jquery
- //= require jquery_ujs
- //= require dataTables/jquery.dataTables
- //= require jquery.turbolinks
- //= require turbolinks
- //= require_tree .
- *= require_tree .
- *= require dataTables/jquery.dataTables
- *= require_self
- <p id="notice"><%= notice %></p>
- <h1>Users</h1>
- <table id="users">
- <thead>
- <tr>
- <th>Name</th>
- <th>Email</th>
- <th colspan="3"></th>
- </tr>
- </thead>
- <tbody>
- <% @users.each do |user| %>
- <tr>
- <td><%= user.name %></td>
- <td><%= user.email %></td>
- <td><%= link_to 'Show', user %></td>
- <td><%= link_to 'Edit', edit_user_path(user) %></td>
- <td><%= link_to 'Destroy', user, method: :delete, data: { confirm: 'Are you sure?' } %></td>
- </tr>
- <% end %>
- </tbody>
- </table>
- <br>
- <%= link_to 'New User', new_user_path %>
- # Place all the behaviors and hooks related to the matching controller here.
- # All this logic will automatically be available in application.js.
- # You can use CoffeeScript in this file: http://coffeescript.org/
- jQuery ->
- $('#users').dataTable()
- "sPaginationType": "bootstrap"
- Rails.application.routes.draw do
- resources :users
- root 'users#index'
- # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
- end
- class UsersController < ApplicationController
- before_action :set_user, only: [:show, :edit, :update, :destroy]
- # GET /users
- # GET /users.json
- def index
- @users = User.all
- end
- # GET /users/1
- # GET /users/1.json
- def show
- end
- # GET /users/new
- def new
- @user = User.new
- end
- <link rel="stylesheet" type="text/css" href="http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.4/css/jquery.dataTables.css">
- <script>
- $(function(){
- $("#user-table").dataTable();
- });
- </script>
- require dataTables/bootstrap/3/jquery.dataTables.bootstrap
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement