Basically my sign up form is not working. When I sign someone up it states that the user exists
(0.1ms) begin transaction
User Exists (0.2ms) SELECT 1 FROM "users" WHERE LOWER("users"."email") == LOWER('sambam@herpderp.edu') LIMIT 1
(0.1ms) rollback transaction
I am unsure what the issue is. Here are some of my model code and controller code.
User Model
class User < ActiveRecord::Base
attr_accessible :name, :email, :password, :password_confirmation, :biography, :avatar
has_secure_password
before_create { generate_token(:auth_token) }
validates :name, presence: true, length: { maximum: 20 }
valid_email_regex = /\A[\w+\-.]+@[a-z\d\-.]+\.edu/i
validates :email, presence: true,
format: { with: valid_email_regex },
uniqueness: { case_sensitive: false }
validates :password, length: { minimum: 6}, :on => :create
validates :password_digest, presence: { message: "Password can't be blank" }
validates :biography, presence: true, length: { maximum: 140 }
has_attached_file :avatar, :styles => { :small => "75x75>" }
end
User Controller
class UsersController < ApplicationController
def new
@user = User.new
end
def show
@user = User.find(params[:id])
end
def create
@user = User.new(params[:user])
if @user.save
redirect_to @user
else
redirect_to current_school
end
end
School Model
class School < ActiveRecord::Base
attr_accessible :name
end
School Controller
class SchoolsController < ApplicationController
def create
school = School.find(params[:name])
if school
session[:school_id] = school.id
redirect_to school_path(school)
end
end
def show
@school = School.find(params[:id])
@user =User.new
end
end
Sign Up Form
<%= form_for @user do |f| %>
<%= f.text_field :name, :class => 'modal_signinfield', :placeholder => 'Name' %>
</br></br>
<%= f.text_field :email, :class => 'modal_signinfield', :placeholder => 'Email: Must be .edu' %>
</br></br>
<%= f.password_field :password, :class => 'modal_signinfield', :placeholder => 'Password: Must be at least 6 letters' %>
</br></br>
<%= f.password_field :password_confirmation, :class => 'modal_signinfield', :placeholder => 'Renter Password' %>
<%= f.submit "Sign Up", :class => 'sign_up_button'%>
<% end %>
Because you log is showing rollback, it can be assumed that something went wrong with a callback or in your case the User model validation.
Looks like you have a validation that is required, which you are not entering in your signup form.
Either make this conditional for a new_record? or remove it.
Might be worth showing the errors in the form, so you will see what validation errors occurred.