Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates for Rails 6.0 #2

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions lib/action_view/template/handlers/rjs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ class RJS
class_attribute :default_format
self.default_format = Mime[:js]

def call(template)
"update_page do |page|;#{template.source}\nend"
def call(template, source=nil)
source ||= template.source
"update_page do |page|;#{source}\nend"
end
end
end
Expand Down
7 changes: 4 additions & 3 deletions lib/jquery-rjs/rendering.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ def render_with_update(options = {}, locals = {}, &block)
render_without_update(options, locals, &block)
end
end

alias_method_chain :render, :update
end

alias_method :render_without_update, :render
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should these use prepend?

Copy link
Member Author

@NickLaMuro NickLaMuro Nov 18, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bdunne see my commit message for this:

417da52

[rails6] replace alias_method_chain

While using the Module.prepend approach is probably the correct way to
do this, the way that this class is defined is pretty gross, so I would
rather avoid trying to deal with that and simply replicate the
functionality alias_method_chain provided by doing two alias_method
calls.

This is a Gem the probably should just die anyway, so I am not terribly
bothered by the hack...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, since this is mostly just to maintain legacy code, I am trying to do the least amount of changes possible, and using prepend is doing more refactoring than I would like, where this approach is basically taking what alias_method_chain did and doing it manually.

alias_method :render, :render_with_update
end
3 changes: 2 additions & 1 deletion lib/jquery-rjs/selector_assertions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,8 @@ def response_from_page_with_rjs
response_from_page_without_rjs
end
end
alias_method_chain :response_from_page, :rjs
alias_method :response_from_page_without_rjs, :response_from_page
alias_method :response_from_page, :response_from_page_with_rjs

# Unescapes a RJS string.
def unescape_rjs(rjs_string)
Expand Down