Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/controllers/categories_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def create
authorize! @category

if @category.save
redirect_to categories_path, notice: "Category was successfully created."
redirect_to @category, notice: "Category was successfully created."
else
set_form_variables
render :new, status: :unprocessable_content
Expand All @@ -53,7 +53,7 @@ def update
authorize! @category
respond_to do |format|
if @category.update(category_params)
format.html { redirect_to categories_path, notice: "Category was successfully updated.", status: :see_other }
format.html { redirect_to @category, notice: "Category was successfully updated.", status: :see_other }
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

decided against having "Base data" tables CRUD differently. now they all go to show after create.

format.json { head :ok }
else
format.html do
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/category_types_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def create
authorize! @category_type

if @category_type.save
redirect_to category_types_path, notice: "Category type was successfully created."
redirect_to @category_type, notice: "Category type was successfully created."
else
@category_type = @category_type.decorate
render :new, status: :unprocessable_content
Expand All @@ -39,7 +39,7 @@ def create
def update
authorize! @category_type
if @category_type.update(category_type_params)
redirect_to category_types_path, notice: "Category type was successfully updated.", status: :see_other
redirect_to @category_type, notice: "Category type was successfully updated.", status: :see_other
else
@category_type = @category_type.decorate
render :edit, status: :unprocessable_content
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/faqs_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def create
authorize! @faq

if @faq.save
redirect_to faqs_path, notice: "FAQ was successfully created."
redirect_to @faq, notice: "FAQ was successfully created."
else
set_form_variables
render :new, status: :unprocessable_content
Expand All @@ -42,7 +42,7 @@ def update
notice = "FAQ was successfully updated."
flash.now[:notice] = notice
if @faq.update(faq_params)
redirect_to faqs_path, notice: notice, status: :see_other
redirect_to @faq, notice: notice, status: :see_other
else
set_form_variables
render :edit, status: :unprocessable_content
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/organization_statuses_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def create
authorize! @organization_status

if @organization_status.save
redirect_to organization_statuses_path, notice: "Organization status was successfully created."
redirect_to @organization_status, notice: "Organization status was successfully created."
else
@organization_status = OrganizationStatus.new.decorate
set_form_variables
Expand All @@ -42,7 +42,7 @@ def create
def update
authorize! @organization_status
if @organization_status.update(organization_status_params)
redirect_to organization_statuses_path, notice: "Organization status was successfully updated.", status: :see_other
redirect_to @organization_status, notice: "Organization status was successfully updated.", status: :see_other
else
@organization_status = OrganizationStatus.new.decorate
set_form_variables
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/sectors_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def create
authorize! @sector

if @sector.save
redirect_to sectors_path, notice: "Sector was successfully created."
redirect_to @sector, notice: "Sector was successfully created."
else
set_form_variables
render :new, status: :unprocessable_content
Expand All @@ -42,7 +42,7 @@ def create
def update
authorize! @sector
if @sector.update(sector_params)
redirect_to sectors_path, notice: "Sector was successfully updated.", status: :see_other
redirect_to @sector, notice: "Sector was successfully updated.", status: :see_other
else
set_form_variables
render :edit, status: :unprocessable_content
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/windows_types_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def create
@windows_type.categories = Category.where(id: selected_ids)

if @windows_type.save
redirect_to windows_types_path, notice: "Windows type was successfully created."
redirect_to @windows_type, notice: "Windows type was successfully created."
else
set_form_variables
render :new, status: :unprocessable_content
Expand All @@ -47,7 +47,7 @@ def update
@windows_type.categories = Category.where(id: selected_ids)

if @windows_type.update(windows_type_params)
redirect_to windows_types_path, notice: "Windows type was successfully updated.", status: :see_other
redirect_to @windows_type, notice: "Windows type was successfully updated.", status: :see_other
else
set_form_variables
render :edit, status: :unprocessable_content
Expand Down
4 changes: 2 additions & 2 deletions lib/templates/rails/scaffold_controller/controller.rb.tt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class <%= controller_class_name %>Controller < ApplicationController
@<%= singular_table_name %> = <%= orm_class.build(class_name, "#{singular_table_name}_params") %>

