Newsstand 2: Still not a news stan?

NGL the Newsstand 2 project kind of made me loose some very important cupcakes so let me first share some cake because I’m not into cakes being a lie :cupcake:

Now that’s out of the way I don’t know why the project did not port the saved data from the first News Stand project which means for me but hopefully not you Step 1 with the ol’ rails serve -p 4001 step results in a false start. This mean it was bascially throw out the projects play book and cobble it together mixing both exercise 1 and 2 together.

This was my approach:
From the first News Stand:

  • Bundle Install all the gems.

  • Your going to likely see a pending migration error so
    bundle exec rake db:migrate

  • bundle exec rake db:seed because otherwise you won’t have any articles either as per the first project.

  • you can run the rails server here if you want just to make sure everything loaded… or not but I think you’ll see that electric blue background and stuff anyway mine did it automatically.

  • uncomment the bcrypt gem and then bundle install that cryptkeeper (sorry I had to)

  • rails generate model User

  • Go to app db: migrate Users and add these column in to the table.

To this point this is where step 2 is now on the new project. You can do the rails generate migration step outlined in the project or just add it in manually with all your other t.strings:

  1. t.string :firstname
  2. t.string :last_name
    3.t,string :email- (the dash is there because it keeps on wanting to add emailmoji but it should just read colon email to create the hash object)
    4.t.string :password You neeed to add this in I wrote about it in another post but basically it was an exercise oversight and you need to add this column or your authenticate won’t work
    5.t.string :password_digest
    6. t.string :role (this is the step to which you can add straight into your user model or do it their way you do you)

save and to be meticulous run bundle exec rake db:migrate again just to make sure your table is set for a feast !!!

  • because this is fusing the two projects I added the def has_secure_password into the user model because otherwise though I didn’t take note of it I think I got an error. Curse you inferior note taking.

  • Step four they’re being a little vague about but honestly just open a new bash tab and do User.Create (first_name: 'Edna’ect…)like you did in the first project. Honestly I just did Edna with the role: ‘author’ and then another User that was just your basic User with no powers.

Now the rest of the exercise should work for you. If you’re stumped on what to write for the other steps just go back to exercise 6 in the Authorization exercises to find the code you need. You need to tweak one or two names here and there but you got this.