Skip to content

Instantly share code, notes, and snippets.

@redrory
Created April 27, 2013 23:49
Show Gist options
  • Save redrory/5475225 to your computer and use it in GitHub Desktop.
Save redrory/5475225 to your computer and use it in GitHub Desktop.
Trying to show different partials
<li id="<%#= client.id %>">
<table class = "table table-striped table-hover">
<tr>
<th>Company</th>
<th>Project Name</th>
<th>Due Date</th>
<th>Amount</th>
<th>Days Left</th>
<th>Status</th>
<th>Action</th>
</tr>
<% @total = 0%>
<% @feed_items.each do |client|%>
<% @days_left = (client.due_date - Date.today).to_i %>
<% @total = @total + client.amount %>
<% unless @days_left > 3 %>
<tr class = "error">
<% else %>
<tr>
<% end %>
<td><%= client.name %></td>
<td><%= client.project_name %></td>
<td><%= client.due_date.to_formatted_s(:long) %></td>
<td><%= number_to_currency(client.amount) %></td>
<td><%= @days_left %> </td>
<% unless client.reminder == "0" || client.reminder == nil %>
<td> <i class="icon-bullhorn"></i></td>
<% else %>
<td></td>
<% end %>
<td>
<%= link_to "", edit_client_path(client), :class => "icon-edit" %>
<%= link_to "", client, method: :delete, data: {confirm: "You sure"}, title: client.project_name, :class => "icon-remove" %>
<%= link_to "", client_paid_path(client),:class => "icon-ok"%>
<%= link_to "", "#", :class => "clickme icon-envelope" %>
</td>
</tr>
<div id ="reminder_form">
<%= form_for(client) do |f| %>
<%= render 'shared/error_messages', object: f.object %>
<div class="e_field">
<p> Set Reminder for <%= client.name %>
<%= f.email_field :email, placeholder: "email address to send reminder" %>
<!-- Daily <%#= check_box("client", "reminder", {}, "Daily")%> -->
<% @Rem.each do |r| %>
<%= check_box_tag "client[reminder][]", r.name %>
<%= r.name %>
<% end %>
<%= f.submit "Set ", class: "btn btn-small btn-primary"%>
</p>
<% end %>
</div>
</div>
</li>
<% end %>
</table>
<p class = "lead text-right"> Total = <%= number_to_currency(@total)%></p>
<script type="text/javascript">
$(document).ready(function (){
$('.e_field').hide();
$('.clickme').click(function() {
var $div = $('.e_field').eq($(this).index('.clickme')); // get relevant div
$div.show(); // show the relevant div
});
});
</script>
<div class="tabbable"> <!-- Only required for left/right tabs -->
<ul class="nav nav-tabs">
<li class="active"><a href="#tab1" data-toggle="tab">Unpaid Jobs</a></li>
<li><a href="#tab2" data-toggle="tab">Paid Jobs</a></li>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="tab1">
<%= render :partial => "shared/feed_item", :feed_items => @feed_items %>
<b>Feed_items</b> <%= @feed_items.inspect%>
</div>
<div class="tab-pane" id="tab2">
<%= render :partial => "shared/feed_item", :feed_items => @paid_items %>
<!-- When I inspect @paid_items, I see the right results, but it doesn't reflect in tables -->
<!-- If I purpose screw up the variable name, it still calls @feed_items, i'm assuming straight from the controller -->
<b>Paid Items</b> <%= @paid_items.inspect%>
</div>
</div>
</div>
def home
if signed_in?
@client = current_user.clients.build
#@feed_items = current_user.feed.paginate(page: params[:page])
@feed_items = current_user.feed.find_all_by_paid(false)
@paid_items = current_user.feed.find_all_by_paid(true)
@one = current_user.feed.find_all_by_paid(true)
@Rem = Rem.all
@emails = current_user.feed.where(:last_email => nil)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment