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

[#10] Update gem usage in README file #11

Merged
merged 1 commit into from
Jun 11, 2015

Conversation

unijewski
Copy link
Contributor

When we use the gem with simple_form then we get a warning regarding heartcombo/simple_form#997 described in #10 However, the recommended solution like:

def input(wrapper_options)
    @builder.text_field(attribute_name, merge_wrapper_options(input_html_options, wrapper_options))
end

Doesn't work properly in our case because wrapper_options hash looks like:

{:class=>"form-control"}

And input_html_options hash after the merge looks like:

{:preview=>true, :rows=>20, :class=>"wmd-input", :placeholder=>nil, :id=>"wmd-input-body"}

When we merge these two hashes using merge_wrapper_options helper as a result we get

{:preview=>true, :rows=>20, :class=>nil, :placeholder=>nil, :id=>"wmd-input-body"}

As you can see class key is a nil but we need both recent values, so:

  def merge_options(html_opts, wrapper_opts)
    html_opts.merge(wrapper_opts) { |_key, first, second| first + ' ' + second }
  end

seems to work pretty well.

hughevans added a commit that referenced this pull request Jun 11, 2015
[#10] Update gem usage in README file
@hughevans hughevans merged commit d55a8e8 into hughevans:master Jun 11, 2015
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