2. Add log in and log out - agentbright/rails-guide GitHub Wiki
Active admin's CSS is screwing everything else up
- In assets/stylesheets.application.css.scss, remove these
*= require active_admin
*= require_tree .
- Add
*= require framework_and_overrides
above the line that saysrequire_self
Here are some hints:
- Add the links in regular old HTML
- The navigation bar code is located in app/views/layouts/_navigation.html.erb and _navigation_links.html.erb
- Remember, we aren't using Bootstrap anymore! Foundation does things differently. The Foundation docs are: http://foundation.zurb.com/docs/ - Look for the topbar in the Navigation section
- Change the links to embedded ruby.
- The format is:
<%= link_to "Text", route %>
, where the text is whatever you want the link to say, and theroute
is the correct route that takes you to where you want to go. The routes all must end in_path
- Example: <%= link_to "Homepage", index_path %>`
- Run a
rake routes
from the terminal, and look for ones similar to these:- Sign in = new session
- Sign up = new registration
- Log out = destroy session
- Wrap the links in an
if
else
statement, so that it shows "Sign In" and "Sign Up" if the user is not signed in, and it shows "Log out" if the user is signed in.
- Go to the Devise github page: https://github.com/plataformatec/devise
- Find the helper that will verify if a user is signed in
-
Go to http://patterntap.com/code and find the sample code for a signup form in Foundation 5
-
Open up the sign in view page - app/views/devise/sessions/new.html.erb
-
Add the scss code in the same to app/assets/stylesheets/framework_and_overrides.css.scss
-
Integrate the HTML code into the new.html.erb file. (This part is a bit tricky. You might have to improvise.)
-
Do the same thing to the sign up page - app/views/devise/registrations/new.html.erb
-
Add a "Settings" link in HTML to the navigation bar (use the navigation_links partial)
-
Add embedded ruby (erb) around the link so that it only shows up if a user is signed in
-
Change the link from HTML to Ruby in an ERB tag
- Run
rake routes
to find the route, which should be something like edit registration
- Make the Edit Registration view file look pretty, like you did with the sign up and sign in pages. You should be able to find the view file in app/views/devise/registrations/edit.html.erb