This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def per_page_select(collection, name=nil, value=nil, options={}) | |
unless collection.empty? | |
per_page = collection.first.class.per_page | |
name = name || 'per_page' | |
value = value || params[:per_page] || per_page.to_s | |
before = options[:before_default] || ["#{per_page/2}"] | |
after = options[:after_default] || ["#{per_page*2}"] | |
choices = options_for_select(before + ["#{per_page}"] + after, value) | |
select_tag name, choices, options | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def per_page_links(collection, options={}) | |
unless collection.empty? | |
separator = options[:seperator] || ' ' | |
css_class = options[:class] || 'per_page_links' | |
param = options[:param] || :per_page | |
per_page = collection.first.class.per_page | |
options = [per_page/2, per_page, per_page*2] | |
value = params[param] || per_page.to_s | |
link = lambda {|p| url_for(params.merge({param => p}))} | |
item = lambda {|p, current_value| current_value == p.to_s ? content_tag(:span, p, :class => 'current') : link_to(p, link.call(p)) } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## In application.js | |
$(document).ready(function() { | |
$('table.search_results tbody tr').click(function() { | |
alert($(this).children('a:first-child').attr('href')); | |
}); | |
}); | |
## In view.html |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Event.addBehavior({ | |
'#my_selector': function() { | |
// code that only gets executed when something with the id 'my_selector' exists | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jQuery.fn.exists = function(fn) { | |
if (this.length) fn(this); | |
return this; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## models/post.rb | |
class Post | |
include DataMapper::Resource | |
property :id, Serial | |
property :title, String, :nullable => false | |
property :body, Text | |
property :created_at, DateTime | |
property :updated_at, DateTime |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## config/router.rb | |
Merb.logger.info("Compiling routes...") | |
Merb::Router.prepare do | |
match("/(:args)", :args => /.*/). | |
to(:controller => "default", :action => 'index') | |
end | |
## app/controllers/default.rb |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## /Library/Application Support/Macromedia/mm.cfg | |
ErrorReportingEnable=1 | |
TraceOutputFileEnable=1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
No tests matched config/initializers/load_app_config.rb | |
No tests matched spec/controllers/sessions_controller_spec.rb | |
No tests matched spec/helpers/sessions_helper_spec.rb | |
No tests matched spec/models/comment_spec.rb | |
No tests matched spec/spec_helper.rb | |
No tests matched config/app_config.yml | |
No tests matched config/initializers/new_rails_defaults.rb | |
No tests matched lib/tasks/rspec.rake | |
No tests matched config/locales/en.yml | |
No tests matched spec/fixtures/comments.yml |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- ruby -*- | |
module Autotest::RedGreen | |
Autotest.send(:alias_method, :real_ruby, :ruby) | |
Autotest.send(:define_method, :ruby) do |*args| | |
real_ruby + %[ -rrubygems -e "require 'redgreen'" ] | |
end | |
# Clean the output so other modules can work correctly | |
Autotest.add_hook :ran_command do |at| |
OlderNewer