Skip to content

Instantly share code, notes, and snippets.

View chebyte's full-sized avatar
🤡
smile

maurotorres chebyte

🤡
smile
View GitHub Profile
function parse_git_dirty {
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*"
}
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/[\1$(parse_git_dirty)]/"
}
export PS1='\u@\h \[\033[1;33m\]\w\[\033[0m\]$(parse_git_branch)$ '
# En el controlador
@users = User.paginate(:page => params[:page])
# En la vista
<%= will_paginate(@users) %>
<div class="pagination"><span class="disabled prev_page">« Previous</span> <span class="current">1</span> <a href="/users?page=2" rel="next">2</a> <a href="/users?page=3">3</a> <a href="/users?page=2" class="next_page" rel="next">Next »</a></div>
.pagination {
padding: 3px;
margin: 3px;
}
.pagination a {
padding: 2px 5px 2px 5px;
margin: 2px;
border: 1px solid #aaaadd;
text-decoration: none;
color: #666;
<ul class="pagination">
<li class="previous"><a href="/users?page=1">« Previous</a></li>
<li><a href="/users?page=1">1</a></li>
<li class="current">2</li>
<li><a href="/users?page=3">3</a></li>
<li class="next"><a href="/users?page=3">Next »</a></li>
</ul>
<ul class="pagination">
<li class="previous"><a href="/users?page=1">« Previous</a></li>
<li><a href="/users?page=1">1</a></li>
<li class="current">2</li>
<li><a href="/users?page=3">3</a></li>
<li class="next"><a href="/users?page=3">Next »</a></li>
</ul>
class VbsLinkRenderer < WillPaginate::LinkRenderer
def to_html
links = @options[:page_links] ? windowed_links : []
links.unshift(page_link_or_span(@collection.previous_page, 'prev', @options[:previous_label]))
links.push(page_link_or_span(@collection.next_page, 'next', @options[:next_label]))
html = links.join(@options[:separator])
<%= will_paginate(@users, :renderer => PaginationListLinkRenderer) %>
<%= will_paginate(@users, :renderer => PaginationListLinkRenderer) %>
WillPaginate::ViewHelpers.pagination_options[:renderer] = 'PaginationListLinkRenderer'