bragi / representations

Simple representations for ActiveRecord models
MIT License
7 stars 2 forks source link

Namespace method #27

Open bragi opened 14 years ago

bragi commented 14 years ago

Add namespace method that allows to 'move' representation to another namespace.

Usage is:

- profile.namespace(:administration) do |administration_profile|
  - administration_profile.form do #...

Alternatively:

- profile.namespace(:administration).form do #...

This will create a form that submits to /administration/profiles instead of /profiles.

It should be possible to create namespaced representations for both nested and top level namespaces.

asok commented 14 years ago

I think it is a good idea to do the ticket http://github.com/bragi/representations/issues#issue/33 before starting work on this one.

gruby commented 14 years ago

taken.

bragi commented 14 years ago

Simple implementation:

Add method that builds path for representation (it should behave a bit like url_for()). This method takes provided namespace into consideration. Each AR representation stores namespace (remember: namespaces can be nested!) When you call .namespace() it returns clone of representation but with new namespace added to the chain. This means when you call path creating method on this representation it will take all namespaces into account.

gruby commented 14 years ago

.namespace and .current_namespace (namespace builder) methods created. They work in views as desired. Some tests to be done.