aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/lib/active_model/naming.rb
Commit message (Collapse)AuthorAgeFilesLines
* allow requiring of 'active_model/naming'Paul McMahon2012-01-251-1/+1
| | | | | | | Requiring 'active_model/naming' will raise an uninitialized constant ActiveSupport::Deprecation exception because the module core extension doesn't require 'active_support/deprecation'. This require cannot be added to the core extension because of circular dependency issues.
* Improve cache on route_key lookup.José Valim2011-12-081-2/+23
|
* ActiveModel::Name#i18n_key: Fix doc and add testsMarc-Andre Lafortune2011-12-051-2/+2
|
* make ActiveModel::Name fail gracefully with anonymous classesJakub Kuźma2011-11-241-0/+3
|
* Rely on a public contract between railties instead of accessing railtie ↵José Valim2011-11-231-11/+13
| | | | methods directly.
* Rename new method to_path to to_partial_path to avoid conflicts with ↵José Valim2011-08-011-1/+1
| | | | File#to_path and similar.
* Let ActiveModel instances define partial paths.Grant Hutchins & Peter Jaros2011-07-251-0/+3
| | | | | | Deprecate ActiveModel::Name#partial_path. Now you should call #to_path directly on ActiveModel instances.
* Get rid of the alternate namespace lookup.José Valim2011-06-111-4/+3
|
* Brought back alternative convention for namespaced models in i18n.thoefer2011-06-081-3/+4
|
* Specify the name to be used for ActiveModel::Name fixes #1168Yves Senn2011-05-201-2/+3
| | | | This patch allows to specify the name of your models independent of the class name.
* Removed extra whitespaceSebastian Martinez2011-04-261-1/+1
|
* Bring back AMo#i18n_key methodSantiago Pastorino2011-03-301-5/+10
|
* Revert "Properly interpolate i18n keys in modules [#5572 state:resolved]"Santiago Pastorino2011-02-271-10/+5
| | | | | | | This breaks #6448, you should use :"module/class" as key for namespacing [#6448 state:committed] This reverts commit 8d30193b08bd2321a7a78a1f481bd5e4d4d45557.
* fix type: remove extra periodNicholas Rowe2011-02-171-1/+1
|
* Added missing AS require to active_model/naming.rbsnusnu2010-10-301-0/+1
| | | | | | | | | | | | | | We saw a failing spec when running the DataMapper ActiveModel compliance specs for dm-active_model. ActiveModel::Naming#model_name relies on the Module#parents method defined in active_support/core_ext/module/introspection.rb Adding the appropriate require statement of course fixed our specs.
* Convert to model before calling model_name on a record in ActiveModel::NamingErnie Miller2010-10-041-1/+5
| | | | Signed-off-by: José Valim <jose.valim@gmail.com>
* Fix Namind#model_name.thedarkone2010-09-271-2/+4
|
* Don't act destructively on ActiveModel::Name#human options hash. [#5366 ↵John Firebaugh2010-09-251-2/+3
| | | | | | state:resolved] Signed-off-by: José Valim <jose.valim@gmail.com>
* Properly interpolate i18n keys in modules [#5572 state:resolved]Rodrigo Rosenfeld Rosas2010-09-241-5/+10
|
* Fix docs related to param_key in ActiveModel::NamingCarlos Antonio da Silva2010-09-051-2/+2
| | | | Signed-off-by: José Valim <jose.valim@gmail.com>
* Add some documantation on new route_key and param_key in ActiveModel::NamingPiotr Sarnacki2010-09-031-0/+16
|
* Prepared ActiveModel::Naming to handle cases for namespaced isolated enginesPiotr Sarnacki2010-09-031-4/+22
|
* Deletes trailing whitespaces (over text files only find * -type f -exec sed ↵Santiago Pastorino2010-08-141-5/+5
| | | | 's/[ \t]*$//' -i {} \;)
* edit pass to apply API guideline wrt the use of "# =>" in example codeXavier Noria2010-07-301-3/+6
|
* Moved a few methods from RecordIdentifier to ActiveModel::NamingPiotr Sarnacki2010-07-211-0/+29
| | | | Signed-off-by: José Valim <jose.valim@gmail.com>
* edit pass: the names of Rails components have a space, ie, "Active Record", ↵Xavier Noria2010-06-141-1/+1
| | | | not "ActiveRecord"
* Revised and added headings.Rizwan Reza2010-06-141-1/+1
|
* Revised naming.rb and lint.rbRizwan Reza2010-06-141-4/+4
|
* Merge remote branch 'mainstream/master'Pratik Naik2010-03-121-1/+1
|\ | | | | | | | | | | | | Conflicts: activerecord/lib/active_record/base.rb railties/lib/rails/configuration.rb railties/lib/rails/log_subscriber.rb
| * Adds #key and #to_param to the AMo interfacesnusnu2010-02-191-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit introduces two new methods that every AMo compliant object must implement. Below are the default implementations along with the implied interface contract. # Returns an Enumerable of all (primary) key # attributes or nil if new_record? is true def key new_record? ? nil : [1] end # Returns a string representing the object's key # suitable for use in URLs, or nil if new_record? # is true def to_param key ? key.first.to_s : nil end 1) The #key method Previously rails' record_identifier code, which is used in the #dom_id helper, relied on calling #id on the record to provide a reasonable DOM id. Now with rails3 being all ORM agnostic, it's not safe anymore to assume that every record ever will have an #id as its primary key attribute. Having a #key method available on every AMo object means that #dom_id can be implemented using record.to_model.key # instead of record.id Using this we're able to take composite primary keys into account (e.g. available in datamapper) by implementing #dom_id using a newly added record_key_for_dom_id(record) method. The user can overwrite this method to provide customized versions of the object's key used in #dom_id. Also, dealing with more complex keys that can contain arbitrary strings, means that we need to make sure that we only provide DOM ids that are valid according to the spec. For this reason, this patch sends the key provided through a newly added sanitize_dom_id(candidate_id) method, that makes sure we only produce valid HTML The reason to not just add #dom_id to the AMo interface was that it feels like providing a DOM id should not be a model concern. Adding #dom_id to the AMo interface would force these concern on the model, while it's better left to be implemented in a helper. Now one could say the same is true for #to_param, and actually I think that it doesn't really fit into the model either, but it's used in AR and it's a main part of integrating into the rails router. This is different from #dom_id which is only used in view helpers and can be implemented on top of a semantically more meaningful method like #key. 2) The #to_param method Since the rails router relies on #to_param to be present, AR::Base implements it and returns the id by default, allowing the user to overwrite the method if desired. Now with different ORMs integrating into rails, every ORM railtie needs to implement it's own #to_param implementation while already providing code to be AMo compliant. Since the whole point of AMo compliance seems to be to integrate any ORM seamlessly into rails, it seems fair that all we really need to do as another ORM, is to be AMo compliant. By including #to_param into the official interface, we can make sure that this code can be centralized in the various AMo compliance layers, and not be added separately by every ORM railtie. 3) All specs pass
| * Full update on ActiveModel documentationMikel Lindsaar2010-02-011-0/+15
| |
* | Adding ActiveModel::Naming documentationMikel Lindsaar2010-01-171-0/+17
|/
* Small clean up in Naming and TTranslation tests.José Valim2009-12-231-4/+22
|
* Move validator, human_name and human_attribute_name to ActiveModel, remove ↵José Valim2009-10-201-4/+5
| | | | | | deprecated error messages and add i18n_scope and lookup_ancestors. Signed-off-by: Carl Lerche <carllerche@mac.com>
* Add support for error_messages_for(@obj)Yehuda Katz2009-07-281-1/+2
|
* Move model naming into ActiveModelJoshua Peek2009-06-171-0/+25