Complete Building Employee Homepage Feature
In this lesson we'll finish implementing the homepage design for users.
Guide Tasks
  • Read Tutorial
  • Watch Guide Video
Video locked
This video is viewable to users with a Bottega Bootcamp license

Now that we've completed the first part of our employee homepage, let's move to the second. This one is going to be just another way to create a new post.

So, open _employee.html.erb and include a standard button called "Request overtime approval" that'll take the employee to the new post creation page.

<!-- app/views/static/_employee.html.erb -->

<div class='pending-homepage employee-blocks'>
  <h3>Request Overtime</h3>

  <%= link_to "Request Overtime Approval", new_post_path, class: 'btn btn-primary btn-block btn-lg' %>
</div>

And this is how it looks on the browser.

large

Here, I don't like the title "Add New Entry" in the navigation tab, so let's go to _nav.html.erb and change it to "Request Overtime."

That's all done. There's one more thing we need to change before we wrap up this section. If you notice, the "Pending your confirmation" block continues to be displayed even when the user has no pending confirmation. This is bad design, so we have to make the entire block to disappear if a user has no pending confirmations.

It's pretty straightforward to implement. We just have to put the button inside an if block.

<!-- app/views/static/_employee.html.erb -->

<% if @pending_audit_confirmations.count > 0 %>
  <div class='pending-homepage employee-blocks'>
    <h3>Pending Your Confirmation</h3>

    <%= render partial: 'pending_audit_confirmations', locals: { pending_audit_confirmations: @pending_audit_confirmations } %>
  </div>
<% end %>

So, that's working!

Before testing this in the browser make sure to run bundle exec rake db:setup to clear out and seed the application with new data. And as you'll see, everything should be working properly.

Resources