Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/albasyir/learn-ruby-on-rails
todo list only for learning
https://github.com/albasyir/learn-ruby-on-rails
Last synced: 13 days ago
JSON representation
todo list only for learning
- Host: GitHub
- URL: https://github.com/albasyir/learn-ruby-on-rails
- Owner: albasyir
- Created: 2022-02-07T11:14:46.000Z (almost 3 years ago)
- Default Branch: production
- Last Pushed: 2023-03-08T23:47:15.000Z (almost 2 years ago)
- Last Synced: 2024-11-14T21:20:58.249Z (2 months ago)
- Language: Ruby
- Size: 62.5 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Simple Ruby On Rails Blog App
This for learning purpose and just for fun, there's no real business logic in this project, just a simple blog app.## My Note
this is my note for remember something like design pattern or "best practice" for **Ruby On Rails**### Form Rendering
Rails can create form by model it self, example
```erbruby
<%= form_with model: [ @article, @article.comments.build ] do |form| %>
<%= form.label :commenter %>
<%= form.text_field :commenter %>
<%= form.label :body %>
<%= form.text_area :body %>
<%= form.label :status %>
<%= form.select :status, %w[public private archived] %>
<%= form.submit %>
<% end %>
```
`article/` is absolute path of views,
if your page on same folder of your component,
we can call name as well instead of write absolute path.### Partials Page
Rails can create partial page when you need it more that one times,
create page and name it with `_` prefix and call it using render :
```erbruby
<%= render "article/form", article: @article %>
```### *turbo-links*
Rails can create link with custom method and confirm, example
```erbruby
<%= link_to 'Delete', article_path(@article), data: { turbo_method: :delete, turbo_confirm: 'Are you sure?' } %>
```### Concerns for Model / Controller
Concerns are a way to make large controllers or models easier to understand and manage. This also has the advantage of reusability when multiple models (or controllers) share the same concerns. Concerns are implemented using modules that contain methods representing a well-defined slice of the functionality that a model or controller is responsible for. In other languages, modules are often known as mixins.