2. Add log in and log out - agentbright/rails-guide GitHub Wiki

Fix css problem

Active admin's CSS is screwing everything else up

  1. In assets/stylesheets.application.css.scss, remove these
  • *= require active_admin
  • *= require_tree .
  1. Add *= require framework_and_overrides above the line that says require_self

Add links to sign in, sign up, or log out on the navigation bar

Here are some hints:

  1. 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
  1. 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 the route 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
  1. 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.

Make the sign in and sign up pages look prettier

  1. Go to http://patterntap.com/code and find the sample code for a signup form in Foundation 5

  2. Open up the sign in view page - app/views/devise/sessions/new.html.erb

  3. Add the scss code in the same to app/assets/stylesheets/framework_and_overrides.css.scss

  4. Integrate the HTML code into the new.html.erb file. (This part is a bit tricky. You might have to improvise.)

  5. Do the same thing to the sign up page - app/views/devise/registrations/new.html.erb

Add a settings link and fix the settings layout

  1. Add a "Settings" link in HTML to the navigation bar (use the navigation_links partial)

  2. Add embedded ruby (erb) around the link so that it only shows up if a user is signed in

  3. 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
  1. 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
⚠️ **GitHub.com Fallback** ⚠️