if @<%= orm_instance.save %>
redirect_to <%= index_helper %>_path, notice: "<%= human_name %> was successfully created."
redirect_to @<%= singular_table_name %>, notice: "<%= human_name %> was successfully created."
else
@<%= singular_table_name %> = <%= orm_class.build(class_name) %>.decorate
set_form_variables
Expand All @@ -38,7 +38,7 @@ class <%= controller_class_name %>Controller < ApplicationController

def update
if @<%= orm_instance.update("#{singular_table_name}_params") %>
redirect_to <%= index_helper %>_path, notice: "<%= human_name %> was successfully updated.", status: :see_other
redirect_to @<%= singular_table_name %>, notice: "<%= human_name %> was successfully updated.", status: :see_other
else
@<%= singular_table_name %> = <%= orm_class.build(class_name) %>.decorate
set_form_variables
Expand Down
2 changes: 1 addition & 1 deletion spec/requests/categories_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
post categories_path, params: { category: valid_attributes }
}.to change(Category, :count).by(1)

expect(response).to redirect_to(categories_path)
expect(response).to redirect_to(category_path(Category.last))
end
end

Expand Down
8 changes: 4 additions & 4 deletions spec/requests/faqs_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,9 @@
}.to change(Faq, :count).by(1)
end

it "redirects to the faqs index" do
it "redirects to the created faq" do
post faqs_url, params: { faq: valid_attributes }
expect(response).to redirect_to(faqs_url)
expect(response).to redirect_to(faq_url(Faq.last))
end
end

Expand Down Expand Up @@ -176,9 +176,9 @@
expect(faq.answer).to eq("Updated answer text.")
end

it "redirects to the faqs index" do
it "redirects to the faq" do
patch faq_url(faq), params: { faq: new_attributes }
expect(response).to redirect_to(faqs_url)
expect(response).to redirect_to(faq_url(faq))
end
end

Expand Down
4 changes: 2 additions & 2 deletions spec/requests/organization_statuses_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
post organization_statuses_path, params: valid_params
}.to change(OrganizationStatus, :count).by(1)

expect(response).to redirect_to(organization_statuses_path)
expect(response).to redirect_to(organization_status_path(OrganizationStatus.last))
end

it "rejects invalid create" do
Expand All @@ -51,7 +51,7 @@
patch organization_status_path(status),
params: { organization_status: { name: "Updated" } }

expect(response).to redirect_to(organization_statuses_path)
expect(response).to redirect_to(organization_status_path(status))
expect(status.reload.name).to eq("Updated")
end

Expand Down
8 changes: 4 additions & 4 deletions spec/requests/sectors_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@
}.to change(Sector, :count).by(1)
end

it "redirects to sectors index" do
it "redirects to the created sector" do
post sectors_url, params: { sector: valid_attributes }
expect(response).to redirect_to(sectors_url)
expect(response).to redirect_to(sector_url(Sector.last))
end
end

Expand Down Expand Up @@ -95,11 +95,11 @@
skip("Add assertions for updated state")
end

it "redirects to the sectors index" do
it "redirects to the sector" do
sector = Sector.create! valid_attributes
patch sector_url(sector), params: { sector: new_attributes }
sector.reload
expect(response).to redirect_to(sectors_url)
expect(response).to redirect_to(sector_url(sector))
end
end

Expand Down
4 changes: 2 additions & 2 deletions spec/requests/windows_types_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@

it "redirects to the created windows_type" do
post windows_types_url, params: { windows_type: valid_attributes }
expect(response).to redirect_to(windows_types_url)
expect(response).to redirect_to(windows_type_url(WindowsType.last))
end
end

Expand Down Expand Up @@ -96,7 +96,7 @@
it "redirects to the windows_type" do
windows_type = WindowsType.create!(valid_attributes)
patch windows_type_url(windows_type), params: { windows_type: new_attributes }
expect(response).to redirect_to(windows_types_url)
expect(response).to redirect_to(windows_type_url(windows_type))
end
end

Expand Down