Comments (2)
@yshmarov, I've suggested this before, but ended up not writing the PR, because someone on Rails core (I believe DHH), mentioned that the scaffold are intentionally "ugly" or bare. They are not intended to be used as is. You are expected to modify them heavily.
In practice, I found that a lot of those modifications where very repetitive, so I wrote a set of generators to handle it for me.
I think that there is a case to be made for upstreaming something like this. Although, it would likely be an an uphill battle.
I rely a lot less on scaffolds than I use to, but I think there is good reasons to use the I18n layer even without translating the app. It let you separate copy from the code.
Take this controller action for example:
def update
if @book.update(book_params)
redirect_to @book, notice: success_message(@book)
else
render :edit, status: :unprocessable_entity
end
end
and the helper implementation:
def success_message model = nil
args = {}
args[:name] = model.model_name.human if model
t(".success", default: :"application.#{action_name}.success", **args)
end
This lets me
- have a generic success message that adapts automatically to the model name.
- I can change the model name showed to the user independently from how it is called in the code.
- I can write custom success message per model if needed.
- The controller doesn't have to worry about copy. It is only focused on returning a success message. It doesn't have to care what the success message is.
I'll try to post my generators soonβ’ and I'll open the discussion again.
from rails.
Thank you for the suggestion but we reserve the issue tracker for bugs only. For feature requests/discussion the best place would be the forums
from rails.
Related Issues (20)
- New docs: Consider making the content centralized on the screen
- New docs: Consider making the copy button cursor pointer
- Large arel tree causes ActiveRecord preloader to throw SystemStackError HOT 2
- Inconsistent behaviour with previous encryption schemes at global / attribute level HOT 1
- Inconsistency between `any?`/`empty?` and `size` for collection associations loaded via `inverse_of` HOT 1
- (New to Rails) Can't start the server HOT 11
- `ActiveRecord::Suppressor` not working on associations that are loaded via `inverse_of` on unsaved records HOT 4
- Assets precompile not compile activetext.css HOT 1
- ActiveSupport::Cache.expand_cache_key sometimes returns falsely same key in parallel tests HOT 11
- ActionMailer::Base.smtp_settings extra options? HOT 3
- Schema file naming when there is no "primary" database HOT 2
- exceptions on views failure to generate detailed error page when external handler alters erb HOT 1
- Request session id unavailable when streaming HTML
- Problem with field named timestamp and index with include HOT 2
- Is where way to disable ActiveRecord::UnknownAttributeReference check? HOT 1
- [Bug][ActiveRecord] #count(:all) on grouped query should clear ORDER BY if it clears SELECT
- Disable send_preload_links_header outright HOT 1
- Date#change crashes on leap years HOT 4
- Postgresql date type is not properly typecasted when using direct SQL queries like select_all HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rails.