Skip to content

Commit

Permalink
Cached the class_path and changed a variable name (kudos to @britto!)
Browse files Browse the repository at this point in the history
  • Loading branch information
Rodrigo Flores committed May 2, 2012
1 parent 67f2074 commit 34a6407
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/generators/active_record/devise_generator.rb
Expand Up @@ -27,10 +27,12 @@ def inject_devise_content
attr_accessible :email, :password, :password_confirmation, :remember_me
CONTENT

indent_size = class_name.to_s.split("::").size - 1
content = content.split("\n").map { |line| " " * indent_size + line}.join("\n")
class_path = class_name.to_s.split("::")

inject_into_class(model_path, class_name.to_s.split("::").last, content) if model_exists?
indent_depth = class_path.size - 1
content = content.split("\n").map { |line| " " * indent_depth + line } .join("\n")

inject_into_class(model_path, class_path.last, content) if model_exists?
end

def migration_data
Expand Down

0 comments on commit 34a6407

Please sign in to comment.