lib/active_admin/comments.rb in activeadmin-0.2.1 vs lib/active_admin/comments.rb in activeadmin-0.2.2

- old
+ new

@@ -51,9 +51,24 @@ before_save do |comment| comment.namespace = active_admin_config.namespace.name comment.author = current_active_admin_user end + # Redirect to the resource show page when failing to add a comment + # TODO: Provide helpers to make such kind of customization much simpler + controller do + def create + create! do |success, failure| + failure.html do + resource_config = active_admin_config.namespace.resource_for(@comment.resource.class) + flash[:error] = "Comment wasn't saved, text was empty." + redirect_to send(resource_config.route_instance_path, @comment.resource) + end + end + end + end + + # Display as a table index do column("Resource"){|comment| auto_link(comment.resource) } column("Author"){|comment| auto_link(comment.author) } column :body