Last active
December 11, 2015 23:58
-
-
Save znz/4680695 to your computer and use it in GitHub Desktop.
problem demo of https://github.com/mileszs/wicked_pdf/pull/182
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
# -*- coding: utf-8 -*- | |
# alias_method_chain problem demo | |
# checked with rails 3.2.11 | |
# | |
# usage: | |
# rails new /tmp/amc-problem-demo --skip-bundle --skip-active-record --skip-test-unit -m amc-problem-demo.rb | |
# cd /tmp/amc-problem-demo | |
# bundle install | |
# bundle exec rails server | |
# open http://localhost:3000/ | |
# try to submit without file (expect "ajax:success") | |
# try to submit with file (expect "ajax:error") | |
# stop rails server | |
# edit Gemfile # comment out "gem 'wicked_pdf'" | |
# bundle exec rails server | |
# open http://localhost:3000/ | |
# try to submit without file (expect "ajax:success") | |
# try to submit with file (expect "ajax:success") | |
# remotipart 1.0.2 incompatible with jquery 1.9.0 (in jquery-rails 2.2.0) | |
gsub_file "Gemfile", /gem 'jquery-rails'(?!,)/, "gem 'jquery-rails', '~> 2.1.4'" | |
gem 'remotipart', '= 1.0.2' | |
gem 'wicked_pdf', '= 0.9.4' | |
insert_into_file "app/assets/javascripts/application.js", "//= require jquery.remotipart\n", :after => /^\/\/= require jquery_ujs\n(?!\/\/= require jquery\.remotipart\n)/ | |
remove_file 'public/index.html' | |
uncomment_lines 'public/robots.txt', /User-Agent|Disallow/ | |
create_file "app/controllers/some_controller.rb", <<-'RUBY' | |
class SomeController < ApplicationController | |
def foo | |
end | |
def bar | |
render formats: [:js] | |
end | |
end | |
RUBY | |
create_file "app/views/some/foo.html.erb", <<-'HTML_ERB' | |
<h1>Some#foo</h1> | |
<div id="foo"></div> | |
<%= form_tag some_bar_path, remote: true do %> | |
<%= file_field_tag "file" %> | |
<%= submit_tag %> | |
<% end %> | |
HTML_ERB | |
create_file "app/views/some/bar.js.erb", <<-'JS_ERB' | |
$("#foo").append("posted.<br>") | |
JS_ERB | |
route "root to: 'some#foo'" | |
route "post 'some/bar'" | |
create_file "app/assets/javascripts/ajax.js", <<-'JS' | |
$(function(){ | |
$(document).on("ajax:error", function(xhr, status, error) { | |
$("#foo").append("ajax:error:'" + error + "'.<br>"); | |
}); | |
$(document).on("ajax:success", function(data, status, xhr) { | |
$("#foo").append("ajax:success.<br>"); | |
}); | |
}); | |
JS |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment