Browse files

Add ActionView::ModelNaming

It's just a duplicate of ActionController::ModelNaming. These are just a
simple helpers for decoupling Active Model, so it does not make sense to
extract it to Active Support, but the point is to decouple also Action
View and Action Pack
  • Loading branch information...
drogus committed Aug 15, 2012
1 parent 2646240 commit 8ca17926dc747f1808cf13cf89dea0ab11ffbccf
@@ -4,12 +4,12 @@
require 'action_view/helpers/form_tag_helper'
require 'action_view/helpers/active_model_helper'
require 'action_view/helpers/tags'
require 'action_view/model_naming'
require 'active_support/core_ext/class/attribute_accessors'
require 'active_support/core_ext/hash/slice'
require 'active_support/core_ext/string/output_safety'
require 'active_support/core_ext/array/extract_options'
require 'active_support/core_ext/string/inflections'
require 'action_controller/model_naming'
module ActionView
# = Action View Form Helpers
@@ -115,7 +115,7 @@ module FormHelper
include FormTagHelper
include UrlHelper
include ActionController::ModelNaming
include ModelNaming
# Creates a form that allows the user to create or update the attributes
# of a specific model object.
@@ -1156,7 +1156,7 @@ def default_form_builder
class FormBuilder
include ActionController::ModelNaming
include ModelNaming
# The methods which wrap a form helper call.
class_attribute :field_helpers
@@ -0,0 +1,12 @@
module ActionView
module ModelNaming
# Converts the given object to an ActiveModel compliant one.
def convert_to_model(object)
object.respond_to?(:to_model) ? object.to_model : object
def model_name_from_record_or_class(record_or_class)
(record_or_class.is_a?(Class) ? record_or_class : convert_to_model(record_or_class).class).model_name
@@ -1,5 +1,5 @@
require 'active_support/core_ext/module'
require 'action_controller/model_naming'
require 'action_view/model_naming'
module ActionView
# The record identifier encapsulates a number of naming conventions for dealing with records, like Active Records or

0 comments on commit 8ca1792

Please sign in to comment.