So, RoR is better at grammer than I. Well so is my nine year old.
If I have a table named “people_type” will Rails see this as singular
because of the _type or will it consider it the plural of “person_type”
?
Is there a link to Rails that lists what words it knows, or what words
not to use in table design etc.
You can use Ruby to find out how Rails’ naming conventions work:
| % script/console
| Loading development environment.
What table name should be used for the PersonType model?
| >> “PersonType”.tableize
| => “person_types”
What model does the table named “people_type” map to?
| >> “people_type”.classify
| => “PeopleType”
Does this match what Rails expects for the PeopleType model?
| >> “PeopleType”.tableize
| => “people_types”
No – if the model is called PeopleType, we need to use “people_types”
for the table name instead. You can make a method which automates this
check for you:
I think I need to watch The Life of Brian again. Remember the bit with
the Centurian, when Brian is writing graffiti on the palace wall? The
Centurion catches him in the act.
Centurion: What’s this, then? “Romanes eunt domus”? People called
Romanes, they go, the house?
Brian: It says, "Romans go home. "
Centurion: No it doesn’t ! What’s the latin for “Roman”? Come on, come
on !
If I have a table named “people_type” will Rails see this as singular
because of the _type or will it consider it the plural of “person_type”?
If your terminology is awkward to use, it may indicate a poor choice for
the term. Why don’t you consider a term that more naturally reflects the
concept, such as “role”, “officer_grade” or “job_description”? In a
journalism class I was told to avoid using the word “people” as it is
usually too generic, and I find that advice serves me well in model
terminology as well.
By the way, someone should let the Rails pluralizer know that the plural
of mother_in_law is mothers_in_law
If your terminology is awkward to use, it may indicate a poor choice for
the term. Why don’t you consider a term that more naturally reflects the
concept, such as “role”, “officer_grade” or “job_description”? In a
journalism class I was told to avoid using the word “people” as it is
usually too generic, and I find that advice serves me well in model
terminology as well.
Noted, and I agree, but…
A “person” may be or have a
-- role
--- officer_grade
---- job_description
I understand what you are saying and I like the way Rails makes you
really think “Naming” something rather seriously.
I’m having problem with naming conventions.
I’ve 2 tables (states and steps), states has id, name, message, and
step_id
but when I go to http://127.0.0.1:3000/state it only pulls up the first
3 columns.
If I change step_id to stepid, it will show up but I want to be able to
show db info with names with underscore. How can this be dones?
This is just a guess, but it may be that RoR is interpreting step_id as
a
reference (i.e., a foreign key) to the steps table. What do your
state_controller.rb index method and state/index.rhtml file look like?
I’m having problem with naming conventions.
I’ve 2 tables (states and steps), states has id, name, message, and
step_id
but when I go to http://127.0.0.1:3000/state it only pulls up the first
3 columns.
If I change step_id to stepid, it will show up but I want to be able to
show db info with names with underscore. How can this be dones?
Thanks,
Nika
random at tangaz dot net
Andy P. wrote:
Which now leads me to…
If I have two tables
“people”
id
name
&
“person_types”
id
kind
Am I right in thinking that the row in “person” linking too
“person_types” should be ;
“people”
id
name
PersonType_id (as opposed to “person_types_id”)
Again, many thanks for your time.
Kindest reagrds.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.