Ruby on Rails
Wednesday, March 28, 2018
Hi Brian,
-- Here is an API reference for Rails: http://api.rubyonrails.org/. You need to check on the Rails version that you're using though, so you don't fall into missing or deprecated methods.
There you can find an updated quick reference to the things that you probably dealt with like has_many, belongs_to and so on. But just like our friends here mentioned, and the example you gave us, this quick reference won't help you understand that a parameter :foo_bar_bazes references a class called FooBarBaz. Getting familiar with the Rails way on doing things will definitely help you to go through that.
Kind regards,
// Marco
On Tue, Mar 27, 2018 at 11:48 PM Brian Postow <bpostow@gmail.com> wrote:
by "not references" I meant it's way too verbose for what I need. The rails guides are meant (or appear to be meant) to be read cover to cover. I need something where I can looks a specific thing up.
It's the difference between http://ruby-doc.com/docs/ProgrammingRuby/ and http://ruby-doc.org/core-2.5.0/Both are useful for learning Ruby, but if you want to just look something up, it's much easier to look things up in the core docs than in the book... But you're not going to read the core docs front to back.I want the core docs. the rails guides are the book.--
On Tuesday, March 27, 2018 at 5:18:29 PM UTC-4, nanaya wrote:
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+unsubscribe@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/c09de860-f182-43d2-b980-5b42fdd4d0c8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
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+unsubscribe@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/CACMkcE5JyOx4ppKSKTpUm9wr2-1cnhxyTQ9GEfKV2gfxUWfQ8Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment