PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.lang.ruby > Modules in rails? ( controllers or models?)
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Modules in rails? ( controllers or models?)

Réponse
 
LinkBack Outils de la discussion
Vieux 02/12/2007, 23h40   #1
malugu satyajit
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Modules in rails? ( controllers or models?)

Note: parts of this message were removed by the gateway to make it a legal Usenet post.

Hello,

I have an rails application that has almost similar function for three
classes. So I am thinking to create a parent class and then the sub classes
inherit from it. But rails already inherits from ActiveRecord(models) or
ApplicationController(controller).

So how can I inherit from others classes. My my ruby knowledge it is modules
and then you mixin the module in your class.

Now my question, where you write the module in rails is it in controller or
model? Can some one provide me links or guidance.


--
Regards,
M.Satyajit
Graduate Student,
Department of Computer Science,
NCSU.
www4.ncsu.edu/~smalugu

  Réponse avec citation
Vieux 02/12/2007, 23h49   #2
thefed
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Modules in rails? ( controllers or models?)


On Dec 2, 2007, at 6:40 PM, malugu satyajit wrote:

> Hello,
>
> I have an rails application that has almost similar function for three
> classes. So I am thinking to create a parent class and then the sub
> classes
> inherit from it. But rails already inherits from ActiveRecord
> (models) or
> ApplicationController(controller).
>
> So how can I inherit from others classes. My my ruby knowledge it
> is modules
> and then you mixin the module in your class.
>
> Now my question, where you write the module in rails is it in
> controller or
> model? Can some one provide me links or guidance.
>


You can create a parent class that inherits from ActiveRecord or
ApplicationController.
Then, your subclasses can inherit from the parent class.

This may or may not work, and this is a question for the rails list


_______________________________|
- Ari
I just bought another case of RockStar. Expect architectural changes.



  Réponse avec citation
Vieux 02/12/2007, 23h58   #3
malugu satyajit
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Modules in rails? ( controllers or models?)

Note: parts of this message were removed by the gateway to make it a legal Usenet post.

thanks... can you say the rails list address? I found it on web.. but just
be sure

On Dec 2, 2007 6:49 PM, thefed <fedzor@gmail.com> wrote:

>
> On Dec 2, 2007, at 6:40 PM, malugu satyajit wrote:
>
> > Hello,
> >
> > I have an rails application that has almost similar function for three
> > classes. So I am thinking to create a parent class and then the sub
> > classes
> > inherit from it. But rails already inherits from ActiveRecord
> > (models) or
> > ApplicationController(controller).
> >
> > So how can I inherit from others classes. My my ruby knowledge it
> > is modules
> > and then you mixin the module in your class.
> >
> > Now my question, where you write the module in rails is it in
> > controller or
> > model? Can some one provide me links or guidance.
> >

>
> You can create a parent class that inherits from ActiveRecord or
> ApplicationController.
> Then, your subclasses can inherit from the parent class.
>
> This may or may not work, and this is a question for the rails list
>
>
> _______________________________|
> - Ari
> I just bought another case of RockStar. Expect architectural changes.
>
>
>
>



--
Regards,
M.Satyajit
Graduate Student,
Department of Computer Science,
NCSU.
www4.ncsu.edu/~smalugu

  Réponse avec citation
Vieux 03/12/2007, 00h06   #4
Todd Benson
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Modules in rails? ( controllers or models?)

On Dec 2, 2007 5:40 PM, malugu satyajit <malugu.satyajit@gmail.com> wrote:
> Hello,
>
> I have an rails application that has almost similar function for three
> classes. So I am thinking to create a parent class and then the sub classes
> inherit from it. But rails already inherits from ActiveRecord(models) or
> ApplicationController(controller).
>
> So how can I inherit from others classes. My my ruby knowledge it is modules
> and then you mixin the module in your class.
>
> Now my question, where you write the module in rails is it in controller or
> model? Can some one provide me links or guidance.


Well, from a kindergartener's perspective (namely, mine), I would
think that if your classes represent tuples of data in a database,
they would be models, and you would add functionality by having the
model classes (those that inherit from ActiveRecord::Base) require the
necessary mixin themselves, or make use of #extend. I think, however,
it is highly dependent on your situation.

I'm sure you can find some best practices advice from the rails list.
The one I have bookmarked is:
http://groups.google.com/group/rubyonrails-talk.

Todd

  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 06h30.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,11069 seconds with 12 queries