The entry was being created before the product was saved, so the URL was
incorrect. Now it is generated after the save and works correctly.
Signed-off-by: Darryl L. Pierce <mcpierce(a)gmail.com>
---
app/controllers/products_controller.rb | 19 +++++++++++++------
doc/ChangeLog | 1 +
2 files changed, 14 insertions(+), 6 deletions(-)
diff --git a/app/controllers/products_controller.rb
b/app/controllers/products_controller.rb
index 25d74f2..c8d8190 100644
--- a/app/controllers/products_controller.rb
+++ b/app/controllers/products_controller.rb
@@ -101,14 +101,14 @@ class ProductsController < ApplicationController
Product.transaction do
@product = Product.new(params[:product])
@product.project = @project
- @product.rss_entries << create_rss_entry("New product created:
#{(a)product.name}",
- products_url(@product),
- "A new product was
created:\r#{@product.description}}")
if @product.project.can_create_products?(@user)
if @product.save
flash[:message] = "Product created successfully."
format.html { redirect_to product_path(@product) }
+ add_rss_entry(create_rss_entry("New product created:
#{(a)product.name}",
+ product_url(@product),
+ "A new product was
created:\r#{@product.description}}"))
else
@title = "New Product"
@users = User.find(:all, :order => 'display_name ASC')
@@ -136,11 +136,11 @@ class ProductsController < ApplicationController
begin
Product.transaction do
@product.update_attributes(params[:product])
- @product.rss_entries << create_rss_entry("Details updated:
#{(a)product.name}",
- product_url(@product),
- "The product's details
have been updated...")
if @product.save
+ add_rss_entry(create_rss_entry("Details updated:
#{(a)product.name}",
+ product_url(@product),
+ "The product's details have been
updated..."))
flash[:message] = "#{(a)product.name} successfully updated."
format.html { redirect_to product_path(@product) }
else
@@ -200,6 +200,13 @@ class ProductsController < ApplicationController
end
end
+ def add_rss_entry rss_entry
+ Project.transaction do
+ @product.rss_entries << rss_entry
+ @product.save
+ end
+ end
+
def path_to_list
@project = Project.find_by_id(params[:project]) if params[:project]
if @project
diff --git a/doc/ChangeLog b/doc/ChangeLog
index ad1709e..94c7fcb 100644
--- a/doc/ChangeLog
+++ b/doc/ChangeLog
@@ -47,6 +47,7 @@ Change Log (0.3.0):
* #220 - When a user has project admin rights, then the link will say "Create"
not "Request". (BUG)
* #221 - When requesting a product role, the URL is broken. (BUG)
* #222 - Fixed creating/editing products using the wrong URL. (BUG)
+ * #228 - Fixed the URL in the product creation RSS entry. (BUG)
Change Log (0.2.0):
* #97 - Users can request new projects.
--
1.6.2.5
Show replies by date