Rails 4 Seeding Devise Admins -
i've seen few questions how go seeding users / admins / people through devise none of them working me , i'd assume it's because using rails4.
i need 1 seed. set straight seed file
admin = admin.new admin.email = 'adminone@gmail.com' admin.password = "topsecret" admin.password_confirmation = "topsecret" admin.save!
that did not work...
neither did this...
admin = admin.create! :name => 'john doe', :email => 'john@gmail.com', :password => 'topsecret', :password_confirmation => 'topsecret'
the seed functions, when seek login, invalid combination.
thoughts? i'm using
devise :database_authenticatable, :registerable, #:recoverable, :rememberable, :trackable, :validatable
for model.
update: entire applicationcontroller.rb
class applicationcontroller < actioncontroller::base before_filter :set_mail # prevent csrf attacks raising exception. # apis, may want utilize :null_session instead. protect_from_forgery with: :exception def set_mail @mail_subscriber = mailsubscriber.new(mail_subscriber_params) end private def current_cart cart = cart.find(session[:cart_id]) unless cart.active? cart = cart.create session[:cart_id] = cart.id end cart rescue activerecord::recordnotfound cart = cart.create session[:cart_id] = cart.id cart end def mail_subscriber_params params.fetch(:mail_subscriber, {}).permit(:email, :name) end end
update #2
admin.valid_password?("topsecret")
gives me, seed must not have worked?
bcrypt::errors::invalidhash: invalid hash
admin.create! :email => 'john@gmail.com', :password => 'topsecret', :password_confirmation => 'topsecret'
did not work but
admin.create :email => 'john@gmail.com', :password => 'topsecret', :password_confirmation => 'topsecret'
did work. difference ! after 'create'
hopefully helps people run issue in future
ruby-on-rails ruby-on-rails-4 devise
No comments:
Post a Comment