ok… let me ask a really dumb question.
I’m really new to this.
That’s OK - I am not an expert either, just a keen amateur.
So is the naming convention to never use an underscore unless you are
I don’t think there is anything wrong with underscores (anyone?), but
the name itself is ambiguous to rails, hence the need for all the fancy
footwork to make the routes work.
So if I wanted to work with BlogPost objects
Is the best method to call the table - blogposts
and the model - Blogpost ?
Yes. This is closer to the conventions rails uses, which equates to
less work for you and more happiness.
Should I give up on the idea of being able to have a
model called BlogPost (with the capital P)?
The capital “P” in the model/table is not an issue. Neither is the name
until you get to exposing it to the user via a route. Rails expects the
mapping to be simple and straight forward. Since you are stepping away
from the conventions Rails is punishing you - it does that. Whenever
things seems difficult in Rails you are most likely running against the
I have found the easiest way is to name your controllers following what
you want the user to type. So /blog/ would require a “blogs”
controller. This makes the routes easy (map.resources blogs).
The models don’t really matter that much, but you may want to have posts
belong to something else other than blogs at some stage in the future.
With a name like “blogposts” you kind of box yourself in.
Seems like a major hassle.
The reason I’m asking is Post/Posts just seems so generic.
What’s wrong with generic?
On Apr 28, 6:43 pm, Andrew S. [email protected]