diff options
author | José Valim <jose.valim@gmail.com> | 2010-03-17 00:08:59 +0100 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2010-03-17 00:09:43 +0100 |
commit | 7a5da2148140eb6824e283d7100727f7227a071e (patch) | |
tree | fdf14423d5ec2cef450871be03a92e54f1e66afc /railties/lib | |
parent | 23b6def0eb76ac0719e420fce91ba862f880a37b (diff) | |
download | rails-7a5da2148140eb6824e283d7100727f7227a071e.tar.gz rails-7a5da2148140eb6824e283d7100727f7227a071e.tar.bz2 rails-7a5da2148140eb6824e283d7100727f7227a071e.zip |
Use human_name in scaffold.
Diffstat (limited to 'railties/lib')
3 files changed, 7 insertions, 3 deletions
diff --git a/railties/lib/generators/erb/scaffold/templates/index.html.erb b/railties/lib/generators/erb/scaffold/templates/index.html.erb index b5c7fd1e58..d30d306d42 100644 --- a/railties/lib/generators/erb/scaffold/templates/index.html.erb +++ b/railties/lib/generators/erb/scaffold/templates/index.html.erb @@ -24,4 +24,4 @@ <br /> -<%%= link_to 'New <%= singular_name %>', new_<%= singular_name %>_path %> +<%%= link_to 'New <%= human_name %>', new_<%= singular_name %>_path %> diff --git a/railties/lib/generators/rails/scaffold_controller/templates/controller.rb b/railties/lib/generators/rails/scaffold_controller/templates/controller.rb index 874e96a2b4..bbdce669dc 100644 --- a/railties/lib/generators/rails/scaffold_controller/templates/controller.rb +++ b/railties/lib/generators/rails/scaffold_controller/templates/controller.rb @@ -46,7 +46,7 @@ class <%= controller_class_name %>Controller < ApplicationController respond_to do |format| if @<%= orm_instance.save %> - format.html { redirect_to(@<%= file_name %>, :notice => '<%= class_name %> was successfully created.') } + format.html { redirect_to(@<%= file_name %>, :notice => '<%= human_name %> was successfully created.') } format.xml { render :xml => @<%= file_name %>, :status => :created, :location => @<%= file_name %> } else format.html { render :action => "new" } @@ -62,7 +62,7 @@ class <%= controller_class_name %>Controller < ApplicationController respond_to do |format| if @<%= orm_instance.update_attributes("params[:#{file_name}]") %> - format.html { redirect_to(@<%= file_name %>, :notice => '<%= class_name %> was successfully updated.') } + format.html { redirect_to(@<%= file_name %>, :notice => '<%= human_name %> was successfully updated.') } format.xml { head :ok } else format.html { render :action => "edit" } diff --git a/railties/lib/rails/generators/named_base.rb b/railties/lib/rails/generators/named_base.rb index 12e918731e..8d1dfbd947 100644 --- a/railties/lib/rails/generators/named_base.rb +++ b/railties/lib/rails/generators/named_base.rb @@ -27,6 +27,10 @@ module Rails @class_name ||= (class_path + [file_name]).map!{ |m| m.camelize }.join('::') end + def human_name + @human_name ||= singular_name.humanize + end + def plural_name @plural_name ||= singular_name.pluralize end |