Skip to content

Commit 3b77c66

Browse files
committed
Auto-set wiki slug
1 parent c62f7f7 commit 3b77c66

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

app/models/node.rb

+3-2
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def slug_from_path
9898

9999
before_save :set_changed_and_created
100100
after_create :setup
101-
before_validation :set_path, on: :create
101+
before_validation :set_path_and_slug, on: :create
102102

103103
# can switch to a "question-style" path if specified
104104
def path(type = :default)
@@ -127,8 +127,9 @@ def generate_path
127127

128128
private
129129

130-
def set_path
130+
def set_path_and_slug
131131
self.path = generate_path if path.blank? && !title.blank?
132+
self.slug = self.path.split('/').last unless self.path.blank?
132133
end
133134

134135
def set_changed_and_created

0 commit comments

Comments
 (0)