Skip to content

Commit

Permalink
Idempotent spina generator + allow debugging routes
Browse files Browse the repository at this point in the history
  • Loading branch information
harmdewit committed Jan 21, 2016
1 parent fd8cfa0 commit e318db5
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
6 changes: 5 additions & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,5 +85,9 @@

# get ':materialized_pathroot/:subpage/:id' => "pages#show", as: "third_level_page"
# get ':root/:id' => "pages#show", as: "subpage"
get '/*id' => "pages#show", as: "page", controller: 'pages'
get '/*id' => 'pages#show', as: "page", controller: 'pages', constraints: lambda { |request|
!Rails.env.development? && !request.env['PATH_INFO'].starts_with?('/rails/')
}

end

3 changes: 3 additions & 0 deletions lib/generators/spina/install_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,13 @@ def copy_views
end

def create_account
return if Account.exists?
name = ask('What would you like to name your website?')
Account.create name: name, theme: 'default'
end

def create_user
return if User.exists?
email = ask('Please enter an email address for your first user:')
password = ask('Create a temporary password:')
User.create name: 'admin', email: email, password: password, admin: true
Expand All @@ -42,6 +44,7 @@ def bootstrap_spina
end

def add_route
return if Rails.application.routes.routes.detect { |route| route.app.app == Spina::Engine }
route "mount Spina::Engine => '/'"
end

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Spina::Engine.configure do
config.NEGATIVE_CAPTCHA_SECRET = '<%= SecureRandom.hex(64) %>'
config.NEGATIVE_CAPTCHA_SECRET = '<%= Spina::Engine.config.try(:NEGATIVE_CAPTCHA_SECRET) || SecureRandom.hex(64) %>'

# Important Note
# ==============
Expand Down
2 changes: 1 addition & 1 deletion test/dummy/db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20160108105712) do
ActiveRecord::Schema.define(version: 20160114085213) do

# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
Expand Down

0 comments on commit e318db5

Please sign in to comment.