Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dt employer links nav bar #31

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions app/controllers/employers_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class EmployersController < ApplicationController
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this do?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I see employer_path in the other code, which will route correctly to this controller but then will crash because there's no show method in this controller. I see show and edit views for employers that can't be accessed because there are no show and edit methods.

I'd add show and edit methods here to prevent that.

def show
end

def edit
end
end
1 change: 0 additions & 1 deletion app/controllers/homes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,4 @@ def show
def goto_dashboard
redirect_to dashboard_path
end

end
5 changes: 5 additions & 0 deletions app/controllers/types_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class TypesController < ApplicationController
def show
@user = current_user
end
end
8 changes: 7 additions & 1 deletion app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,13 @@ def edit
def update
@user = current_user
@user.update(user_params)
redirect_to mind_path(@user)
if current_user.employer?
redirect_to dashboard_path
elsif current_user.mind?
redirect_to mind_path(@user)
else
redirect_to type_path
end
end

private
Expand Down
2 changes: 1 addition & 1 deletion app/models/employer.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class Employer < User
has_one :employer_profile
accepts_nested_attributes_for :employer_profile
delegate :company_name, :company_url to:, :employer_profile
delegate :company_name, :company_url, to: :employer_profile
end
12 changes: 12 additions & 0 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,16 @@ def name
email
end
end

def no_type?
%w(Employer Mind).exclude?(type)
end

def employer?
type == 'Employer'
end

def mind?
type == 'Mind'
end
end
Empty file.
Empty file.
15 changes: 11 additions & 4 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,17 @@
<div class="nav">
<ul id="navigation-menu">
<% if signed_in? %>
<li><%= link_to "View your Profile", mind_path(current_user) %></li>
<li><%= link_to "Update your Personal Information", edit_user_path(current_user) %></li>
<li><%= link_to "View your Projects", projects_path %></li>
<li><%= link_to "View your skills", mind_proficiencies_path(current_user) %></li>
<% if current_user.no_type? %>
<li><%= link_to "Choose your account type", type_path %></li>
<% elsif current_user.employer? %>
<li><%= link_to "Personal Information", edit_user_path(current_user) %></li>
<li><%= link_to "Employer Profile", employer_path(current_user) %></li>
<% elsif current_user.mind? %>
<li><%= link_to "Personal Information", edit_user_path(current_user) %></li>
<li><%= link_to "Profile", mind_path(current_user) %></li>
<li><%= link_to "Projects", projects_path %></li>
<li><%= link_to "Skills", mind_proficiencies_path(current_user) %></li>
<% end %>
<li><%= link_to 'Sign out', sign_out_path, method: :delete %></li>
<% end %>
</ul>
Expand Down
3 changes: 3 additions & 0 deletions app/views/minds/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<h2><%= @user.name %></h2>

<div>
<b><%= @user.type %></b>
</div>
<div>
Phone: <b><%= @user.telephone %></b>
</div>
Expand Down
7 changes: 7 additions & 0 deletions app/views/types/show.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<h1>Choose your account type</h1>
<%= form_for @user.becomes(User), url: user_path(@user) do |form|%>
<div>
<%= form.select :type, User::TYPES, include_blank: "User Type" %>
</div>
<%= form.submit "Update User type" %>
<% end %>
5 changes: 1 addition & 4 deletions app/views/users/edit.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
<h2>Update profile</h2>
<h4>Update contact information:</h4>

<h4>Update User Account information:</h4>
<%= form_for @user.becomes(User), url: user_path(@user) do |form|%>
<div>
<%= form.select :type, User::TYPES, include_blank: "User Type" %>
Expand All @@ -20,7 +18,6 @@
<div>
<%= form.telephone_field :telephone, placeholder: "Phone Number" %>
</div>
<h4>Update links to your personal pages:</h4>
<%= hidden_field_tag(has_profile: :true) %>
<%= form.submit "Update Personal Information" %>
</div>
Expand Down
3 changes: 3 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@

root 'homes#show'

resource :type, only: [:show]
resources :users, only: [:new, :edit, :show, :update]

resources :employers, only: [:edit, :show]

resources :minds, only: [:show, :edit, :update] do
resources :projects, only: [:new, :create, :show]
resources :proficiencies
Expand Down