Skip to content

Commit

Permalink
[fix] undefined #private_show_path for layout, part
Browse files Browse the repository at this point in the history
  • Loading branch information
itowtips committed Jun 29, 2016
1 parent 768b17a commit 0763b96
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 0 deletions.
22 changes: 22 additions & 0 deletions app/models/concerns/cms/model/layout.rb
Expand Up @@ -31,6 +31,28 @@ def body
return html =~ /<body/ ? html.sub(/.*?(<body.*<\/body>).*/im, '\\1') : nil
end

# returns admin side show path
def private_show_path(*args)
model = self.class.name.underscore.sub(/^.+?\//, "")
options = args.extract_options!
methods = []
if parent.blank?
options = options.merge(site: site || cur_site, id: self)
methods << "cms_#{model}_path"
else
options = options.merge(site: site || cur_site, cid: parent, id: self)
methods << "node_#{model}_path"
end

helper_mod = Rails.application.routes.url_helpers
methods.each do |method|
path = helper_mod.send(method, *args, options) rescue nil
return path if path.present?
end

nil
end

private
def fix_extname
".layout.html"
Expand Down
22 changes: 22 additions & 0 deletions app/models/concerns/cms/model/node.rb
Expand Up @@ -118,6 +118,28 @@ def move(dst)
save
end

# returns admin side show path
def private_show_path(*args)
model = "node"
options = args.extract_options!
methods = []
if parent.blank?
options = options.merge(site: site || cur_site, id: self)
methods << "cms_#{model}_path"
else
options = options.merge(site: site || cur_site, cid: parent, id: self)
methods << "node_#{model}_path"
end

helper_mod = Rails.application.routes.url_helpers
methods.each do |method|
path = helper_mod.send(method, *args, options) rescue nil
return path if path.present?
end

nil
end

private
def validate_node_filename
errors.add :basename, :invalid if filename == "fs"
Expand Down
22 changes: 22 additions & 0 deletions app/models/concerns/cms/model/part.rb
Expand Up @@ -40,6 +40,28 @@ def ajax_html
%(<a class="ss-part" data-href="#{json}">#{name}</a>)
end

# returns admin side show path
def private_show_path(*args)
model = "part"
options = args.extract_options!
methods = []
if parent.blank?
options = options.merge(site: site || cur_site, id: self)
methods << "cms_#{model}_path"
else
options = options.merge(site: site || cur_site, cid: parent, id: self)
methods << "node_#{model}_path"
end

helper_mod = Rails.application.routes.url_helpers
methods.each do |method|
path = helper_mod.send(method, *args, options) rescue nil
return path if path.present?
end

nil
end

private
def fix_extname
".part.html"
Expand Down

0 comments on commit 0763b96

Please sign in to comment.