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
| en: | |
| short_names: | |
| default: | |
| male: "Mr %{surname}" | |
| female: "Ms %{surname}" | |
| full_names: | |
| default: | |
| male: "%{given_name} %{surname}" | |
| female: "%{given_name} %{surname}" | |
| not_specified: "%{given_name} %{surname}" |
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
| # Run this code inside your Rails application | |
| # | |
| # Rails 2.3: | |
| # script/runner unsafe_query_check.rb | |
| # | |
| # Rails 3.0 and later | |
| # rails runner unsafe_query_check.rb | |
| connection = ActiveRecord::Base.connection | |
| tables = connection.tables |
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
| require 'active_record' | |
| require 'logger' | |
| require 'minitest/autorun' | |
| ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: ':memory:') | |
| ActiveRecord::Base.logger = Logger.new(STDOUT) | |
| ActiveRecord::Schema.define do | |
| create_table :texts do |t| | |
| t.string :title |
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
| require 'action_controller/railtie' | |
| require 'minitest/autorun' | |
| class TestApplication < Rails::Application | |
| config.eager_load = false | |
| config.root = File.dirname(__FILE__) | |
| config.session_store :cookie_store, key: 'cookie_store_key' | |
| config.secret_token = 'secret_token' | |
| config.secret_key_base = 'secret_key_base' | |
| 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
| require 'action_controller/railtie' | |
| require 'minitest/autorun' | |
| class RoutingApp < Rails::Application | |
| config.eager_load = false | |
| config.root = File.dirname(__FILE__) | |
| config.session_store :cookie_store, key: 'session' | |
| config.secret_key_base = 'secret' | |
| 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
| require 'benchmark/ips' | |
| require 'action_controller/railtie' | |
| ROUTE = '/posts/:post_id/comments/:id.:format' | |
| PARTS = [:post_id, :id, :format] | |
| OPTIMIZED = ["/", "posts", "/", :post_id, "/", "comments", "/", :id, ".", :format] | |
| KLASS = ActionDispatch::Journey::Router::Utils | |
| def optimized_helper_1(*args) | |
| path = ROUTE.dup |
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
| require 'benchmark/ips' | |
| require 'action_controller/railtie' | |
| ROUTE = '/posts/:id' | |
| PARTS = [:id] | |
| OPTIMIZED = ["/", "posts", "/", :id] | |
| SEPARATOR = '/' | |
| KLASS = ActionDispatch::Journey::Router::Utils | |
| def optimized_helper_1(*args) |
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
| require 'action_controller/railtie' | |
| require 'minitest/autorun' | |
| class RoutingApp < Rails::Application | |
| config.eager_load = false | |
| config.root = File.dirname(__FILE__) | |
| config.session_store :cookie_store, key: 'session' | |
| config.secret_key_base = 'secret' | |
| 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
| require 'benchmark/ips' | |
| require "action_controller/railtie" | |
| class BlogApplication < Rails::Application | |
| config.eager_load = false | |
| config.root = File.dirname(__FILE__) | |
| config.session_store :cookie_store, key: 'session' | |
| config.secret_key_base = 'secret' | |
| 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
| # Feed URLs need to be explict passed as options because there is no request object | |
| atom_feed( | |
| id: "tag:weblog.rubyonrails.org,2005:/feed/atom", | |
| root_url: "http://weblog.rubyonrails.org/", | |
| url: "http://weblog.rubyonrails.org/feed/atom.xml" | |
| ) do |feed| | |
| feed.title("Riding Rails") | |
| feed.updated(@posts.first.updated_at) | |
| @posts.each do |post| |