small medium large xlarge


Activity 1

Modify the user update function to require and validate the current password before allowing a user’s password to be changed.

Hint: you can add markup specific to a particular action in _form.html.erb by adding an if check ensuring that params[:action] is the one you want.

Hint: you can simultaneously retrieve and remove the non-database field from the params hash by using the delete method.


Activity 2

When the system is freshly installed on a new machine, there are no administrators defined in the database, and hence no administrator can log on. But, if no administrator can log on, then no one can create an administrative user. Change the code so that if no administrator is defined in the database, any username works to log on (allowing you to quickly create a real administrator).

Hint: can be used to determine if there are any existing users.


Activity 3

Experiment with rails console. Try creating products, orders, and line items. Watch for the return value when you save a model object—when validation fails, you’ll see false returned. Find out why by examining the errors.

Hint: check out the documentation for full_messages


Page History
  • V18: Denis Hovart [over 1 year ago]
  • V17: eric tenne [about 2 years ago]
  • V16: Sam Ruby [over 6 years ago]
  • V15: Sam Ruby [over 6 years ago]
  • V14: Sam Ruby [over 6 years ago]
  • V13: Sam Ruby [over 6 years ago]
  • V12: Sam Ruby [over 6 years ago]
  • V11: Andrew de Andrade [over 7 years ago]
  • V10: Andrew de Andrade [over 7 years ago]
  • V9: Andrew de Andrade [over 7 years ago]