From ccfddce4cfc807f072e0aae6abb93720663a44a6 Mon Sep 17 00:00:00 2001 From: Prem Sichanugrist Date: Wed, 23 Jun 2010 23:12:37 +0700 Subject: [PATCH 2/2] Silence some of the erb tag whitespace, and calling 'edit_resource_path' without the argument on singleton scaffold generation [#4863] --- .../erb/scaffold/templates/_form.html.erb | 2 +- .../erb/scaffold/templates/edit.html.erb | 5 +---- .../generators/erb/scaffold/templates/new.html.erb | 4 ++-- .../erb/scaffold/templates/show.html.erb | 10 +++++----- 4 files changed, 9 insertions(+), 12 deletions(-) diff --git a/railties/lib/rails/generators/erb/scaffold/templates/_form.html.erb b/railties/lib/rails/generators/erb/scaffold/templates/_form.html.erb index d12b2ff..053dad1 100644 --- a/railties/lib/rails/generators/erb/scaffold/templates/_form.html.erb +++ b/railties/lib/rails/generators/erb/scaffold/templates/_form.html.erb @@ -1,4 +1,4 @@ -<%%= form_for(@<%= singular_table_name %>) do |f| %> +<%%= form_for(@<%= singular_table_name %><% if options[:singleton] %>, :url => <%= singular_table_name %>_path<% end %>) do |f| %> <%% if @<%= singular_table_name %>.errors.any? %>

<%%= pluralize(@<%= singular_table_name %>.errors.count, "error") %> prohibited this <%= singular_table_name %> from being saved:

diff --git a/railties/lib/rails/generators/erb/scaffold/templates/edit.html.erb b/railties/lib/rails/generators/erb/scaffold/templates/edit.html.erb index 115e387..c7a8141 100644 --- a/railties/lib/rails/generators/erb/scaffold/templates/edit.html.erb +++ b/railties/lib/rails/generators/erb/scaffold/templates/edit.html.erb @@ -2,7 +2,4 @@ <%%= render 'form' %> -<%%= link_to 'Show', @<%= singular_table_name %> %> -<% unless options[:singleton] -%> -| <%%= link_to 'Back', <%= index_helper %>_path %> -<% end -%> +<%%= link_to 'Show', @<%= singular_table_name %> %><% unless options[:singleton] %> | <%%= link_to 'Back', <%= index_helper %>_path %><% end %> diff --git a/railties/lib/rails/generators/erb/scaffold/templates/new.html.erb b/railties/lib/rails/generators/erb/scaffold/templates/new.html.erb index acd9464..cf5ae3a 100644 --- a/railties/lib/rails/generators/erb/scaffold/templates/new.html.erb +++ b/railties/lib/rails/generators/erb/scaffold/templates/new.html.erb @@ -1,6 +1,6 @@

New <%= singular_table_name %>

<%%= render 'form' %> -<% unless options[:singleton] -%> +<% unless options[:singleton] %> <%%= link_to 'Back', <%= index_helper %>_path %> -<% end -%> +<%- end -%> diff --git a/railties/lib/rails/generators/erb/scaffold/templates/show.html.erb b/railties/lib/rails/generators/erb/scaffold/templates/show.html.erb index 5d6ece5..7fe4afd 100644 --- a/railties/lib/rails/generators/erb/scaffold/templates/show.html.erb +++ b/railties/lib/rails/generators/erb/scaffold/templates/show.html.erb @@ -7,8 +7,8 @@

<% end -%> - -<%%= link_to 'Edit', edit_<%= singular_table_name %>_path(@<%= singular_table_name %>) %> -<% unless options[:singleton] -%> -| <%%= link_to 'Back', <%= index_helper %>_path %> -<% end -%> +<%- unless options[:singleton] -%> +<%%= link_to 'Edit', edit_<%= singular_table_name %>_path(@<%= singular_table_name %>) %> | <%%= link_to 'Back', <%= index_helper %>_path %> +<%- else -%> +<%%= link_to 'Edit', edit_<%= singular_table_name %>_path %> +<%- end -%> -- 1.7.0.4