When scaffolding in Rails 3 the generator does this:
<% if @user.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@user.errors.count, "error") %> prohibited this user from being saved:</h2>
<ul>
<% @user.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>
But what about i18n? The messages get translated but why the hardcoded headline? Am I supposed to translate that manually? That doesn't seem very DRY?
Regards,
Jacob
you can override scaffold default behavior by downloading the files here on github and place em in your
lib/templates/erb/scaffold
. When you generate scaffold it realize the templates are there and use those.<% this code is executed and probably result in html %>
,<%% this is converted to snippet %>
, it was not that difficult and then you can perform all your personalizations, but to have theyml
file automatically generated could be harder, anyway you can still get your templates almost done automatically.To answer your question I do too think scaffold could be improved, but I read everywhere developers prefer to write their own code from scratch. Therefor I think, efforts are focused on improving other features. Scaffold remains at the very least a useful generator to understand and get familiar with the logic when you're a beginner.