On Wed, Mar 28, 2018, at 04:39, Brian Postow wrote:
> The rails guides are not references. They're tutorials.
> 
> An example of the thing I'm having trouble with:
> 
> I'm having things like "it says it's missing foo_bar_bazes" but 
> "foo_bar_bazes" never occurs in my code, why does it think that it SHOULD?" 
> The answer in this particular case was that there was a FooBarBaz or  
> something, and that Rails decided that there obviously should be a 
> foo_bar_bazes sql table, which I never created. Rails was RIGHT, there 
> needed to be a sql table, but it took me like 4 hours to figure out what it 
> was complaining about, and where it thought "foo_bar_bazes" needed to live, 
> and why it should be foo_bar_bazes and not FooBarBaz, or FooBarBazes or 
> foo_bar_baz, or any other of a number of possible things... It took another 
> 4 person hours to figure out how to get migrate to correctly do the things 
> I needed, because it converted Camel to snake in ways that I didn't expect.
> 
> 

http://guides.rubyonrails.org/active_record_basics.html#naming-conventions

By default, Active Record uses some naming conventions to find out how the 
mapping between models and database tables should be created. Rails will 
pluralize your class names to find the respective database table. So, for a 
class Book, you should have a database table called books. The Rails 
pluralization mechanisms are very powerful, being capable of pluralizing (and 
singularizing) both regular and irregular words. When using class names 
composed of two or more words, the model class name should follow the Ruby 
conventions, using the CamelCase form, while the table name must contain the 
words separated by underscores. Examples:



http://guides.rubyonrails.org/active_record_migrations.html#creating-a-migration

Migrations are stored as files in the db/migrate directory, one for each 
migration class. The name of the file is of the form 
YYYYMMDDHHMMSS_create_products.rb, that is to say a UTC timestamp identifying 
the migration followed by an underscore followed by the name of the migration. 
The name of the migration class (CamelCased version) should match the latter 
part of the file name. For example 20080906120000_create_products.rb should 
define class CreateProducts and 20080906120001_add_details_to_products.rb 
should define AddDetailsToProducts. Rails uses this timestamp to determine 
which migration should be run and in what order, so if you're copying a 
migration from another application or generate a file yourself, be aware of its 
position in the order.



http://guides.rubyonrails.org/association_basics.html#detailed-association-reference

When you declare a belongs_to association, the declaring class automatically 
gains five methods related to the association:

...

When you declare a has_one association, the declaring class automatically gains 
five methods related to the association:

...


Not sure where you got the idea it's not references.

Oh and here's the documentation for autoloading mechanism (re: "Given a name of 
a given form, what kind of thing does RoR think it is and where is RoR looking 
for it?"):

http://guides.rubyonrails.org/autoloading_and_reloading_constants.html

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/1522185467.2857204.1318226216.161518C4%40webmail.messagingengine.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to