Skip to content

Instantly share code, notes, and snippets.

@catm705
Created April 13, 2014 20:00
Show Gist options
  • Save catm705/10599928 to your computer and use it in GitHub Desktop.
Save catm705/10599928 to your computer and use it in GitHub Desktop.
partial forms
-------------------------------------------------------------
new.html.erb --> PARTIAL FORMS
-------------------------------------------------------------
<div id="main">
<h1><em>Wish U Were Here</em></h1>
<% if logged_in? %>
<p>Hi, <%= current_user.name %>!<br><br>
<img src=<%= current_user.image_url %> alt="User Profile Pic" />
<br>
<span class="tagline">Where would YOU rather be?</span>
</p>
<%= render 'admin' %>
<!-- Beginning of search form -->
<%= render partial: "search_form", locals: { favorite: @favorites.first } %>
<br>
<a href = "/favorites">Favs</a>
<br>
<a href = "/users/<%= current_user.id %>/edit"><span class="green">Edit Profile</span></a>
<br>
<a href="/logout"><span class="lavender">Logout</span></a>
</p>
<% else %>
<p>
<button><a href="/users/new">Sign Up</a></button>
<button><a href="/session/new">Login</a></button>
</p>
<% end %>
</div>
-------------------------------------------------------------
_search_form.html.erb
-------------------------------------------------------------
<div class="search">
<%= form_tag("/searches", method: "POST") do %>
<%= label_tag(:hashtag, "Cities") %>
<%= text_field_tag(:hashtag) %>
<br>
<%= submit_tag("Search") %>
<% end %>
</div>
-------------------------------------------------------------
_admin_form.html.erb
-------------------------------------------------------------
<% if current_user.admin %>
<hr />
<strong>Super Secret Admin Controls</strong>:
<p>Actually admins have no special controls</p>
<hr />
<% end %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment