Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RF DOCS] Active Model Basics Documentation [ci-skip] #51210

Merged

Conversation

Ridhwana
Copy link
Contributor

Motivation / Background

This Pull Request has been created to update the Active Model Basics Documentation.

Detail

This Pull Request adds the following two sections:

  • AttributeAssignment
  • Attributes

It updates the rest of the sections by trying to provide more information, be more clear, and include more examples. In some parts, it references the API where more information about the methods can be provided.

I also addressed these as part of the changes:

There's the new ActiveModel::API module that was essentially a split from ActiveModel::Model, this difference can be better explained in the guides as it is in the original PR.

The Lint Tests section example shows ActiveModel::Model, it should probably be ActiveModel::API.

It's possible to expand validations with how to check for errors, and other common usage. As well as different types of callback examples.

Some examples use send, those can be updated to use public_send instead.

Checklist

Before submitting the PR make sure the following are checked:

  • This Pull Request is related to one change. Changes that are unrelated should be opened in separate PRs.
  • Commit message has a detailed description of what changed and why. If this PR fixes a related issue include it in the commit message. Ex: [Fix #issue-number]
  • Tests are added or updated if you fix a bug or add a feature.
  • CHANGELOG files are updated for the changed libraries if there is a behavior change or additional feature. Minor bug fixes and documentation changes should not be included.

@rails-bot rails-bot bot added the docs label Feb 27, 2024
@carlosantoniodasilva carlosantoniodasilva added the rails foundation Rails Foundation PRs label Feb 27, 2024
<%= render "email_contact", email_contact: @email_contact %>
```

### Attributes
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As this isn't included in API, should not this be only mentioned later?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They feel like individual sections that can live on their own, I'm not sure there's need to follow "API" with only the modules that it includes, since you can navigate up/down via the links/anchors under the API section to learn more about the individual ones?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO, a beginner will likely read this in order, so I'd love if the most common things appeared first in the document.

Copy link
Contributor

@brunoprietog brunoprietog left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work!

What do you think about adding a small section on how to customize the url that will generate the ActionView helper related to that model? I have seen that need when you have the model in a namespace, something like Student::Application, but for some reason you need the path to simply point to application (/applications/..., etc).

I don't know if there is a more idiomatic way to do it than this:

class Student::Application
  include ActiveModel::Model
  
  ...

  def self.model_name
    ActiveModel::Name.new(self, nil, "Application")
  end
end

Or maybe it's something very specific.

guides/source/active_model_basics.md Outdated Show resolved Hide resolved
guides/source/active_model_basics.md Outdated Show resolved Hide resolved
Co-authored-by: Bruno Prieto <brunoprietog@hey.com>
Ridhwana and others added 2 commits March 5, 2024 12:23
Co-authored-by: Juanjo Bazán <jjbazan@gmail.com>
Copy link
Member

@carlosantoniodasilva carlosantoniodasilva left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really nice work @Ridhwana. I had some last minute bits of feedback on a final pass, let me know if you have any questions.

guides/source/active_model_basics.md Outdated Show resolved Hide resolved
guides/source/active_model_basics.md Outdated Show resolved Hide resolved
guides/source/active_model_basics.md Outdated Show resolved Hide resolved
guides/source/active_model_basics.md Outdated Show resolved Hide resolved
guides/source/active_model_basics.md Outdated Show resolved Hide resolved
guides/source/active_model_basics.md Outdated Show resolved Hide resolved
guides/source/active_model_basics.md Outdated Show resolved Hide resolved
guides/source/active_model_basics.md Outdated Show resolved Hide resolved
Ridhwana and others added 10 commits March 7, 2024 11:41
Co-authored-by: Carlos Antonio da Silva <carlosantoniodasilva@gmail.com>
Co-authored-by: Carlos Antonio da Silva <carlosantoniodasilva@gmail.com>
Co-authored-by: Carlos Antonio da Silva <carlosantoniodasilva@gmail.com>
Co-authored-by: Carlos Antonio da Silva <carlosantoniodasilva@gmail.com>
Co-authored-by: Carlos Antonio da Silva <carlosantoniodasilva@gmail.com>
Co-authored-by: Carlos Antonio da Silva <carlosantoniodasilva@gmail.com>
Co-authored-by: Carlos Antonio da Silva <carlosantoniodasilva@gmail.com>
@carlosantoniodasilva carlosantoniodasilva merged commit 6e0b89c into rails:main Mar 7, 2024
3 checks passed
viralpraxis pushed a commit to viralpraxis/rails that referenced this pull request Mar 24, 2024
Review the Active Model Basics guide.

Add `Attributes` and `AttributeAssignment` sections.

Update the rest of the sections by trying to provide more information, be more clear, and include more examples. In some parts, it references the API where more information about the methods can be provided.

Expand `ActiveModel::API` and `ActiveModel::Model`, reorganize sections to a more sensible order.

Co-authored-by: Carlos Antonio da Silva <carlosantoniodasilva@gmail.com>
fractaledmind pushed a commit to fractaledmind/rails that referenced this pull request May 13, 2024
Review the Active Model Basics guide.

Add `Attributes` and `AttributeAssignment` sections.

Update the rest of the sections by trying to provide more information, be more clear, and include more examples. In some parts, it references the API where more information about the methods can be provided.

Expand `ActiveModel::API` and `ActiveModel::Model`, reorganize sections to a more sensible order.

Co-authored-by: Carlos Antonio da Silva <carlosantoniodasilva@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs rails foundation Rails Foundation PRs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants