question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

expected Hash (got String) for param `date'

See original GitHub issue

When using pickadate in Rails, I get the following error when submitting a form:

expected Hash (got String) for param `date’

Here is my form and schema for the two fields: https://gist.github.com/DevanB/6551291

I can remove pickadate classes from the fields, and everything works fine, but when those two fields have the pickadate classes, I get that error.

Thanks for any help guys!

Issue Analytics

  • State:closed
  • Created 10 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

6reactions
jerefrercommented, Jan 12, 2014

Turns out the error is caused by the hidden _submit field. Apparently Rails doesn’t like fields named like this object[field_name]_submit.

But is it even normal to have a field named like this ? I’ve never seen anything like it. Maybe what you meant to do with the suffix was to have something like object[field_name_suffix]. Didn’t you ?

Anyway, to get rid of the error I’ve just set the hiddenSuffix option to empty string: hiddenSuffix: ''. Worked for pickatime too.

1reaction
retoocommented, Mar 17, 2014

The following snippet provides a workaround, which converts hidden attributes foo[bar]_submit to foo[bar_submit] (notation as suggested by jerefrer).

I hope we can fix this properly in the library, the workaround is rather hackish.

/* see https://github.com/amsul/pickadate.js/issues/227 */
var BAD_ATTR_RE = /\]_submit$/;
$(function() {
  $('form').submit(function(event) {
    var target = $(event.target);
    $.each(target.find("input[type=hidden]"), function(i, el) {
      var e = $(el);
      var name = e.attr('name');
      if (name.match(BAD_ATTR_RE)) {
        var newName = name.replace(BAD_ATTR_RE, "_submit]");
        e.attr("name", newName)
      }
    });
  });
});
Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeError (expected Hash (got String) for param `content
I'm currently trying to add widgEditor to a form in ruby on rails however whenever I hit submit I get ...
Read more >
Solved: expected String to be a Hash - Shopify Community
I have a problem on creating Fulfillment or creating a test transaction. I followed the documentation in REST API but still got and...
Read more >
A brand new website interface for an even better experience!
Invalid querystring leads to status 500 (TypeError: expected Hash (got Array) for param) ... Backers, Amount, Date. Updates. IN PROGRESS. BOUNTY TOO LOW....
Read more >
Rails Form helpers - Ruby on Rails Guides
When the form is submitted, the name will be passed along with the form data, and will make its way to the params...
Read more >
Customer Information Parameters - Conversions API
string. Do not hash. The IP address of the browser corresponding to the ... for how to get this value or generate this...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found