Skip to content

Support camelizing ActionController::Parameters #932

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

Merged
merged 1 commit into from
Sep 15, 2018

Conversation

jcarlson
Copy link
Contributor

@jcarlson jcarlson commented Sep 6, 2018

Summary

Adds support for React.camelize_props to camelize an instance of
ActionController::Parameters hash, so that permitted, strong parameters
in a Rails controller can be passed to a React component.

Other Information

Resolves #931

Adds support for React.camelize_props to camelize an instance of
ActionController::Parameters hash, so that permitted, strong parameters
in a Rails controller can be passed to a React component.

Resolves reactjs#931
Copy link
Member

@BookOfGreg BookOfGreg left a comment

Choose a reason for hiding this comment

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

Only one tweak needed to the test.
Would also be nice to add a comment in the Readme.

I'll check in again next week and I'll prep it for a new version.

Well done, thank you for taking your time to contribute :)

@@ -28,4 +28,23 @@ def test_it_camelizes_props

assert_equal expected_props, React.camelize_props(raw_props)
end

def test_it_camelizes_params
Copy link
Member

@BookOfGreg BookOfGreg Sep 7, 2018

Choose a reason for hiding this comment

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

You can actually wrap the test in a defined check like this:

if defined?(ActionController::Parameters)
  def test_method
  end
end

Which should make it work on Rails <4

Edit: Though technically speaking we don't support Rails3

@BookOfGreg BookOfGreg merged commit 339a563 into reactjs:master Sep 15, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants