This file contains 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
= form_for(@order, url:order_url, method:'POST') do |order_form| | |
= error_messages_for :order | |
= order_form.text_field :name | |
And more parent form fields... | |
= order_form.fields_for :order_lines, @order.order_lines do |lines_form| | |
= lines_form.text_field :item_number | |
And more child form fields.. |
This file contains 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
class Order | |
include ActiveModel::Model | |
attr_accessor :order_lines, :name | |
def initialize(*params) | |
self.order_lines = [] | |
super | |
end |
This file contains 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
class Application < Rails::Application | |
# ... other config ... | |
# no error div on labels | |
add_error_div_proc = ActionView::Base.field_error_proc | |
config.action_view.field_error_proc = ->(html_tag, instance) { | |
html_tag && html_tag.start_with?("<label") ? html_tag : add_error_div_proc.call(html_tag, instance) } | |
end |
This file contains 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
mysql> SHOW GLOBAL VARIABLES LIKE 'innodb%'; | |
+-------------------------------------------+------------------------+ | |
| Variable_name | Value | | |
+-------------------------------------------+------------------------+ | |
| innodb_adaptive_flushing | ON | | |
| innodb_adaptive_flushing_lwm | 10 | | |
| innodb_adaptive_hash_index | ON | | |
| innodb_adaptive_hash_index_parts | 8 | | |
| innodb_adaptive_max_sleep_delay | 150000 | | |
| innodb_api_bk_commit_interval | 5 | |
This file contains 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
RSpec.describe HandleBadEncodingMiddleware do | |
let(:app) { double() } | |
let(:middleware) { HandleBadEncodingMiddleware.new(app) } | |
it "request with query string is unchanged" do | |
expect(app).to receive(:call).with("PATH" => "/some/path", "QUERY_STRING" => "name=fred") | |
middleware.call("PATH" => "/some/path", "QUERY_STRING" => "name=fred") | |
end |
This file contains 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
class HandleBadEncodingMiddleware | |
def initialize(app) | |
@app = app | |
end | |
def call(env) | |
begin | |
Rack::Utils.parse_nested_query(env['QUERY_STRING'].to_s) | |
rescue Rack::Utils::InvalidParameterError | |
env['QUERY_STRING'] = '' |
This file contains 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
sudo apt-get install libapache2-mod-xsendfile | |
sudo a2enmod xsendfile | |
# Add to virtual host | |
sudo vi /etc/apache2/sites-available/mysite.conf | |
XSendFile On | |
XSendFilePath /var/www/myapp/shared/pdfs | |
sudo service apache2 restart |
This file contains 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
task :deploy_pdfs do | |
on roles(:app) do |h| | |
execute "mkdir -p #{remote_shared_pdfs_dir}" | |
rsync_pdfs("#{h.username}@#{h.hostname}") | |
end | |
end | |
task :delete_pdfs do | |
on roles(:app) do | |
execute "rm #{remote_shared_pdfs_dir}/*" |
This file contains 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
#!/usr/bin/env ruby | |
require 'active_support/inflector' | |
require 'active_support/core_ext/string/inflections' | |
begin | |
File.exist? './config/environment.rb' | |
rescue LoadError | |
puts "*** rails_refactor needs to be run from the root of a Rails 3 webapp ***" | |
exit | |
end |