Skip to content

Commit

Permalink
Fixed route generation to include devise_for prior to the mounted engine
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric Berry committed Sep 26, 2012
1 parent f447386 commit bf42a6f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions lib/generators/rails_admin/install_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ def install
display "Looks like you've already installed it, good!"
end

namespace = ask_for("Where do you want to mount rails_admin?", "admin", _namespace)
gsub_file "config/routes.rb", /mount RailsAdmin::Engine => \'\/.+\', :as => \'rails_admin\'/, ''
route("mount RailsAdmin::Engine => '/#{namespace}', :as => 'rails_admin'")

unless routes.index("devise_for")
model_name = ask_for("What would you like the user model to be called?", "user", _model_name)
display "Now setting up devise with user model name '#{model_name}':"
Expand Down Expand Up @@ -75,9 +79,6 @@ def install
end
display "Adding a migration..."
migration_template 'migration.rb', 'db/migrate/create_rails_admin_histories_table.rb' rescue display $!.message
namespace = ask_for("Where do you want to mount rails_admin?", "admin", _namespace)
gsub_file "config/routes.rb", /mount RailsAdmin::Engine => \'\/.+\', :as => \'rails_admin\'/, ''
route("mount RailsAdmin::Engine => '/#{namespace}', :as => 'rails_admin'")
display "Job's done: migrate, start your server and visit '/#{namespace}'!", :blue
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/dummy_app/config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
# Needed for :show_in_app tests
resources :players, :only => [:show]

mount RailsAdmin::Engine => '/admin', :as => 'rails_admin'
devise_for :users
mount RailsAdmin::Engine => '/admin', :as => 'rails_admin'
root :to => "rails_admin::Main#dashboard"
# https://github.com/sferik/rails_admin/issues/362
match ':controller(/:action(/:id(.:format)))'
Expand Down

0 comments on commit bf42a6f

Please sign in to comment.