Skip to content

Instantly share code, notes, and snippets.

@czepluch
Created December 29, 2013 02:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save czepluch/8166841 to your computer and use it in GitHub Desktop.
Save czepluch/8166841 to your computer and use it in GitHub Desktop.
<% if current_user == @user %>
<h2>Tilføj et indlæg:</h2>
<%= simple_form_for([@user, @user.posts.build], :html => { :class => 'form-horizontal'}) do |f| %>
<%= f.error_notification %>
<div class="form-inputs">
<%= f.input :title, :required => true, :autofocus => true %>
<%= f.input :description, :required => true %>
<%= f.input :location, :required => true %>
<%= f.input :photo %>
</div>
<div class="form-actions">
<%= f.button :submit, "Opret" %>
</div>
<% end %>
<% end %>
<!-- Button trigger modal -->
<button class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal">
Opret nyt opslag
</button>
<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h4 class="modal-title" id="myModalLabel">Opret nyt indlæg</h4>
</div>
<div class="modal-body">
<%= render 'form' %>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<% @user.posts.sort_by(&:created_at).reverse.each do |p| %>
<div class="panel panel-default">
<div class="panel-heading">
<h2 class="panel-title"><%= link_to p.title, post_path(p.id) %></h2>
</div>
<div class="panel-body">
<%= p.description %>
<% if p.photo? %>
<%= link_to p.photo.url do %>
<%= image_tag p.photo.url(:medium) %>
<% end %>
<% end %>
</div>
<div class="panel-footer"><%= p.location %> |
Oprettet for <%= time_ago_in_words(p.created_at) %> siden |
af <%= link_to p.user.email, user_path(p.user_id) %> |
<% if current_user == @user %>
<%= link_to 'Rediger', edit_user_post_path(p.user_id, p.id) %> |
<%= link_to 'Slet', user_post_path(p.user_id, p.id), method: :delete %>
<% end %>
</div>
</div>
<% end %>
<div class="page-header">
<h2>Indlæg af <%= @user.first_name %></h2>
</div>
<% if current_user == @user %>
<%= render 'modal' %>
<% end %>
<%= render 'post' %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment