Skip to content

Commit

Permalink
Shush Mime::JSON deprecation. Switch to backward-compatible Mime[:json]
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremy committed Sep 29, 2015
1 parent 3536726 commit 5ba4e4a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/jbuilder/jbuilder_template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ def _render_active_model_partial(object)

class JbuilderHandler
cattr_accessor :default_format
self.default_format = Mime::JSON
self.default_format = Mime[:json]

def self.call(template)
# this juggling is required to keep line numbers right in the error
Expand Down

7 comments on commit 5ba4e4a

@jasnow
Copy link

@jasnow jasnow commented on 5ba4e4a Sep 30, 2015

Choose a reason for hiding this comment

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

@jeremy : Suggest that the following message be changed:

DEPRECATION WARNING: Accessing mime types via constants is
deprecated.  Please change:
  `Mime::JSON`
to:
  `Mime::Type[:JSON]`

to

DEPRECATION WARNING: Accessing mime types via constants is
deprecated.  Please change:
  `Mime::JSON`
to:
  `Mime::[json]`

based on the above commit 5ba4e4a

@jeremy
Copy link
Member Author

@jeremy jeremy commented on 5ba4e4a Sep 30, 2015

Choose a reason for hiding this comment

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

@jasnow Definitely. We haven't changed this in Rails yet, though.

@jasnow
Copy link

@jasnow jasnow commented on 5ba4e4a Sep 30, 2015

Choose a reason for hiding this comment

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

@jeremy - note the change from Mime::Type[:JSON] to Mime::[json] in message.

@jeremy
Copy link
Member Author

@jeremy jeremy commented on 5ba4e4a Sep 30, 2015

Choose a reason for hiding this comment

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

Right, noted. We're saying the same thing 😁 That's exactly the change we'll be making in Rails, but we haven't made it yet.

@jasnow
Copy link

@jasnow jasnow commented on 5ba4e4a Sep 30, 2015

Choose a reason for hiding this comment

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

@jeremy - FYI: When I cut and pasted the string (Mime::Type[:JSON]) in the current message, then it did not work in my PR.

@jeremy
Copy link
Member Author

@jeremy jeremy commented on 5ba4e4a Sep 30, 2015

Choose a reason for hiding this comment

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

@jasnow Yeah, that only works in latest Rails, so it won't work with jbuilder's own tests. The feature-detection you implemented is what every lib that supports multiple versions of Rails would've had to do—no good. Hence the switch to an alternative that's already backward compatible.

@jasnow
Copy link

@jasnow jasnow commented on 5ba4e4a Sep 30, 2015

Choose a reason for hiding this comment

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

@jeremy - okay

Please sign in to comment.