Skip to content

Instantly share code, notes, and snippets.

@kplandes
kplandes / _form.html
Last active August 29, 2015 14:08
Rails authentication using bcrypt
<h2>Sign up</h2>
<%= form_for @user do |f| %>
<% if @user.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@user.errors.count, "error") %> prohibited this user from being saved:</h2>
<ul>
<% @user.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
@kplandes
kplandes / seed.rb
Created October 16, 2014 20:41 — forked from changemewtf/seed.rb
# db/seed.rb
# This block will automatically empty the database every time db:seed is run.
ActiveRecord::Base.connection.tables.each do |table|
# Don't clear our migration history! Clear everything else.
if table != 'schema_migrations'
# http://stackoverflow.com/a/7758797
ActiveRecord::Base.connection.execute("TRUNCATE TABLE #{table};")
# http://stackoverflow.com/questions/2097052/rails-way-to-reset-seed-on-id-field
ActiveRecord::Base.connection.reset_pk_sequence! table