Best Practice to use different controller

7 views
Skip to first unread message

acras

unread,
Jun 13, 2011, 6:28:22 PM6/13/11
to restfulx-framework
Hey,

I´ve been using restfulx for some time now and sometimes I find
myself working arround to use everytime the same controller for some
given model I have. But it seems to me that there must be some way to
use a different controller for that.

Let´s imagine I have a Person model in my RoR app and in restfulx it
is like:

[Resource(name="people", singularName="person")]
[Bindable]
public class Person extends RxModel {
}

Ok, that´s perfect almost all the time.

Now let´s think I need to fetch a group of people from my server in a
very specific way and I don´t want to get my people_controller full of
noise just for that functionality, I want a different controller for
that, let´s call it different_people_controller

What´s the best way to do that?

Thank you




acras

unread,
Jun 14, 2011, 10:31:58 AM6/14/11
to restfulx-framework
I don´t know if my question was clear, so I´m gonna try to be more
specific.

When I do this:

Rx.models.reload(Person)

Restfulx knows that it must ask my server for /people

what I need is something like

Rx.models.reload(Person, {controller: 'different_people'}

Thanks

tom

unread,
Jun 14, 2011, 10:38:23 AM6/14/11
to restfulx-...@googlegroups.com
maybe rails - STI is what you r lookin for

> --
> You received this message because you are subscribed to the Google Groups "restfulx-framework" group.
> To post to this group, send email to restfulx-...@googlegroups.com.
> To unsubscribe from this group, send email to restfulx-framew...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/restfulx-framework?hl=en.
>
>

acras

unread,
Jun 14, 2011, 10:46:23 AM6/14/11
to restfulx-framework
I don´t think so. It´s the very same model. Searched in a different
way.

It´s truly a different controller resulting in a set of the same model
Person.

Thanks
Att

tom

unread,
Jun 14, 2011, 10:51:49 AM6/14/11
to restfulx-...@googlegroups.com
maybe you can look into rails & admin controllers.
but, if its just a search method, why not putting it into your model?

acras

unread,
Jun 14, 2011, 11:05:05 AM6/14/11
to restfulx-framework
I can do it, but like I said in my first mail it will add noise to my
controller.

Isn´t it natural to have more than one controller returning the same
model? What I know about MVC it should be.

Att
Reply all
Reply to author
Forward
0 new messages