From e738acd08052c73cd5b52cd8c706f6982ba1ca8c Mon Sep 17 00:00:00 2001 From: Guillermo Iguaran Date: Sat, 22 Dec 2012 23:46:51 -0500 Subject: Fix syntax error in controller template --- .../rails/scaffold_controller/templates/controller.rb | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'railties/lib/rails/generators') diff --git a/railties/lib/rails/generators/rails/scaffold_controller/templates/controller.rb b/railties/lib/rails/generators/rails/scaffold_controller/templates/controller.rb index 8f2967bc61..999a29b18d 100644 --- a/railties/lib/rails/generators/rails/scaffold_controller/templates/controller.rb +++ b/railties/lib/rails/generators/rails/scaffold_controller/templates/controller.rb @@ -12,7 +12,9 @@ class <%= controller_class_name %>Controller < ApplicationController @<%= plural_table_name %> = <%= orm_class.all(class_name) %> respond_to do |format| - <%- if options[:html] -%>format.html # index.html.erb<%- end -%> + <%- if options[:html] -%> + format.html # index.html.erb + <%- end -%> format.json { render json: <%= "@#{plural_table_name}" %> } end end @@ -21,7 +23,9 @@ class <%= controller_class_name %>Controller < ApplicationController # GET <%= route_url %>/1.json def show respond_to do |format| - <%- if options[:html] -%>format.html # show.html.erb<%- end -%> + <%- if options[:html] -%> + format.html # show.html.erb + <%- end -%> format.json { render json: <%= "@#{singular_table_name}" %> } end end @@ -55,7 +59,9 @@ class <%= controller_class_name %>Controller < ApplicationController <%- end -%> format.json { render json: <%= "@#{singular_table_name}" %>, status: :created, location: <%= "@#{singular_table_name}" %> } else - <%- if options[:html] -%>format.html { render action: "new" }<%- end -%> + <%- if options[:html] -%> + format.html { render action: "new" } + <%- end -%> format.json { render json: <%= "@#{orm_instance.errors}" %>, status: :unprocessable_entity } end end @@ -83,7 +89,9 @@ class <%= controller_class_name %>Controller < ApplicationController @<%= orm_instance.destroy %> respond_to do |format| - <%- if options[:html] -%>format.html { redirect_to <%= index_helper %>_url }<%- end -%> + <%- if options[:html] -%> + format.html { redirect_to <%= index_helper %>_url } + <%- end -%> format.json { head :no_content } end end -- cgit v1.2.3