-
Notifications
You must be signed in to change notification settings - Fork 630
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
201 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68f48e6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hooray!
68f48e6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, I've just had a play around with this. Is there a reason that check_boxes sends the selection as a hash?
"role_ids" => { "1" => "1", "2" => "2" }
Shouldn't this be sent as an array?
68f48e6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Jim, there is no way to send it as an array. :/ Rails encode parameters as hashes (unless I'm missing something!).
68f48e6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Jose, I think if you change the markup from the following:
To something along the lines of this:
Rails will get an array of ids along the lines of:
author_ids => [1, 2, 3]
You can then pass that to the author_ids of the model in your controller.
I'm not entirely sure, but I don't think you need the hidden fields if you do it this way, as if the box is unchecked it simply doesn't get sent. So if you uncheck all the boxes rails will get an empty array for author_ids, which will in turn remove all the associations to authors on that model.
Hope that made sense?
68f48e6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Crap.
68f48e6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should have been:
to:
68f48e6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I will try that.
68f48e6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed!
http://github.com/justinfrench/formtastic/commit/3f00af0c7d1a9fe36928d31ff616840ac9f27c0b
Do you mind trying it out once again?