forked from rails/rails
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
4 changed files
with
81 additions
and
42 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
59 changes: 59 additions & 0 deletions
59
actionpack/lib/action_view/helpers/form_helper_core_extensions.rb
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
class String | ||
def form_object_name | ||
self | ||
end | ||
|
||
def as_fields_for_form_object(args) | ||
args.first | ||
end | ||
|
||
def acts_like_model? | ||
false | ||
end | ||
end | ||
|
||
class Symbol | ||
def form_object_name | ||
self | ||
end | ||
|
||
def as_fields_for_form_object(args) | ||
args.first | ||
end | ||
|
||
def acts_like_model? | ||
false | ||
end | ||
end | ||
|
||
class Array | ||
def as_form_object | ||
last | ||
end | ||
|
||
def as_array | ||
self | ||
end | ||
end | ||
|
||
class Object | ||
def as_form_object | ||
self | ||
end | ||
|
||
def as_fields_for_form_object(args) | ||
as_form_object | ||
end | ||
|
||
def form_object_name | ||
ActionController::RecordIdentifier.singular_class_name(self) | ||
end | ||
|
||
def as_array | ||
[self] | ||
end | ||
|
||
def acts_like_model? | ||
true | ||
end | ||
end |
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
cffbc43
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.
👍