Advertisement
Guest User

Untitled

a guest
Jul 29th, 2016
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.38 KB | None | 0 0
  1. #Intersect App
  2.  
  3. This application was done on Ruby on Rails and was designed to allow users to create an account so that they could find, do, and share workouts with people from all over. It allowed them to track which workouts they had done and leave a comment if they felt it would help others who had yet to complete it.
  4.  
  5. ###Manipulating User Data
  6. This code was where I took the data from the database and manipulated it to display properly on the page. Converting UTC time stamps into a readable string for a user to digest is a bit tricky.
  7.  
  8. ```
  9. <div class="content_workout">
  10. <h5><strong class="custom_heading"><%= @workout.name.upcase %></strong> - <span class="yellow_font"><%= @workout.difficulty %> / 10 Difficulty</span></h5>
  11. <p><strong>Description: </strong> <%= @workout.description %></p>
  12. <p><strong>Date Created: </strong><%= @workout.created_at.localtime.strftime('%a %b %d, %Y') %></p>
  13. <p><strong>Type: </strong><%= @workout.workout_type %></p>
  14. <p><strong>Duration: </strong><%= @workout.duration %> minutes</p>
  15.  
  16. <div class="button_container_workout">
  17. <form class="home_button" action="/users/sign_in">
  18. <input class="standard_button" type="submit" value="DO WORKOUT">
  19. </form>
  20.  
  21. <form class="home_button" action="/users/sign_up">
  22. <input class="standard_button" type="submit" value="LIKE!">
  23. </form>
  24. </div>
  25. </div>
  26.  
  27. ```
  28.  
  29. ###Creating a Table of Workouts
  30. This block of code took all of the workouts in our database and prints them onto the page in a dynamic and digestable form. The style of this section is something I am proud of.
  31.  
  32. ```
  33. <div class="comment_container_workout">
  34. <hr />
  35. <%= form_for ([@workout, @workout.comments.build]) do |f| %>
  36. <%= f.text_field :text_field, :class => 'comment_input', placeholder: "Comment", autocomplete: "off" %>
  37. <%= f.hidden_field :user_id, :value => current_user.id %>
  38. <%= f.hidden_field :workout_id, :value => @workout.id %>
  39. <%= f.submit 'POST', :class => 'standard_button' %>
  40. <% end %>
  41.  
  42.  
  43. <% @comments.each do |comment| %>
  44. <p><%= comment.text_field %></p>
  45. <p class="comment_author">by: <%= comment.user.first_name.downcase %> <%= comment.user.last_name.downcase %> <%= link_to "Delete comment", delete_comment_path(comment.id), method: :delete, class: 'comment_link' %></p>
  46. <% end %>
  47. </div>
  48.  
  49. ```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement