im making a rails app and have created a simple navbar that works fine. I have set up devise and created a profile model which i would like users to create after they sign up, and (I believe) I have correctly made the necessary associations. As a new user signs in for the first time, I would like a "Create profile" link to show in the nav-bar using the new_profile_path, but once that specific user has created his/her profile, i would like the "create Profile" to change to "View Profile" and remain that way permanently, which should redirect to the profile_path.
The code I currently have in my nav-bar is the following:
<ul>
<li><%= link_to root_path do %>
<i class="fa fa-home"></i>Main
<% end %>
</li>
<% if current_user.profile %>
<li><%= link_to profile_path(current_user.profile) do %>
<i class="fa fa-user"></i>Employee Profile<i class="fa fa-sort-desc"></i>
<% end %>
<% end %>
<% else %>
<li><%= link_to "New Profile", new_profile_path %></li>
<ul>
<li><%= link_to "Tasks / Activities", tasks_path %></li>
<li><%= link_to "Vacations", vacations_path %></li>
</ul>
</li>
<li><%= link_to projects_path do %>
<i class="fa fa-building-o"></i>Projects<i class="fa fa-sort-desc"></i>
<% end %>
<ul>
However even after creating the new profile the link "Create Profile" still remains. How can I fix this?
Aucun commentaire:
Enregistrer un commentaire