Skip to content

Commit

Permalink
Automatically underscore and pluralize scoped views generator. Fixes h…
Browse files Browse the repository at this point in the history
  • Loading branch information
excid3 committed Oct 21, 2015
1 parent 9568e28 commit 005d514
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lib/generators/devise/views_generator.rb
Original file line number Diff line number Diff line change
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 005d514

Please sign in to comment.