Commit 1a27fac1 authored by Galen Evilla's avatar Galen Evilla

trial

parent 85c61e55
...@@ -31,6 +31,7 @@ class CandidatesController < ApplicationController ...@@ -31,6 +31,7 @@ class CandidatesController < ApplicationController
#@users = User.all #@users = User.all
if @candidate.save if @candidate.save
flash[:success] = 'Candidate was created!'
redirect_to candidate_path(@candidate.id) redirect_to candidate_path(@candidate.id)
else else
render "candidates/new.html.erb" render "candidates/new.html.erb"
......
...@@ -3,5 +3,5 @@ class Candidate < ApplicationRecord ...@@ -3,5 +3,5 @@ class Candidate < ApplicationRecord
validates :last_name, presence: true validates :last_name, presence: true
belongs_to :position belongs_to :position
belongs_to :user #belongs_to :user
end end
...@@ -4,5 +4,5 @@ class User < ApplicationRecord ...@@ -4,5 +4,5 @@ class User < ApplicationRecord
devise :database_authenticatable, :registerable, devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable :recoverable, :rememberable, :trackable, :validatable
has_many :candidates #has_many :candidates
end end
<%= simple_form_for(@candidate) do |f| %> <%= simple_form_for @candidate do |f| %>
<%= f.input :first_name %> <%= f.input :first_name %>
<%= f.input :last_name %> <%= f.input :last_name %>
<%= f.input :slogan %> <%= f.input :slogan %>
<%= f.association :position, as: :select %> <%= f.association :position %>
<%= f.submit %> <%= f.submit %>
<% end %> <% end %>
...@@ -11,11 +11,13 @@ ...@@ -11,11 +11,13 @@
<li><%= link_to p.last_name, candidate_path(p.id) %></li> <li><%= link_to p.last_name, candidate_path(p.id) %></li>
<% end %> <% end %>
</ul> </ul>
<%= link_to "View all Positions", "/positions/#{c.id}" %> <%= link_to "View all Candidates under #{c.name}" , "/positions/#{c.id}" %>
<% end %> <% end %>
<hr> <hr>
<%= link_to "View Candidates", candidates_path %>
<br>
<%= link_to "Home", root_path %> <%= link_to "Home", root_path %>
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