Scenario:
- Model defines an optional belongs_to relationship
- User submits form with <option value="" name="user_id"></option>
Expected behavior: - user_id is cleared
Actual behavior: - user_id is set to "", which results in a "User must be an integer" error
The following patch solved this problem for me (typecasting blank to nil for Integer fields): https://gist.github.com/769304
Created by Bernerd Schaefer - 2011-01-07 10:00:49 UTC
Original Lighthouse ticket: http://datamapper.lighthouseapp.com/projects/20609/tickets/1470
该提问来源于开源项目:datamapper/dm-core