Skip to content

Commit

Permalink
Merge pull request #3792 from excid3/master
Browse files Browse the repository at this point in the history
Automatically underscore and pluralize scoped views generator
  • Loading branch information
josevalim committed Oct 21, 2015
2 parents 9568e28 + 005d514 commit d6dc93c
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lib/generators/devise/views_generator.rb
Expand Up @@ -47,15 +47,19 @@ def copy_views
def view_directory(name, _target_path = nil)
directory name.to_s, _target_path || "#{target_path}/#{name}" do |content|
if scope
content.gsub "devise/shared/links", "#{scope}/shared/links"
content.gsub "devise/shared/links", "#{plural_scope}/shared/links"
else
content
end
end
end

def target_path
@target_path ||= "app/views/#{scope || :devise}"
@target_path ||= "app/views/#{plural_scope || :devise}"
end

def plural_scope
@plural_scope ||= scope.presence && scope.underscore.pluralize
end
end

Expand Down Expand Up @@ -118,7 +122,7 @@ def copy_views
end

def target_path
"app/views/#{scope || :devise}/mailer"
"app/views/#{plural_scope || :devise}/mailer"
end
end

Expand Down

0 comments on commit d6dc93c

Please sign in to comment.