Skip to content

Commit

Permalink
more for 'confirmable' and 'invitable' options to 'devise' recipe
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielKehoe committed Feb 23, 2012
1 parent b594107 commit 1d5cb76
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.textile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ h2. 1.1.5 unreleased
* add 'confirmable' and 'invitable' options to 'devise' recipe
* change prompt for 'guard' recipe
* add 'rake db:test:prepare' to 'seed_database' recipe
* remove 'add_user_name' recipe (replaced by 'add_user' recipe)

h2. 1.1.4 February 21, 2012

Expand Down
17 changes: 11 additions & 6 deletions recipes/add_user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,9 @@
# Generate models and routes for a User
generate 'devise user'

if recipes.include? 'devise-confirmable'
gsub_file 'app/models/user.rb', /:registerable,/, ":registerable, :confirmable,"
generate 'migration AddConfirmableToUsers confirmation_token:string confirmed_at:datetime confirmation_sent_at:datetime unconfirmed_email:string'
end

# Add a 'name' attribute to the User model
if recipes.include? 'mongoid'
# for mongoid
gsub_file 'app/models/user.rb', /end/ do
<<-RUBY
field :name
Expand All @@ -40,6 +36,9 @@
# for ActiveRecord
# Devise created a Users database, we'll modify it
generate 'migration AddNameToUsers name:string'
if recipes.include? 'devise-confirmable'
generate 'migration AddConfirmableToUsers confirmation_token:string confirmed_at:datetime confirmation_sent_at:datetime unconfirmed_email:string'
end
# Devise created a Users model, we'll modify it
gsub_file 'app/models/user.rb', /attr_accessible :email/, 'attr_accessible :name, :email'
inject_into_file 'app/models/user.rb', :before => 'validates_uniqueness_of' do
Expand All @@ -48,8 +47,14 @@
gsub_file 'app/models/user.rb', /validates_uniqueness_of :email/, 'validates_uniqueness_of :name, :email'
end

# needed for both mongoid and ActiveRecord
if recipes.include? 'devise-confirmable'
gsub_file 'app/models/user.rb', /:registerable,/, ":registerable, :confirmable,"
gsub_file 'app/models/user.rb', /:remember_me/, ':remember_me, :confirmed_at'
end

unless recipes.include? 'haml'

# Generate Devise views (unless you are using Haml)
run 'rails generate devise:views'

Expand Down
3 changes: 3 additions & 0 deletions recipes/cucumber.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@
get 'https://raw.github.com/RailsApps/rails3-devise-rspec-cucumber/master/features/step_definitions/user_steps.rb', 'features/step_definitions/user_steps.rb'
remove_file 'features/support/paths.rb'
get 'https://raw.github.com/RailsApps/rails3-devise-rspec-cucumber/master/features/support/paths.rb', 'features/support/paths.rb'
if recipes.include? 'devise-confirmable'
gsub_file 'features/step_definitions/user_steps.rb', /Welcome! You have signed up successfully./, "A message with a confirmation link has been sent to your email address."
end
rescue OpenURI::HTTPError
say_wizard "Unable to obtain Cucumber example files from the repo"
end
Expand Down
3 changes: 3 additions & 0 deletions recipes/seed_database.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@
puts 'New user created: ' << user.name
FILE
end
if recipes.include? 'devise-confirmable'
gsub_file 'db/seeds.rb', /:password_confirmation => 'please'/, ":password_confirmation => 'please', :confirmed_at => DateTime.now"
end
end

run 'bundle exec rake db:seed'
Expand Down

0 comments on commit 1d5cb76

Please sign in to comment.