Reputation: 2188
I would like to display Snort IPS events in my dashboard app, these events are written into a database via barnyard2. I'm going threw rails for zombies
and they say to access info from tables out of a database the table should be plural, and the model is singular. You would then expect the table with the IPS events to be events
and not event
.
Barnyard2 comes with a create_postgres
schema script. Below are the tables created by the script. They are all singular.
csdashboard=# \dt
List of relations
Schema | Name | Type | Owner
--------+-------------------+-------+-------------
public | data | table | csdashboard
public | detail | table | csdashboard
public | encoding | table | csdashboard
public | event | table | csdashboard
public | icmphdr | table | csdashboard
public | iphdr | table | csdashboard
public | opt | table | csdashboard
public | reference | table | csdashboard
public | reference_system | table | csdashboard
public | schema | table | csdashboard
public | sensor | table | csdashboard
public | sig_class | table | csdashboard
public | sig_reference | table | csdashboard
public | signature | table | csdashboard
public | tcphdr | table | csdashboard
public | udphdr | table | csdashboard
I do not need or want my app to enter anything into these tables, just find and display the info.
My questions are;
Do I need to create a model per table that I will be getting info from?
Since they should be plural, will this create a problem?
Upvotes: 1
Views: 143
Reputation: 5832
You do not have to stick with all conventions and there is an easy way to alter this one. You can set table name in your model:
class Event < ActiveRecord::Base
self.table_name = 'event'
end
Upvotes: 2
Reputation: 1722
Yes. Yes.
You need a model per table. Without that you'll have big problems with ActiveRecord
.
You'll have some other problems if your table name is not a plural of your model, once again with ActiveRecord
.
Upvotes: 1