Closed MrSerth closed 2 weeks ago
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 94.12%. Comparing base (
beb5df3
) to head (e195759
). Report is 10 commits behind head on master.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
Do you know if lib/templates/slim/scaffold/_form.html.slim.erb
is still needed? The commit that added the file is very old and it has not been changed since then. Also the safe delete function of RubyMine does not find any uses?
Edit: I decided to remove the file.
Do you know if
lib/templates/slim/scaffold/_form.html.slim.erb
is still needed? The commit that added the file is very old and it has not been changed since then. Also the safe delete function of RubyMine does not find any uses?Edit: I decided to remove the file.
The file is still used, at least somehow 😁
Rails features so-called generators, which allow someone to add another resource quickly. These generators can either be used for specific parts (like a migration, model, controller, views, tests, ...) or altogether. For example, the following introduces a new model Repository
and all related files. It already specifies that a repository should have three attributes and one association:
rails generate scaffold repository name:string description:text remote:string group:references
```log invoke active_record create db/migrate/20240812125339_create_repositories.rb create app/models/repository.rb invoke test_unit create test/models/repository_test.rb create test/fixtures/repositories.yml invoke resource_route route resources :repositories invoke scaffold_controller create app/controllers/repositories_controller.rb invoke slim exist app/views/repositories create app/views/repositories/index.html.slim create app/views/repositories/edit.html.slim create app/views/repositories/show.html.slim create app/views/repositories/new.html.slim create app/views/repositories/_form.html.slim create app/views/repositories/_repository.html.slim invoke resource_route invoke test_unit create test/controllers/repositories_controller_test.rb create test/system/repositories_test.rb invoke helper create app/helpers/repositories_helper.rb invoke test_unit invoke jbuilder create app/views/repositories/index.json.jbuilder create app/views/repositories/show.json.jbuilder create app/views/repositories/_repository.json.jbuilder ```
As part of this generation (specifically for app/views/repositories/_form.html.slim
) the lib/templates/slim/scaffold/_form.html.slim.erb
is used. Hence, the resulting file will look like this:
= simple_form_for(@repository) do |f|
= f.error_notification
.form-inputs
= f.input :name
= f.input :description
= f.input :remote
= f.association :group
.form-actions
= f.button :submit
As you can see, this really much instantiates the template you deleted. The resulting page doesn't look too nice yet, but is fully functional (especially the reference!):
All of that was magically created by Rails 🪄
That having said, I have to admit that we aren't using generators often and they also lack the latest changes. For example, no pundit policy is generated or considered in the controller, the styling is off, and errors are also caught differently than expected.
![Bildschirmfoto 2024-08-12 um 15 09 32](https://github.com/user-attachments/assets/33c6e927-5897-4ca0-b5cb-c0276b6ef9e7)
Without the file, the view for adding or editing entries looks different (mostly better, I would say)
The only downside is that the "nice" dropdown for the group is lost and replaced with a text field (which expects a group ID). Long story short: I think, I am fine with removing the file, but would wish for a backlog ticket to fix the Rails generators (views, policies, ...) and verify them.
Ah, one further thing I wanted to share: About two weeks ago, online ratings were subject of a trial at the German Federal Court of Justice (BGH). The question was whether an online platform needs to show the distribution of ratings for the different star levels. In the ruling, the court decided that this information doesn't need to be revealed, since the average user should be aware of the potential discrepancy of individual ratings.
Sources: Press Release, Ruling
We just merged this branch and included all changes for the rating with af875c7dda08f50f40c4a7e4499711e325afb2d6.
to be written
Closes #1483