Skip to content
# app/controllers/application_controller.rb
# Rescue from RoutingError
class ApplicationController < ActionController::Base
protect_from_forgery
rescue_from ActionController::RoutingError, :with => :render_routing_error
def render_routing_error
render :text => "Rescued from routing error.", :status => 404
module MyAttributes
@@attributes = []
def my_accessor(field)
@@attributes << field
attr_accessor(field)
end
def my_attributes
@@attributes
class Configuration
attr_accessor :tail_logs, :max_connections, :admin_password
attr_accessor :app_server
def app_server
@app_server_config ||= AppServer.new
yield @app_server_config if block_given?
@app_server_config
end
end
def counter(start=0, increment=1)
count = nil
Proc.new do
count = count ? count+increment : start
end
end
result = counter(2,3)
puts result.call #2
DISPLAY=:99
XVFB=/usr/bin/Xvfb
XVFBARGS="$DISPLAY -ac -screen 0 1024x768x16"
PIDFILE=/var/run/xvfb.pid
case "$1" in
start)
echo -n "Starting virtual X frame buffer: Xvfb"
/sbin/start-stop-daemon --start --quiet --pidfile $PIDFILE --make-pidfile --background --exec $XVFB -- $XVFBARGS
echo "."
;;
// HTML using 960.gs
<body>
<div class="container_16">
// more stuff
<div class="grid_4">
Sidebar
</div>
// Snippet by @ayosec on IM - Thx ayose! :)
//:ruby
//= form.input :city_id, :as => :string, :input_html => { :value => resource.city_id }
//:javascript
jQuery(function() { city_autocompleter("#resource_city_id", "#{escape_javascript resource.localized_city_long_name || params[:city]}") });
#Así he implementado tu propuesta como scope:
named_scope :normalized_name_begins_with, lambda { |term|
map = [
"âãäåāăąÁÂÃÄÅĀĂĄèééêëēĕėęěĒĔĖĘĚìíîïìĩīĭÌÍÎÏÌĨĪĬóôõöōŏőÒÓÔÕÖŌŎŐùúûüũūŭůÙÚÛÜŨŪŬŮñÑçÇüÜ".mb_chars,
"aaaaaaaaaaaaaaaeeeeeeeeeeeeeeeiiiiiiiiiiiiiiiiooooooooooooooouuuuuuuuuuuuuuuunnccuu"]
# ActiveSupport::Multibyte::Chars#tr broken?
adapted_word = "%#{term.mb_chars.split(//).map {|e| (p = map[0].index(e)) ? map[1][p,1] : e.to_s }.join.downcase}%"
{
Before('@selenium') do
if ENV["SELENIUM_HEADLESS"] == 'true'
require "headless"
@headless = Headless.new
@headless.start
end
end
After('@selenium') do
@headless.destroy if @headless.present?
Something went wrong with that request. Please try again.