Commit eba37af2 authored by Christiana Tan's avatar Christiana Tan

added some in models

parent 1571aa7f
......@@ -4,4 +4,12 @@ class User < ActiveRecord::Base
has_many :votes
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
validates :email
validates :encrypted_password, presence: true
validates :first_name, presence: true
validates :last_name, presence: true
validates :birthday
validates :gender
end
class Vote < ActiveRecord::Base
belongs_to :user
belongs_to :candidate
validates :user_id, presence: true, uniqueness: true
validates :candidate_id, presence: true, uniqueness: true
validates :comments
end
<%= simple_form_for(@position) do |p| %>
<%= p.input :name %>
<%= p.input :number_of_winners %>
<button class = "btn btn-success">Create new position <% p.submit %></button>
<% end %>
<%= link_to 'Cancel', positions_path, class: "btn btn-danger" %>
\ No newline at end of file
<h1>New Position</h1>
<%= form_for(@position) do |p| %>
<p>
<%= p.label "Name" %>
<%= p.text_field :name %>
</p>
<p>
<%= p.label "Number of Winners" %>
<%= p.text_field :number_of_winners %>
</p>
<button class = "btn btn-success">Create new position <% p.submit %></button>
<% end %>
<%= link_to 'Cancel', positions_path, class: "btn btn-danger" %>
<%= render "form"%>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment