Skip to content

Instantly share code, notes, and snippets.

@josephrexme
Last active August 29, 2015 14:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save josephrexme/729d851a12d6f0a49126 to your computer and use it in GitHub Desktop.
Save josephrexme/729d851a12d6f0a49126 to your computer and use it in GitHub Desktop.
Form_for breaking on encounter of <td>
<html><head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="author" content="ostrich-dev">
<link href="http://fonts.googleapis.com/css?family=Roboto+Condensed:400,300" rel="stylesheet" type="text/css">
<link rel="author" href="http://ostrich-dev.com">
<link rel="shortcut icon" href="http://localhost:3000/favicon.ico">
<title>vitabiotics</title>
<link data-turbolinks-track="true" href="/assets/application.css" media="all" rel="stylesheet">
<meta content="authenticity_token" name="csrf-param">
<meta content="6X/iN2C0Mpdt873RNgSPjDHgRcFbjKxKB3+0ZZWgUEQ=" name="csrf-token">
</head>
<body>
<!-- Sidebar -->
<section class="sidebar">
<header title="vitabiotics"><a href="http://localhost:3000/">Vitabiotics</a></header>
<img src="/uploads/geeky-bl4ckdu5t.jpg" alt="Joseph Rex">
<h3 title="Joseph">
Joseph
</h3>
<h4 title="Rex">
Rex
</h4>
<ul>
<li class="">
<a href="/dashboard">
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="20" height="20" viewBox="0 0 32 32">
<g id="icomoon-ignore"></g>
<path d="M16 0c-8.837 0-16 7.163-16 16s7.163 16 16 16 16-7.163 16-16-7.163-16-16-16zM9.464 26.067c0.347-0.957 0.536-1.99 0.536-3.067 0-3.886-2.463-7.197-5.913-8.456 0.319-2.654 1.508-5.109 3.427-7.029 2.267-2.266 5.28-3.515 8.485-3.515s6.219 1.248 8.485 3.515c1.92 1.92 3.108 4.375 3.428 7.029-3.45 1.26-5.913 4.57-5.913 8.456 0 1.077 0.189 2.11 0.536 3.067-1.928 1.258-4.18 1.933-6.536 1.933s-4.608-0.675-6.536-1.933zM17.242 20.031c0.434 0.109 0.758 0.503 0.758 0.969v2c0 0.55-0.45 1-1 1h-2c-0.55 0-1-0.45-1-1v-2c0-0.466 0.324-0.86 0.758-0.969l0.742-14.031h1l0.742 14.031z"></path>
</svg>
Dashboard
</a> </li>
<li class="">
<a href="/dashboard/attendance-records">
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="24" height="20" viewBox="0 0 36 32">
<path d="M7 4h-6c-0.55 0-1 0.45-1 1v22c0 0.55 0.45 1 1 1h6c0.55 0 1-0.45 1-1v-22c0-0.55-0.45-1-1-1zM6 10h-4v-2h4v2z"></path>
<path d="M17 4h-6c-0.55 0-1 0.45-1 1v22c0 0.55 0.45 1 1 1h6c0.55 0 1-0.45 1-1v-22c0-0.55-0.45-1-1-1zM16 10h-4v-2h4v2z"></path>
<path d="M23.909 5.546l-5.358 2.7c-0.491 0.247-0.691 0.852-0.443 1.343l8.999 17.861c0.247 0.491 0.852 0.691 1.343 0.443l5.358-2.7c0.491-0.247 0.691-0.852 0.443-1.343l-8.999-17.861c-0.247-0.491-0.852-0.691-1.343-0.443z"></path>
<path d="M29 27c0 0.552-0.448 1-1 1s-1-0.448-1-1c0-0.552 0.448-1 1-1s1 0.448 1 1z"></path>
</svg>
Records
</a> </li>
<li class="">
<a href="/dashboard/company">
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="20" height="20" viewBox="0 0 32 32">
<g id="icomoon-ignore"></g>
<path d="M0 32h16v-32h-16v32zM10 4h4v4h-4v-4zM10 12h4v4h-4v-4zM10 20h4v4h-4v-4zM2 4h4v4h-4v-4zM2 12h4v4h-4v-4zM2 20h4v4h-4v-4zM18 10h14v2h-14zM18 32h4v-8h6v8h4v-18h-14z"></path>
</svg>
Company Settings
</a> </li>
<li class="">
<a href="/dashboard/user">
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="20" height="20" viewBox="0 0 32 32">
<g id="icomoon-ignore"></g>
<path d="M26.5 32h-21c-0.828 0-1.5-0.672-1.5-1.5 0-2.152 0.908-4.756 2.43-6.967 1.272-1.847 2.834-3.238 4.521-4.050-0.744-0.676-1.384-1.501-1.891-2.441-0.813-1.508-1.242-3.252-1.242-5.041 0-2.488 0.819-4.838 2.306-6.618 1.552-1.858 3.639-2.881 5.876-2.881s4.324 1.023 5.876 2.882c1.487 1.78 2.306 4.131 2.306 6.618 0 1.79-0.43 3.533-1.242 5.041-0.507 0.941-1.147 1.765-1.891 2.441 1.687 0.812 3.25 2.203 4.521 4.050 1.521 2.21 2.43 4.815 2.43 6.967 0 0.828-0.672 1.5-1.5 1.5zM7.19 29h17.62c-0.288-1.229-0.891-2.575-1.711-3.766-1.295-1.882-2.912-3.113-4.551-3.466-0.691-0.149-1.184-0.76-1.184-1.466v-1.072c0-0.539 0.29-1.037 0.758-1.304 1.859-1.057 3.060-3.383 3.060-5.926 0-3.584-2.325-6.5-5.182-6.5s-5.182 2.916-5.182 6.5c0 2.543 1.201 4.869 3.060 5.926 0.469 0.267 0.758 0.764 0.758 1.304v1.072c0 0.707-0.493 1.317-1.184 1.466-1.639 0.353-3.256 1.584-4.551 3.466-0.82 1.191-1.423 2.537-1.711 3.766z"></path>
</svg>
User Settings
</a> </li>
<li class="">
<a href="/dashboard/preferences">
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="20" height="20" viewBox="0 0 32 32">
<g id="icomoon-ignore"></g>
<path d="M11.366 22.564l1.291-1.807-1.414-1.414-1.807 1.291c-0.335-0.187-0.694-0.337-1.071-0.444l-0.365-2.19h-2l-0.365 2.19c-0.377 0.107-0.736 0.256-1.071 0.444l-1.807-1.291-1.414 1.414 1.291 1.807c-0.187 0.335-0.337 0.694-0.443 1.071l-2.19 0.365v2l2.19 0.365c0.107 0.377 0.256 0.736 0.444 1.071l-1.291 1.807 1.414 1.414 1.807-1.291c0.335 0.187 0.694 0.337 1.071 0.444l0.365 2.19h2l0.365-2.19c0.377-0.107 0.736-0.256 1.071-0.444l1.807 1.291 1.414-1.414-1.291-1.807c0.187-0.335 0.337-0.694 0.444-1.071l2.19-0.365v-2l-2.19-0.365c-0.107-0.377-0.256-0.736-0.444-1.071zM7 27c-1.105 0-2-0.895-2-2s0.895-2 2-2 2 0.895 2 2-0.895 2-2 2zM32 12v-2l-2.106-0.383c-0.039-0.251-0.088-0.499-0.148-0.743l1.799-1.159-0.765-1.848-2.092 0.452c-0.132-0.216-0.273-0.426-0.422-0.629l1.219-1.761-1.414-1.414-1.761 1.219c-0.203-0.149-0.413-0.29-0.629-0.422l0.452-2.092-1.848-0.765-1.159 1.799c-0.244-0.059-0.492-0.109-0.743-0.148l-0.383-2.106h-2l-0.383 2.106c-0.251 0.039-0.499 0.088-0.743 0.148l-1.159-1.799-1.848 0.765 0.452 2.092c-0.216 0.132-0.426 0.273-0.629 0.422l-1.761-1.219-1.414 1.414 1.219 1.761c-0.149 0.203-0.29 0.413-0.422 0.629l-2.092-0.452-0.765 1.848 1.799 1.159c-0.059 0.244-0.109 0.492-0.148 0.743l-2.106 0.383v2l2.106 0.383c0.039 0.251 0.088 0.499 0.148 0.743l-1.799 1.159 0.765 1.848 2.092-0.452c0.132 0.216 0.273 0.426 0.422 0.629l-1.219 1.761 1.414 1.414 1.761-1.219c0.203 0.149 0.413 0.29 0.629 0.422l-0.452 2.092 1.848 0.765 1.159-1.799c0.244 0.059 0.492 0.109 0.743 0.148l0.383 2.106h2l0.383-2.106c0.251-0.039 0.499-0.088 0.743-0.148l1.159 1.799 1.848-0.765-0.452-2.092c0.216-0.132 0.426-0.273 0.629-0.422l1.761 1.219 1.414-1.414-1.219-1.761c0.149-0.203 0.29-0.413 0.422-0.629l2.092 0.452 0.765-1.848-1.799-1.159c0.059-0.244 0.109-0.492 0.148-0.743l2.106-0.383zM21 15.35c-2.402 0-4.35-1.948-4.35-4.35s1.948-4.35 4.35-4.35 4.35 1.948 4.35 4.35c0 2.402-1.948 4.35-4.35 4.35z"></path>
</svg>
Preferences
</a> </li>
</ul>
</section>
<!-- End of Sidebar -->
<section class="board">
<header>
<form action=""><input type="text" name="search" placeholder="search..."></form>
<ul>
<li title="Settings">
<a href="/dashboard/preferences">
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="20" height="20" viewBox="0 0 32 32">
<g id="icomoon-ignore"></g>
<path d="M14 4v-0.5c0-0.825-0.675-1.5-1.5-1.5h-5c-0.825 0-1.5 0.675-1.5 1.5v0.5h-6v4h6v0.5c0 0.825 0.675 1.5 1.5 1.5h5c0.825 0 1.5-0.675 1.5-1.5v-0.5h18v-4h-18zM8 8v-4h4v4h-4zM26 13.5c0-0.825-0.675-1.5-1.5-1.5h-5c-0.825 0-1.5 0.675-1.5 1.5v0.5h-18v4h18v0.5c0 0.825 0.675 1.5 1.5 1.5h5c0.825 0 1.5-0.675 1.5-1.5v-0.5h6v-4h-6v-0.5zM20 18v-4h4v4h-4zM14 23.5c0-0.825-0.675-1.5-1.5-1.5h-5c-0.825 0-1.5 0.675-1.5 1.5v0.5h-6v4h6v0.5c0 0.825 0.675 1.5 1.5 1.5h5c0.825 0 1.5-0.675 1.5-1.5v-0.5h18v-4h-18v-0.5zM8 28v-4h4v4h-4z"></path>
</svg>
</a> </li>
<li title="Notifications">
<small></small>
<a href="">
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="20" height="20" viewBox="0 0 32 32">
<g id="icomoon-ignore"></g>
<path d="M32.047 25c0-9-8-7-8-14 0-0.58-0.056-1.076-0.158-1.498-0.526-3.532-2.88-6.366-5.93-7.23 0.027-0.123 0.041-0.251 0.041-0.382 0-1.040-0.9-1.891-2-1.891s-2 0.851-2 1.891c0 0.131 0.014 0.258 0.041 0.382-3.421 0.969-5.966 4.416-6.039 8.545-0.001 0.060-0.002 0.121-0.002 0.183 0 7-8 5-8 14 0 2.382 5.331 4.375 12.468 4.878 0.673 1.263 2.002 2.122 3.532 2.122s2.86-0.86 3.532-2.122c7.137-0.503 12.468-2.495 12.468-4.878 0-0.007-0.001-0.014-0.001-0.021l0.048 0.021zM25.82 26.691c-1.695 0.452-3.692 0.777-5.837 0.958-0.178-2.044-1.893-3.648-3.984-3.648s-3.805 1.604-3.984 3.648c-2.144-0.18-4.142-0.506-5.837-0.958-2.332-0.622-3.447-1.318-3.855-1.691 0.408-0.372 1.523-1.068 3.855-1.691 2.712-0.724 6.199-1.122 9.82-1.122s7.109 0.398 9.82 1.122c2.332 0.622 3.447 1.318 3.855 1.691-0.408 0.372-1.523 1.068-3.855 1.691z"></path>
</svg>
</a>
</li>
<li title="Sign Out">
<a href="/logout">
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="20" height="20" viewBox="0 0 32 32">
<g id="icomoon-ignore"></g>
<path d="M31.317 9.82l-3.16-3.159c-0.775-0.775-2.043-2.043-2.818-2.818l-3.16-3.159c-0.775-0.775-2.155-0.911-3.067-0.304l-8.639 5.759c-0.912 0.608-1.257 1.907-0.767 2.887l2.203 4.405c0.067 0.135 0.145 0.278 0.231 0.427l-11.142 11.142-1 7h6v-2h4v-4h4v-4h4v-2.225c0.2 0.119 0.392 0.226 0.569 0.314l4.405 2.203c0.98 0.49 2.279 0.145 2.887-0.767l5.759-8.639c0.608-0.912 0.471-2.292-0.304-3.066zM4.707 26.707l-1.414-1.414 9.737-9.737 1.414 1.414-9.737 9.737zM28.657 13.243l-1.414 1.414c-0.389 0.389-1.025 0.389-1.414 0l-8.485-8.485c-0.389-0.389-0.389-1.025 0-1.414l1.414-1.414c0.389-0.389 1.025-0.389 1.414 0l8.485 8.485c0.389 0.389 0.389 1.025 0 1.414z"></path>
</svg>
</a> </li>
</ul>
</header>
<section class="row-doubles" id="user-list">
<h2 class="inline-block">User Accounts</h2>
<div style="display:none"><input name="utf8" type="hidden" value="✓"><input name="_method" type="hidden" value="patch"><input name="authenticity_token" type="hidden" value="6X/iN2C0Mpdt873RNgSPjDHgRcFbjKxKB3+0ZZWgUEQ="></div><div style="display:none"><input name="utf8" type="hidden" value="✓"><input name="_method" type="hidden" value="patch"><input name="authenticity_token" type="hidden" value="6X/iN2C0Mpdt873RNgSPjDHgRcFbjKxKB3+0ZZWgUEQ="></div><div style="display:none"><input name="utf8" type="hidden" value="✓"><input name="_method" type="hidden" value="patch"><input name="authenticity_token" type="hidden" value="6X/iN2C0Mpdt873RNgSPjDHgRcFbjKxKB3+0ZZWgUEQ="></div><table class="listings">
<thead>
<tr>
<th><input class="checkbox" type="checkbox"></th>
<th>Email</th>
<th>Name</th>
<th>Role</th>
<th>Created</th>
<th>Last updated</th>
</tr>
</thead>
<tbody class="list"><tr class="user-data">
<td><input type="checkbox"></td>
<form accept-charset="UTF-8" action="/users/3" class="edit_user" id="edit_user_3" method="post"></form>
<td>
<strong>manager@vitabiotics.com</strong>
<span>Edit</span><span>Delete</span>
<p style="display: block;"><input id="user_email" name="user[email]" type="email" value="manager@vitabiotics.com"></p>
</td>
<td><p style="display: block;"><input id="user_name" name="user[name]" type="text" value=""></p></td>
<td>administrator
<p style="display: block;"><select id="user_role" name="user[role]"><option selected="selected" value="administrator">Administrator</option>
<option value="manager">Manager</option></select></p>
</td>
<td>2014-12-28 05:25:18 UTC<p style="display: block;"><input class="btn" name="commit" type="submit" value="update"></p></td>
<td>2014-12-28 05:25:18 UTC</td>
</tr><tr class="user-data">
<td><input type="checkbox"></td>
<form accept-charset="UTF-8" action="/users/2" class="edit_user" id="edit_user_2" method="post"></form>
<td>
<strong>john@vitabiotics.com</strong>
<span>Edit</span><span>Delete</span>
<p><input id="user_email" name="user[email]" type="email" value="john@vitabiotics.com"></p>
</td>
<td><p><input id="user_name" name="user[name]" type="text" value=""></p></td>
<td>administrator
<p><select id="user_role" name="user[role]"><option selected="selected" value="administrator">Administrator</option>
<option value="manager">Manager</option></select></p>
</td>
<td>2014-12-28 05:25:06 UTC<p><input class="btn" name="commit" type="submit" value="update"></p></td>
<td>2014-12-28 05:25:06 UTC</td>
</tr><tr class="user-data">
<td><input type="checkbox"></td>
<form accept-charset="UTF-8" action="/users/1" class="edit_user" id="edit_user_1" method="post"></form>
<td>
<strong>admin@vitabiotics.com</strong>
<span>Edit</span><span>Delete</span>
<p><input id="user_email" name="user[email]" type="email" value="admin@vitabiotics.com"></p>
</td>
<td>Joseph Rex<p><input id="user_name" name="user[name]" type="text" value="Joseph Rex"></p></td>
<td>administrator
<p><select id="user_role" name="user[role]"><option selected="selected" value="administrator">Administrator</option>
<option value="manager">Manager</option></select></p>
</td>
<td>2014-12-27 22:30:21 UTC<p><input class="btn" name="commit" type="submit" value="update"></p></td>
<td>2014-12-28 20:45:40 UTC</td>
</tr></tbody>
</table>
<ul class="pagination"><li class="active"><a class="page" href='javascript:function Z(){Z=""}Z()'>1</a></li></ul>
</section>
</section>
<!-- Scripts -->
<script data-turbolinks-track="true" src="/assets/application.js"></script>
<div><div class="sweet-overlay" tabindex="-1"></div><div class="sweet-alert" tabindex="-1"><div class="icon error"><span class="x-mark"><span class="line left"></span><span class="line right"></span></span></div><div class="icon warning"> <span class="body"></span> <span class="dot"></span> </div> <div class="icon info"></div> <div class="icon success"> <span class="line tip"></span> <span class="line long"></span> <div class="placeholder"></div> <div class="fix"></div> </div> <div class="icon custom"></div> <h2>Title</h2><p>Text</p><button class="cancel" tabindex="2">Cancel</button><button class="confirm" tabindex="1">OK</button></div></div></body></html>
<section class="row-doubles" id="user-list">
<h2 class="inline-block">User Accounts</h2>
<table class="listings">
<thead>
<tr>
<th><input class="checkbox" type="checkbox"></th>
<th>Email</th>
<th>Name</th>
<th>Role</th>
<th>Created</th>
<th>Last updated</th>
</tr>
</thead>
<tbody class="list">
<% @users.all.map do |user| %>
<tr class="user-data">
<% if current_user.role == 'administrator' %>
<td><input type="checkbox"></td>
<%= form_for update_user("#{user.id}") do |f| %>
<td>
<strong><%= user.email %></strong>
<span>Edit</span><span>Delete</span>
<p><%= email_field :user, :email, value: "#{user.email}" %></p>
</td>
<td><%= user.name %><p><%= f.text_field :name, value: "#{user.name}" %></p></td>
<td><%= user.role %>
<p><%= f.select :role, options_for_select([['Administrator','administrator'],['Manager','manager']], "#{user.role}") %></p>
</td>
<td><%= user.created_at %><p><%= f.submit :update, class: 'btn' %></p></td>
<td><%= user.updated_at %></td>
<% end %>
<% else %>
<td><input type="checkbox"></td>
<td><strong><%= user.email %></strong></td>
<td><%= user.name %></td>
<td><%= user.role %></td>
<td><%= user.created_at %></td>
<td><%= user.updated_at %></td>
<% end %>
</tr>
<% end %>
</tbody>
</table>
<ul class="pagination"></ul>
</section>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="author" content="ostrich-dev">
<link href='http://fonts.googleapis.com/css?family=Roboto+Condensed:400,300' rel='stylesheet' type='text/css'>
<link rel="author" href="http://ostrich-dev.com">
<link rel="shortcut icon" href="http://localhost:3000/favicon.ico">
<title>vitabiotics</title>
<link data-turbolinks-track="true" href="/assets/application.css" media="all" rel="stylesheet" />
<meta content="authenticity_token" name="csrf-param" />
<meta content="6X/iN2C0Mpdt873RNgSPjDHgRcFbjKxKB3+0ZZWgUEQ=" name="csrf-token" />
</head>
<body>
<!-- Sidebar -->
<section class="sidebar">
<header title="vitabiotics"><a href="http://localhost:3000/">Vitabiotics</a></header>
<img src="/uploads/geeky-bl4ckdu5t.jpg" alt="Joseph Rex">
<h3 title="Joseph">
Joseph
</h3>
<h4 title="Rex">
Rex
</h4>
<ul>
<li class="">
<a href="/dashboard">
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="20" height="20" viewBox="0 0 32 32">
<g id="icomoon-ignore"></g>
<path d="M16 0c-8.837 0-16 7.163-16 16s7.163 16 16 16 16-7.163 16-16-7.163-16-16-16zM9.464 26.067c0.347-0.957 0.536-1.99 0.536-3.067 0-3.886-2.463-7.197-5.913-8.456 0.319-2.654 1.508-5.109 3.427-7.029 2.267-2.266 5.28-3.515 8.485-3.515s6.219 1.248 8.485 3.515c1.92 1.92 3.108 4.375 3.428 7.029-3.45 1.26-5.913 4.57-5.913 8.456 0 1.077 0.189 2.11 0.536 3.067-1.928 1.258-4.18 1.933-6.536 1.933s-4.608-0.675-6.536-1.933zM17.242 20.031c0.434 0.109 0.758 0.503 0.758 0.969v2c0 0.55-0.45 1-1 1h-2c-0.55 0-1-0.45-1-1v-2c0-0.466 0.324-0.86 0.758-0.969l0.742-14.031h1l0.742 14.031z"></path>
</svg>
Dashboard
</a> </li>
<li class="">
<a href="/dashboard/attendance-records">
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="24" height="20" viewBox="0 0 36 32">
<path d="M7 4h-6c-0.55 0-1 0.45-1 1v22c0 0.55 0.45 1 1 1h6c0.55 0 1-0.45 1-1v-22c0-0.55-0.45-1-1-1zM6 10h-4v-2h4v2z"></path>
<path d="M17 4h-6c-0.55 0-1 0.45-1 1v22c0 0.55 0.45 1 1 1h6c0.55 0 1-0.45 1-1v-22c0-0.55-0.45-1-1-1zM16 10h-4v-2h4v2z"></path>
<path d="M23.909 5.546l-5.358 2.7c-0.491 0.247-0.691 0.852-0.443 1.343l8.999 17.861c0.247 0.491 0.852 0.691 1.343 0.443l5.358-2.7c0.491-0.247 0.691-0.852 0.443-1.343l-8.999-17.861c-0.247-0.491-0.852-0.691-1.343-0.443z"></path>
<path d="M29 27c0 0.552-0.448 1-1 1s-1-0.448-1-1c0-0.552 0.448-1 1-1s1 0.448 1 1z"></path>
</svg>
Records
</a> </li>
<li class="">
<a href="/dashboard/company">
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="20" height="20" viewBox="0 0 32 32">
<g id="icomoon-ignore"></g>
<path d="M0 32h16v-32h-16v32zM10 4h4v4h-4v-4zM10 12h4v4h-4v-4zM10 20h4v4h-4v-4zM2 4h4v4h-4v-4zM2 12h4v4h-4v-4zM2 20h4v4h-4v-4zM18 10h14v2h-14zM18 32h4v-8h6v8h4v-18h-14z"></path>
</svg>
Company Settings
</a> </li>
<li class="">
<a href="/dashboard/user">
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="20" height="20" viewBox="0 0 32 32">
<g id="icomoon-ignore"></g>
<path d="M26.5 32h-21c-0.828 0-1.5-0.672-1.5-1.5 0-2.152 0.908-4.756 2.43-6.967 1.272-1.847 2.834-3.238 4.521-4.050-0.744-0.676-1.384-1.501-1.891-2.441-0.813-1.508-1.242-3.252-1.242-5.041 0-2.488 0.819-4.838 2.306-6.618 1.552-1.858 3.639-2.881 5.876-2.881s4.324 1.023 5.876 2.882c1.487 1.78 2.306 4.131 2.306 6.618 0 1.79-0.43 3.533-1.242 5.041-0.507 0.941-1.147 1.765-1.891 2.441 1.687 0.812 3.25 2.203 4.521 4.050 1.521 2.21 2.43 4.815 2.43 6.967 0 0.828-0.672 1.5-1.5 1.5zM7.19 29h17.62c-0.288-1.229-0.891-2.575-1.711-3.766-1.295-1.882-2.912-3.113-4.551-3.466-0.691-0.149-1.184-0.76-1.184-1.466v-1.072c0-0.539 0.29-1.037 0.758-1.304 1.859-1.057 3.060-3.383 3.060-5.926 0-3.584-2.325-6.5-5.182-6.5s-5.182 2.916-5.182 6.5c0 2.543 1.201 4.869 3.060 5.926 0.469 0.267 0.758 0.764 0.758 1.304v1.072c0 0.707-0.493 1.317-1.184 1.466-1.639 0.353-3.256 1.584-4.551 3.466-0.82 1.191-1.423 2.537-1.711 3.766z"></path>
</svg>
User Settings
</a> </li>
<li class="">
<a href="/dashboard/preferences">
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="20" height="20" viewBox="0 0 32 32">
<g id="icomoon-ignore"></g>
<path d="M11.366 22.564l1.291-1.807-1.414-1.414-1.807 1.291c-0.335-0.187-0.694-0.337-1.071-0.444l-0.365-2.19h-2l-0.365 2.19c-0.377 0.107-0.736 0.256-1.071 0.444l-1.807-1.291-1.414 1.414 1.291 1.807c-0.187 0.335-0.337 0.694-0.443 1.071l-2.19 0.365v2l2.19 0.365c0.107 0.377 0.256 0.736 0.444 1.071l-1.291 1.807 1.414 1.414 1.807-1.291c0.335 0.187 0.694 0.337 1.071 0.444l0.365 2.19h2l0.365-2.19c0.377-0.107 0.736-0.256 1.071-0.444l1.807 1.291 1.414-1.414-1.291-1.807c0.187-0.335 0.337-0.694 0.444-1.071l2.19-0.365v-2l-2.19-0.365c-0.107-0.377-0.256-0.736-0.444-1.071zM7 27c-1.105 0-2-0.895-2-2s0.895-2 2-2 2 0.895 2 2-0.895 2-2 2zM32 12v-2l-2.106-0.383c-0.039-0.251-0.088-0.499-0.148-0.743l1.799-1.159-0.765-1.848-2.092 0.452c-0.132-0.216-0.273-0.426-0.422-0.629l1.219-1.761-1.414-1.414-1.761 1.219c-0.203-0.149-0.413-0.29-0.629-0.422l0.452-2.092-1.848-0.765-1.159 1.799c-0.244-0.059-0.492-0.109-0.743-0.148l-0.383-2.106h-2l-0.383 2.106c-0.251 0.039-0.499 0.088-0.743 0.148l-1.159-1.799-1.848 0.765 0.452 2.092c-0.216 0.132-0.426 0.273-0.629 0.422l-1.761-1.219-1.414 1.414 1.219 1.761c-0.149 0.203-0.29 0.413-0.422 0.629l-2.092-0.452-0.765 1.848 1.799 1.159c-0.059 0.244-0.109 0.492-0.148 0.743l-2.106 0.383v2l2.106 0.383c0.039 0.251 0.088 0.499 0.148 0.743l-1.799 1.159 0.765 1.848 2.092-0.452c0.132 0.216 0.273 0.426 0.422 0.629l-1.219 1.761 1.414 1.414 1.761-1.219c0.203 0.149 0.413 0.29 0.629 0.422l-0.452 2.092 1.848 0.765 1.159-1.799c0.244 0.059 0.492 0.109 0.743 0.148l0.383 2.106h2l0.383-2.106c0.251-0.039 0.499-0.088 0.743-0.148l1.159 1.799 1.848-0.765-0.452-2.092c0.216-0.132 0.426-0.273 0.629-0.422l1.761 1.219 1.414-1.414-1.219-1.761c0.149-0.203 0.29-0.413 0.422-0.629l2.092 0.452 0.765-1.848-1.799-1.159c0.059-0.244 0.109-0.492 0.148-0.743l2.106-0.383zM21 15.35c-2.402 0-4.35-1.948-4.35-4.35s1.948-4.35 4.35-4.35 4.35 1.948 4.35 4.35c0 2.402-1.948 4.35-4.35 4.35z"></path>
</svg>
Preferences
</a> </li>
</ul>
</section>
<!-- End of Sidebar -->
<section class="board">
<header>
<form action=""><input type="text" name="search" placeholder="search..."></form>
<ul>
<li title="Settings">
<a href="/dashboard/preferences">
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="20" height="20" viewBox="0 0 32 32">
<g id="icomoon-ignore"></g>
<path d="M14 4v-0.5c0-0.825-0.675-1.5-1.5-1.5h-5c-0.825 0-1.5 0.675-1.5 1.5v0.5h-6v4h6v0.5c0 0.825 0.675 1.5 1.5 1.5h5c0.825 0 1.5-0.675 1.5-1.5v-0.5h18v-4h-18zM8 8v-4h4v4h-4zM26 13.5c0-0.825-0.675-1.5-1.5-1.5h-5c-0.825 0-1.5 0.675-1.5 1.5v0.5h-18v4h18v0.5c0 0.825 0.675 1.5 1.5 1.5h5c0.825 0 1.5-0.675 1.5-1.5v-0.5h6v-4h-6v-0.5zM20 18v-4h4v4h-4zM14 23.5c0-0.825-0.675-1.5-1.5-1.5h-5c-0.825 0-1.5 0.675-1.5 1.5v0.5h-6v4h6v0.5c0 0.825 0.675 1.5 1.5 1.5h5c0.825 0 1.5-0.675 1.5-1.5v-0.5h18v-4h-18v-0.5zM8 28v-4h4v4h-4z"></path>
</svg>
</a> </li>
<li title="Notifications">
<small></small>
<a href="">
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="20" height="20" viewBox="0 0 32 32">
<g id="icomoon-ignore"></g>
<path d="M32.047 25c0-9-8-7-8-14 0-0.58-0.056-1.076-0.158-1.498-0.526-3.532-2.88-6.366-5.93-7.23 0.027-0.123 0.041-0.251 0.041-0.382 0-1.040-0.9-1.891-2-1.891s-2 0.851-2 1.891c0 0.131 0.014 0.258 0.041 0.382-3.421 0.969-5.966 4.416-6.039 8.545-0.001 0.060-0.002 0.121-0.002 0.183 0 7-8 5-8 14 0 2.382 5.331 4.375 12.468 4.878 0.673 1.263 2.002 2.122 3.532 2.122s2.86-0.86 3.532-2.122c7.137-0.503 12.468-2.495 12.468-4.878 0-0.007-0.001-0.014-0.001-0.021l0.048 0.021zM25.82 26.691c-1.695 0.452-3.692 0.777-5.837 0.958-0.178-2.044-1.893-3.648-3.984-3.648s-3.805 1.604-3.984 3.648c-2.144-0.18-4.142-0.506-5.837-0.958-2.332-0.622-3.447-1.318-3.855-1.691 0.408-0.372 1.523-1.068 3.855-1.691 2.712-0.724 6.199-1.122 9.82-1.122s7.109 0.398 9.82 1.122c2.332 0.622 3.447 1.318 3.855 1.691-0.408 0.372-1.523 1.068-3.855 1.691z"></path>
</svg>
</a>
</li>
<li title="Sign Out">
<a href="/logout">
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="20" height="20" viewBox="0 0 32 32">
<g id="icomoon-ignore"></g>
<path d="M31.317 9.82l-3.16-3.159c-0.775-0.775-2.043-2.043-2.818-2.818l-3.16-3.159c-0.775-0.775-2.155-0.911-3.067-0.304l-8.639 5.759c-0.912 0.608-1.257 1.907-0.767 2.887l2.203 4.405c0.067 0.135 0.145 0.278 0.231 0.427l-11.142 11.142-1 7h6v-2h4v-4h4v-4h4v-2.225c0.2 0.119 0.392 0.226 0.569 0.314l4.405 2.203c0.98 0.49 2.279 0.145 2.887-0.767l5.759-8.639c0.608-0.912 0.471-2.292-0.304-3.066zM4.707 26.707l-1.414-1.414 9.737-9.737 1.414 1.414-9.737 9.737zM28.657 13.243l-1.414 1.414c-0.389 0.389-1.025 0.389-1.414 0l-8.485-8.485c-0.389-0.389-0.389-1.025 0-1.414l1.414-1.414c0.389-0.389 1.025-0.389 1.414 0l8.485 8.485c0.389 0.389 0.389 1.025 0 1.414z"></path>
</svg>
</a> </li>
</ul>
</header>
<section class="row-doubles" id="user-list">
<h2 class="inline-block">User Accounts</h2>
<table class="listings">
<thead>
<tr>
<th><input class="checkbox" type="checkbox"></th>
<th>Email</th>
<th>Name</th>
<th>Role</th>
<th>Created</th>
<th>Last updated</th>
</tr>
</thead>
<tbody class="list">
<tr class="user-data">
<td><input type="checkbox"></td>
<form accept-charset="UTF-8" action="/users/3" class="edit_user" id="edit_user_3" method="post"><div style="display:none"><input name="utf8" type="hidden" value="&#x2713;" /><input name="_method" type="hidden" value="patch" /><input name="authenticity_token" type="hidden" value="6X/iN2C0Mpdt873RNgSPjDHgRcFbjKxKB3+0ZZWgUEQ=" /></div>
<td>
<strong>manager@vitabiotics.com</strong>
<span>Edit</span><span>Delete</span>
<p><input id="user_email" name="user[email]" type="email" value="manager@vitabiotics.com" /></p>
</td>
<td><p><input id="user_name" name="user[name]" type="text" value="" /></p></td>
<td>administrator
<p><select id="user_role" name="user[role]"><option selected="selected" value="administrator">Administrator</option>
<option value="manager">Manager</option></select></p>
</td>
<td>2014-12-28 05:25:18 UTC<p><input class="btn" name="commit" type="submit" value="update" /></p></td>
<td>2014-12-28 05:25:18 UTC</td>
</form> </tr>
<tr class="user-data">
<td><input type="checkbox"></td>
<form accept-charset="UTF-8" action="/users/2" class="edit_user" id="edit_user_2" method="post"><div style="display:none"><input name="utf8" type="hidden" value="&#x2713;" /><input name="_method" type="hidden" value="patch" /><input name="authenticity_token" type="hidden" value="6X/iN2C0Mpdt873RNgSPjDHgRcFbjKxKB3+0ZZWgUEQ=" /></div>
<td>
<strong>john@vitabiotics.com</strong>
<span>Edit</span><span>Delete</span>
<p><input id="user_email" name="user[email]" type="email" value="john@vitabiotics.com" /></p>
</td>
<td><p><input id="user_name" name="user[name]" type="text" value="" /></p></td>
<td>administrator
<p><select id="user_role" name="user[role]"><option selected="selected" value="administrator">Administrator</option>
<option value="manager">Manager</option></select></p>
</td>
<td>2014-12-28 05:25:06 UTC<p><input class="btn" name="commit" type="submit" value="update" /></p></td>
<td>2014-12-28 05:25:06 UTC</td>
</form> </tr>
<tr class="user-data">
<td><input type="checkbox"></td>
<form accept-charset="UTF-8" action="/users/1" class="edit_user" id="edit_user_1" method="post"><div style="display:none"><input name="utf8" type="hidden" value="&#x2713;" /><input name="_method" type="hidden" value="patch" /><input name="authenticity_token" type="hidden" value="6X/iN2C0Mpdt873RNgSPjDHgRcFbjKxKB3+0ZZWgUEQ=" /></div>
<td>
<strong>admin@vitabiotics.com</strong>
<span>Edit</span><span>Delete</span>
<p><input id="user_email" name="user[email]" type="email" value="admin@vitabiotics.com" /></p>
</td>
<td>Joseph Rex<p><input id="user_name" name="user[name]" type="text" value="Joseph Rex" /></p></td>
<td>administrator
<p><select id="user_role" name="user[role]"><option selected="selected" value="administrator">Administrator</option>
<option value="manager">Manager</option></select></p>
</td>
<td>2014-12-27 22:30:21 UTC<p><input class="btn" name="commit" type="submit" value="update" /></p></td>
<td>2014-12-28 20:45:40 UTC</td>
</form> </tr>
</tbody>
</table>
<ul class="pagination"></ul>
</section>
</section>
<!-- Scripts -->
<script data-turbolinks-track="true" src="/assets/application.js"></script>
</body>
</html>
class UsersController < ApplicationController
before_filter :init
before_action :require_login
def index
@users = User.all.order('created_at DESC')
@users.all.map do |user|
instance_variable_set("@user#{user.id}", User.find(user.id))
end
end
def create
@user = User.new(user_params)
if @user.save
redirect_to :back, notice: "Account Created"
else
redirect_to :back, notice: "Failed to create account"
end
end
def update
@user = User.find(current_user.id)
uploaded_io = params[:user][:avatar]
password_salt = current_user.password_salt
pwd = user_params[:current].present? ? BCrypt::Engine.hash_secret(user_params[:current], password_salt) : current_user.password_hash
confirmed = true if pwd == current_user.password_hash
if user_params[:current].present? && !confirmed
redirect_to :back, alert: "Current Password is not valid"
else
if uploaded_io.present?
File.open(Rails.root.join('public','uploads', uploaded_io.original_filename), 'wb') do |file|
file.write(uploaded_io.read)
end
end
@user.name = "#{user_params[:firstname]} #{user_params[:lastname]}"
@user.email = user_params[:email]
@user.avatar = uploaded_io.original_filename if uploaded_io.present?
@user.password = user_params[:password] if user_params[:password] != ""
if @user.save
redirect_to :back, alert: "Account Updated"
else
redirect_to :back, alert: "Account Update Failed"
end
end
end
def destroy
end
private
def user_params
params.require(:user).permit(:email, :role, :password, :avatar, :firstname, :lastname, :current)
end
def init
@preferences = Preference.find(1)
end
def require_login
unless session[:user_id].present?
redirect_to root_url
end
end
end
module UsersHelper
def update_user(arg)
instance_variable_get("@user#{arg}")
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment