Forum: Ruby on Rails Is this a case for STI?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Sean H. (Guest)
on 2006-01-30 23:05
(Received via mailing list)
Hi everyone,

We have different populations of people here at our college: Staff,
Faculty, Students, Alumni (and a host of "Other" that I'll worry about
another day.

I originally had only Staff and Faculty loaded in under a Person model
using a Personnel controller.  Now I want to add the students in, so I
thought STI might be the way to go:

class Person < AR::Base
end
class Staff < Person
end
class Faculty < Person
end
class Student < Person
end

My question is, where do I put everything?  They'll all have similar
search result listings, different info detail listings, the same
"check password" and "change password" functions.

I think it sounds nice to have one controller, but then the list and
search methods turn UGLY when trying to account for what the user is
actually looking for.  My search methods are already ugly with all the
checking for whatever attribute the user is trying to search on.

Multiple controllers would break it out, but then there wouldn't be
much that's DRY about it.

Where to go?  What to do?

Thanks,

Sean
Ben R. (Guest)
on 2006-01-30 23:14
(Received via mailing list)
Sean ~

I definitely thing this is a good use of STI.  How you break out the
functionality will largely depend on how common elements are between the
different types of people.  For instance you say that the search results
will look the same so lets say you have a controller called Person and
an
action called Search.  This action could be shared by all Persons, and
use
the same view.  When you go to the detail view however, you say you will
have different needs.  You could create individual controllers, but
again
unless there is a lot of functionality, I would put it in the Person
Controller, staff_detail action, student_detail action, and so on.  The
urls
would look nice  too:

/person/staff_detail
/person/student_detail... and so on.

Anyhow just some thoughts to get you going.

~ Ben
Sean H. (Guest)
on 2006-01-31 16:40
(Received via mailing list)
That's what I was thinking, but I feel like that's more duplication.

Though, maybe I can set up one "detail" screen and, through the
action, set variables for what should be displayed.  Hmm, that might
work.

Thanks!

Sean
Pierre F. (Guest)
on 2006-01-31 17:41
(Received via mailing list)
Hi,

i try to make stats with Awstats and Apache2 :

Virtual configuration :

<VirtualHost *:80>
    ServerName www
    ServerAlias www.zieute.com
    DocumentRoot /var/www/www/public/
    ErrorLog /var/log/apache2/error_www.log
    CustomLog /var/log/apache2/www-access.log combined
    ServerPath /var/www/www/public/
 <Directory /var/www/www/public/>
       Options ExecCGI FollowSymLinks
       AddHandler cgi-script .cgi
       AllowOverride all
       Order allow,deny
       Allow from all
 </Directory>
</VirtualHost>



In /etc/awstats/awstats.www.zieute.com.conf
LogFile=�/var/log/apache2/www-access.log�


This :
/usr/lib/cgi-bin/awstats.pl -config=www.zieute.com
do :
With data in log file "/var/log/apache2/www-access.log"...
Phase 1 : First bypass old records, searching new record...
Searching new records from beginning of log file...
Phase 2 : Now process new records (Flush history on disk after 20000
hosts)...
Jumped lines in file: 0
Parsed lines in file: 4
 Found 0 dropped records,
 Found 0 corrupted records,
 Found 0 old records,
 Found 4 new qualified records.



I can't access awstats at www.zieute.com/cgi-bin/awstats.pl.

I don't understand
David Genord II (Guest)
on 2006-01-31 19:22
(Received via mailing list)
That is because awstats.pl needs to be located in
/var/www/www/public/cgi-bin/ or you need to setup a symbolic link.
David Genord II
This topic is locked and can not be replied to.