diff --git a/lib/generators/rails/templates/controller.rb b/lib/generators/rails/templates/controller.rb index c6f78e6..d58aa55 100644 --- a/lib/generators/rails/templates/controller.rb +++ b/lib/generators/rails/templates/controller.rb @@ -34,9 +34,9 @@ def create respond_to do |format| if @<%= orm_instance.save %> format.html { redirect_to @<%= singular_table_name %>, notice: <%= "'#{human_name} was successfully created.'" %> } - format.json { render action: 'show', status: :created, location: <%= "@#{singular_table_name}" %> } + format.json { render :show, status: :created, location: <%= "@#{singular_table_name}" %> } else - format.html { render action: 'new' } + format.html { render :new } format.json { render json: <%= "@#{orm_instance.errors}" %>, status: :unprocessable_entity } end end @@ -48,9 +48,9 @@ def update respond_to do |format| if @<%= orm_instance.update("#{singular_table_name}_params") %> format.html { redirect_to @<%= singular_table_name %>, notice: <%= "'#{human_name} was successfully updated.'" %> } - format.json { render action: 'show', status: :ok, location: <%= "@#{singular_table_name}" %> } + format.json { render :show, status: :ok, location: <%= "@#{singular_table_name}" %> } else - format.html { render action: 'edit' } + format.html { render :edit } format.json { render json: <%= "@#{orm_instance.errors}" %>, status: :unprocessable_entity } end end diff --git a/test/scaffold_controller_generator_test.rb b/test/scaffold_controller_generator_test.rb index 577afb1..0ff0100 100644 --- a/test/scaffold_controller_generator_test.rb +++ b/test/scaffold_controller_generator_test.rb @@ -31,15 +31,15 @@ class ScaffoldControllerGeneratorTest < Rails::Generators::TestCase assert_match /@post = Post\.new\(post_params\)/, m assert_match /@post\.save/, m assert_match /format\.html \{ redirect_to @post, notice: 'Post was successfully created\.' \}/, m - assert_match /format\.json \{ render action: 'show', status: :created, location: @post \}/, m - assert_match /format\.html \{ render action: 'new' \}/, m + assert_match /format\.json \{ render :show, status: :created, location: @post \}/, m + assert_match /format\.html \{ render :new \}/, m assert_match /format\.json \{ render json: @post\.errors, status: :unprocessable_entity \}/, m end assert_instance_method :update, content do |m| assert_match /format\.html \{ redirect_to @post, notice: 'Post was successfully updated\.' \}/, m - assert_match /format\.json \{ render action: 'show', status: :ok, location: @post \}/, m - assert_match /format\.html \{ render action: 'edit' \}/, m + assert_match /format\.json \{ render :show, status: :ok, location: @post \}/, m + assert_match /format\.html \{ render :edit \}/, m assert_match /format\.json \{ render json: @post.errors, status: :unprocessable_entity \}/, m end