Skip to content

Commit

Permalink
Improving the 4.0.0 update guide for the #to_model method
Browse files Browse the repository at this point in the history
  • Loading branch information
jrgriffiniii committed Mar 21, 2018
1 parent c71c924 commit 57fd70a
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,21 @@ Add the stylesheets by adding this line to your app/assets/stylesheets/applicati
## Updating to 4.0.0

* [SimpleForm](https://github.com/plataformatec/simple_form) is supported from release 3.2.0 onwards
* `#to_model` now returns `self` (previously it was the value of `@model`):
```ruby
class MyForm
include HydraEditor::Form
self.model_class = MyModel
self.terms = [:title, :creator]
# [...]
end
# [...]
some_work = MyModel.new(title: ['Black holes: The Reith Lectures.'], creator: 'S.W. Hawking')
some_form = MyForm.new(some_work)
# [...]
some_form.to_model
# => #<MyForm:0x00007fd5b2fd1468 @attributes={"id"=>nil, "title"=>["Black holes: The Reith Lectures."], "creator"=>"S.W. Hawking"}, @model=#<MyModel id: nil, title: ["Black holes: The Reith Lectures."], creator: "S.W. Hawking">>
```
* When a form field for a single value is empty, it now returns a `nil` value (as opposed to an empty `String`):
```ruby
class MyForm
Expand Down

0 comments on commit 57fd70a

Please sign in to comment.