Skip to content

Instantly share code, notes, and snippets.

View sharnik's full-sized avatar
📱
Developing mobile apps

Wojciech Ogrodowczyk sharnik

📱
Developing mobile apps
View GitHub Profile
class PaginationListLinkRenderer < WillPaginate::LinkRenderer
def to_html
links = @options[:page_links] ? windowed_links : []
html = links.join(@options[:separator])
@options[:container] ? @template.content_tag(:ul, html, html_attributes) : html
end
protected
def windowed_links
class PaginationListLinkRenderer < WillPaginate::LinkRenderer
def to_html
links = @options[:page_links] ? windowed_links : []
html = links.join(@options[:separator])
@options[:container] ? @template.content_tag(:ul, html, html_attributes) : html
end
protected
def windowed_links
<div class="pagination">
<span class="disabled prev_page">&laquo; Previous</span>
<span class="current">1</span>
<a href="/users/john/komentarze?page=2" rel="next">2</a>
<a href="/users/john/komentarze?page=3">3</a>
<a href="/users/john/komentarze?page=4">4</a>
<a href="/users/john/komentarze?page=2" class="next_page" rel="next">Next &raquo;</a>
</div>
<ul class="pagination">
<li class="select">1</li>
<li><a href="/users/john/komentarze?page=2">2</a></li>
<li><a href="/users/john/komentarze?page=3">3</a></li>
<li><a href="/users/john/komentarze?page=4">4</a></li>
</ul>
<ul class="pagination">
<li class="select">1</li>
<li><a href="/users/john/komentarze?page=2">2</a></li>
<li><a href="/users/john/komentarze?page=3">3</a></li>
<li><a href="/users/john/komentarze?page=4">4</a></li>
</ul>
will_paginate @comments,
:prev_label => '&laquo; poprzedni',
:next_label => 'następny &raquo;'
{"email" => "moj@mejl.pl", "amp;name" => "Stefan"}
module ActionController
class AbstractRequest
class << self
def parse_query_parameters(query_string)
return {} if query_string.blank?
query_string = query_string.gsub("amp;", "")
pairs = query_string.split('&').collect do |chunk|
next if chunk.empty?
key, value = chunk.split('=', 2)
<%= cache('your_cache_key', :expires_in => 3.hours) do %>
<!-- computation heavy stuff goes here %>
<% end %>
config.middleware.use Rack::Bug,
:secret_key => "moje_tajne_haslo",
:panel_classes => [
Rack::Bug::TimerPanel,
Rack::Bug::ActiveRecordPanel,
Rack::Bug::CachePanel,
Rack::Bug::SQLPanel,
Rack::Bug::TemplatesPanel,
Rack::Bug::LogPanel,
Rack::Bug::MemoryPanel