Skip to content

Instantly share code, notes, and snippets.

@priyapower
Last active August 24, 2020 20:52
Show Gist options
  • Save priyapower/8db1c247d04f362627ab23cea384fa9e to your computer and use it in GitHub Desktop.
Save priyapower/8db1c247d04f362627ab23cea384fa9e to your computer and use it in GitHub Desktop.
Turing School Project Reflections

Project Reflections Journal

PROJECT PAGES
Mod 1 Projects
Mod 2 Projects
Mod 3 Projects
Mod 4 Projects

Mod 1

Mod 1 - Week 1: War or Peace

Details:

  • FIRST project
  • Solo Project
  • Completed until Iteration 3 for pass
  • Completed Iteration 4 for extension practice

Reflections:

Wow, this was a scary project. This was my first bit of true coding project (all others coding projects were from kids tutorials) . I was scared of how much I could actually complete since I had zero grasp of how quickly I might be able to work and what was effective work. This was stressful because even though they gave us an insane amount of structure and direction, it was my first time turing in something like this. All previous work or school projects were typically presentations/deliverables that I had plenty of practice or a skill set in. Then I realized, this isn't quite true. I'm basically forgetting all my fears at the beginning on any new job or situation. When I was beginning as a teacher, my lessons weren't that great! And there is so much I could have done better or adopted more effective and empathetic communication and teaching styles. I was comparing my first Turing project with my final lesson as a teacher, or my final drink made as a barista, or my final delivery run as a medical courier, or my final dog haircut, etc, etc, etc. I was comparing apples to giraffes. So more than anything, this project taught me to remember everything is scary when you begin. And anything worth doing well is worth doing poorly first. My craziest gains in knowledge and skills happened over our 3-day weekend. I had to drive back to San Antonio, TX to close out our previous apartment and come back to Denver, CO in just those three days. I also had to complete this project. AND, there is like zero service for a good 50-70% of that 14-16 hour drive. So, I had to download a bunch of resources that I guessed would help me. I didn't really know what I might need to look up so I had to rely on the basics like Ruby Textbooks and the Ruby Doc (I downloaded quite a few PDF's straight from the Ruby Docs). This meant that I couldn't learn by Googling or asking anyone for help. I had to rely purely on my ability to find the answer in the Ruby Doc or through my errors in the terminal. This was an insane learning curve and I think I want to continue this type of "forced-learning" as I have to learn new languages/programs/tech/etc.

Mod 1 - Week 2-3: Battleship

Paired

Worked with Arique

Design is key

Transfer from physical notebook

Mod 1 - Week 4-5: Futbol

Group

Worked wtih Logan, Tyler, Chris

Communicaton and TEAM design is key

Transfer from physical notebook

Mod 1 - Week 6: Night Writer

ARGHHHH!!!

Transfer from physical notebook

Mod 2

Mod 2 - Week 1: Adopt Don't Shop (solo)

Project Page
Sunday, Aug 16, 2020
Self-Preview before kickoff
I want to test something out. There is a practice in teaching to teach with the end in mind, meaning: whatever your method of assessing the students gain, retention, and higher-level- to learn with the end in mind. Why not try to learn with the end in mind as well? In this scenario the "end in mind" are projects, therefore, if I read through them (even if I can't understand) I may be more familar with the new lessons.

I have the learning goals in my digital notebook. I am skipping ahead to Rubric.
There are 4 main components this project is looking for:

  1. Feature Completeness - There are 22 User Stories to complete and 6 Extension user stories (hopefully, pick one extension)
  2. Rails - Code is organized using POROs and adhere to MVC, use strategies learned in AND outside of class
  3. ActiveRecord - Effective/Efficient use of ActiveRecord that uses outside ressearch to force even .each calls to prevent additional database lookups
  4. Testing and Debugging - Uses TDD (clearly); files are organized and nested; utilize before :each blocks; 100% coverage for features and models

My Questions for Learning/Understanding

  • What are User Stories? They look like examples of how a use might use the application and their expectations. This seems more like actual client work since a client won't have lots of details but may know how they want the user to experience their product.
  • What are POROs? Plain Old Ruby Objects - THIS looks like a good article to peruse on organization of POROs in rails.
  • What is MVC? Models, Views, Controllers - this is a pattern for the architecture of a software application. It can help guide you as your build apps from scratch. Models handle the data/business logic; Controllers handle the UI/app; Views handle the GUI/Presentation (source
  • What is ActiveRecord? This is the M in MVC - the layer of the system responsible for representing business data and logic. This most follows ORM (Object/Relational Mapping) where tables map to classes, rows map to objects, and columns map to object-attributes
  • How can you force .each to prevent additional database lookups using ActiveRecord? Docs, RubyGuides
  • What does TDD look like in rails? THIS looks like a very good tutorial to peruse. After reading the first 1/4, I feel a little better about what TDD looks like in rails.
  • What does nested mean for test files? After researching, it looks like this is better learned through practice. It looks like many sites reference "nested resources/parameters/collections". Does this mean that my TDD should still work while using nested-etc...? This is more how I am beginning to understand this part
  • What is before :each? StackOverflow response:

    before(:all) runs the block one time before all of the examples are run. before(:each) runs the block one time before each of your specs in the file before(:all) sets the instance variables @admission, @project, @creative, @contest_entry one time before all of the it blocks are run. However, :before(:each) resets the instance variables in the before block every time an it block is run.

  • What is Heroku? This is a cloud application platform - you can build, run, and operate applications entirely in the cloud

ATTEMPTING TO UNDERSTAND THE APP FROM FIRST 6 USER STORIES

  • Looks like an animal shelter website that is hosted via Heroku and holds multiple shelters (Per Instructor Brian: DO THIS LAST)
  • There is a page called 'shelters' - can see the name of each shelter in the system
  • There is a page called 'shelters' with behavior :id - this shows off shelter by id with name, address, city, state, zip
  • There is a Shelter Index page - can create new shelter with a new form (details in User#4)
  • Using the Shelter page, I can update shelter information
  • I can also delete shelter info
  • This all feels very similar to what we did during Intermission Work

I FEEL CONFIDENT IN MY ABILITY TO UNDERSTAND THIS PROJECT NOW
I FEEL CONFIDENT IN MY ABILITY TO LEARN THE THINGS I NEED TO THIS WEEK FOR THIS PROJECT!

Wednesday, Aug 19, 2020
Create the app

  • began by creating new rails app
  • created GH repo and initial commit
  • Created pry gem and installed
  • Created app database

SHELTERS

Develop my Index Page for Shelters

  • User Story 2 - Shelter Index
  • Created a controller ruby file for shelters
  • Added class syntax and inheritance from ApplicationController
  • Made a mistake in my route - the path and controller should have been plural :)
  • Working now - correct error!
  • Created index action in Controller
  • Created a view file for shelters/index using the best-practice of .html.erb instead of just erb
  • Woo! Blank webpage! This means my request-response cycle is currently working for this page
  • But now I need to see the names of each shelter in the system
  • This means I need to work on my database!
  • Used rails to "generate" migration and make a table CreateShelters with an attribute: name which takes a string
  • The instructions for database are written in app
  • Executed instructions using "rails db:migrate"
  • Now that I have my blank web page and my blank database for shelters, I can create the model :)
  • When creating my model, the file should be singular
  • Opened shelter model file and added class syntax && Inherits from ApplicationRecord WHICH ALREADY INHERITS FROM ACTIVERECORD
  • I finally get to make my shelters!
  • Where do I get the data for my database? Do I make it up myself? I think so confirmed from study hall
  • Googled local Denver shelters and added the first 5 names to my database
  • Cool - my db has 5 entries (checked in rails c with Shelter.all)
  • Let's display them in view - AKA - let's get that blank web page up and running!
  • Updated action:index with @shelters = Shelter.all which should access the class shelters, which then acess the db, and then show all
  • In my view file
    • Added a header
    • Added ruby code to display shelter names (each that just prints name)
  • Complete US#2

Update Shelter Database && Display single Shelter information

  • User Story 3 - Shelter Info by ID
  • Since I'm following Day2-3 Lessons on creating an app, testing, associations - I NOW NEED TO SETUP TESTING ENVIRONMENT
  • Installed rspec
  • Installed gem rspec-pride
  • Updated rails_helper with simplecov
  • Now I can write a feature test for US#2 (the shelter index page)
  • Added folders: spec/features/shelters
  • Added test information for shelter names
  • TEST ERROR: more than 1 server accessing database - closed rails erver terminal I still had open on accident
  • Test passes! - FABULOUS TEST
  • Now I am ready to attempt US#3
  • To update the db with address, city, state, and zip, I can go to rails console - but is this tdd? t
  • I am going to look at my task manager for help with accessing by id
  • I think I need to begin by writing my test and then following the errors (which I assume starts at config/routes)
  • I write in validation, then invalid without attributes
  • Get "is valid with valid attributes" passing
  • WHOA! - attempting "is not valid without a name" and major chaos errors! haha
  • NoMethodError:
    undefined method `address' for #<Shelter id: nil, name: "The Humane Society - Denver">
  • Went on a rabbit hole attempting to update the columns in my database and failed to actually read AND PROCESS the error. What I learned: when you see this error, your object in the test itself is what is missing the method. Finally got this fixed with help from stack.
  • When everything should have been working fine, everything was neatly in all the right files. I could confirm my database information through Postico && using rails console. The answer for this was using rake db:test:prepare to reset my tests and they began giving me more appropriate errors I could follow.
  • Wowza, these error codes are hecka confusing... Also, this somehow made my previous test for US#2 fail... Which doesn't make sense, so I don't know if it "stopped it from passing" or more like something is interrupting or I've written my test funky
  • I may have realized something... I'm in the index_spec.rb file... should I be doing all these tests in here? Isn't this technically a new page? I've been approaching this all wrong(maybe?) - Current index_spec.rb file
  • Aw man... I reset everything and now I have a failure in a test that was passing for US#2... darn
  • Error hunting for tomorrow: Failure/Error: expect(page).to have_content(shelter_1.name) expected to find text "The Humane Society - Denver" in "Shelters in the Denver Area"

Thursday, Aug 20, 2020

  • Instead of attempting the error from yesterday, I nuked my index_spec and started over. Test runs now. Unsure what I did before to get it to break, but glad it is working. I can MOVE ON now :)
  • Let's create another webpage! (/shelters/:id) that displays the shelters information that is unique to them - Sounds like a show action
  • Starting with my rspec, the name of this actionpage is probably... show. I don't think it would be new or create; it definetly isn't destroy or edit/update
  • Error: ActionController::RoutingError: No route matches [GET] "/shelters/7"
  • WOOO! This means go to my routes, which is what I predicted!
  • Added a GET to my routes and VOILA, new Error: AbstractController::ActionNotFound: The action 'show' could not be found for SheltersController
  • Do you know what this means??? I get to go to controllers!
  • Created an empty def show, now my error implies I should be going into view, howveer, I don't think there is any real connection to the shelter_by_id information, and I think here, in the controller is probably where that information lives
  • Cool, updating the show action with accessing the Shelter by id didn't change the error
  • Let's go update the page under views :) - I think I need at least a header and the paragraph printing of address, etc
  • OMG. It passed!!!

Shelter - Linking, Creation, and Forms

  • User Story 4 - Create
  • I need to shower and go to class - WHEN I RETURN: I need to make a link on the shelter#index for "new shelter"; then new webpage /shelters/new and forms from there :)
  • Created new_spec.rb test file with "it can create a new shelter" test
  • If I follow Thursday Lesson: Passing Data In Rails; it looks like I may also need to have a create action
  • Let's run the test and follow errors!
    • First error pointed me to my typo in RSpec (forgot to capitalize)
    • Second error pointed me to typo in visit (I made it plural)
    • Sweet - finally got an error I recognize: The routes error! So, I updated my route with get '/shelters/new', to: 'shelters#new'
    • Wowza - Now I am at the error following the lesson plan! This tells us no link actually exists, so let's go make it in views!
    • Gonna use the ruby and link_to code link_to 'New Shelter', '/shelters/new'
    • New error - this one is scary ActiveRecord::RecordNotFound: Couldn't find Shelter with 'id'=new
    • I think this is telling me to go my controllers and make a action/method called new
    • Welp- that wasn't it - in fact, this is making a previous test fail..., so recording error log below:
  • Original Error Message:
    ActiveRecord::RecordNotFound:
    Couldn't find Shelter with 'id'=new
    # ./app/controllers/shelters_controller.rb:7:in `show'
    # ./spec/features/shelters/new_spec.rb:9:in `block (4 levels) in <top (required)>'```
    
  • Attempting to pry in where I think issue is:

    6: def show => 7: binding.pry 8: @shelters = Shelter.find(params[:id]) 9: end [1] pry(#)> Shelter.find(params[:id]) ActiveRecord::RecordNotFound: Couldn't find Shelter with 'id'=new from /Users/priyapower/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/activerecord-5.2.4.3/lib/active_record/core.rb:177:in `find'

  • Moved Pry up to index and maybe identified that I never gave my test something to hold in temp db - NOPE This isn't the solve, it's a new action and page...
  • I am missing the view information after controller, but I don't think that is the issue I'm facing....

    ARGHHGHWIKUEJKFJHSDFKJSYIF

    Dear Project#1,

    I know that it will get better: but how are you breaking me already? I’m glad I have good habits in place, a mod of understanding under my belt, and a world of support and resources from my community. However, when you give me those errors, you know the ones I’m talking about. The ones that stump the internet. The ones that aren’t “supposed” to appear next. The ones you’ve pried/cried/nuked/puked. Those are the errors that are breaking my back.

    If you feel like letting me know how to fix you: I’ll be here. In the meantime, I’m gonna go watch cartoons until I can love you again.

    Sincerely, A frustrated rails beginner

CONT... Linking, Creation, and Forms

  • In Project Checkins - asking for help with issue above OMG - It was Order of Operations in config/routes
  • I switched the routes: get shelters#show and get shelters#new AND IT PASSES!!!!
  • Continuing on!!
  • Advice from Tim:
    • Use Bootstrap for CSS learning (real world dev advice)
    • Use user stories to guide tests
  • Got the capybara error we were expecting Capybara::ElementNotFound: Unable to find field :name that is not disabled
  • This means that our view page doesn't have the info we are requesting
  • Let's update our new.html.erb (in Shelters) page
  • Used rails language to create form
  • First error helped me catch a typo in my form submit tag (mispelled shelter)
  • Next error I expected: need post in routes
  • Updates routes
  • New error is expected - create doesn't exist yet!
  • Updates create action to shelters controller
  • Expected error: Capybara::ElementNotFound: Unable to find xpath "/html" - in class we first pryed and then moved on from here. I will try the same.
  • I get it: this information helps us determine what to write in the create method and private: shelter_params
  • PRY:
=> <ActionController::Parameters {"utf8"=>"✓", "name"=>"Priya's Shelter O' Love", "address"=>"17 Here Ave", "city"=>"Denver", "state"=>"CO", "zip"=>"99999", "commit"=>"Create Shelter", "controller"=>"shelters", "action"=>"create"} permitted: false>
  • Since I can't have the shelter create using params (since these are forbidden attributes), we need to give permission first. (we cannot use the params ‘hash’ directly to create or update records in our database)
  • Updates create method and create shelter_params Why does the shelter_params need to be private?
  • Uh oh - this wasn't the error.. hmmm - seems like I need to redirect back - but let me check user story. Yes - the user needs to be redirected back to the shelters index page
  • Look at that beautifulness, it passes
  • I'm nervous because I haven't previewed my webpage in a while, however, I trust myself to continue through these user stories and I can check it before I start pets

Shelter - Editing and Updating

  • User Story 5 - Update
  • I created initial test based off user story - Per Tim's advice, followed the story verbage a lot closer in my test language

Friday, Aug 21, 2020
CONT Shelter - Editing and Updating

  • Updating "it can edit the shelter form" with a visit, expect+have_link, click_link, expect+current_path, expect+find_field
  • First error - link - Went to show page and added link for 'Update Shelter'
  • Next error catches that my string path should be in double-quotes, otherwise the string interpolation doesn't process as a URI
  • Next error is a nil:NilClass error - this means when it hit the URI, @shelter didn't exist... which is true since it was supposed to be @shelters. THANKS RSpec for catching all my typos :)
  • Woo - the routes error! - Update routes with a get at the bottom
  • Looks like that was the correct Order of Operations in my routes, so I can move on to the controller
  • Does the edit action/method go above or below the "private" information? I bet above... (yep, put it under and same error)
  • Woop woop - looks like the views error :)
  • Updating edit.html.erb with edit form html/ruby
  • Oops, I learned how to include the current information in my form so the user can see what they were editing
  • Ooh - another nil:NilClass error. This one originates once I hit the edit.html.erb and try to access @shelter - IS THIS THE SAME TYPO FROM BEFORE PRIYA! Hahahaha. Should be @shelters
  • Well, that was one issue, but it doesn't solve my error - this could be order of operations in my routes, or a wrong word somewhere, let's investigate
    • Routes looks fine
    • Controller - hmmm... I have nothing in the method - THIS COULD BE THE ISSUE :)
    • What would go in the edit action/method? Well, I want to access the database, definetly using Shelter.something.... it is probably similar to show. In fact, I think it is exactly the same code from show now that I'm re-reading it.
  • BOOM - new error - hmmm... looks like a TYPO! Thanks RSpec for catching my typos!
  • WOOOOO! I passed the test! OMG! This is finally getting a tiny bit in my head. I say this as I move further into the project where I can imagine lots of stump worthy information is coming...
  • Let's commit and move to the next test in this spec
  • Let's actually edit the information and create a submit button now - I tested editing the address and zipcode
  • route error! - let's add a patch route
  • Looks like I wrote the patch route correctly
  • HOWEVER, it does NOT look like the database updated... hmmm...
  • Okay - looks like my patch route was NOT correct! I linked it to the edit action, so basically it was hitting the action/method edit and that's just pulling the info up by id, there was no actual database updating.
  • Look at that, new error that is sending me to Controller to add a update method!
  • Added method, new error is sending me to views... BUT, would an update page exist? Let's check the user story - nope, it wants us to redirect directly back to the unique shelter page to see the updated info
  • Okay, I started with the redirect... it told me that I hadn't defined what @shelters was so it couldn't call id
  • I added an @shelters which finds the shelter by id
  • Hmmm... it is still showing as if the webpage never updated the info. To google I go
  • OH! I actually need to use a .update built-in method!
  • It needs an argument, I'm trying params
  • OH! No permits, so use shelter_params
  • AHHHH! It passed! It passed!
  • Commit and finish this spec test :)
  • OHH! My only other test was the redirect, and guess what! I wrote it in above! Done with US#5!

Shelter - Deleting database values

  • User Story 6, Shelter Delete
  • Just like last time, I'm going to use the user story to basically write my test first :)
  • Perfect, everything passing and 2 Pending that I can work on after my shower :)
  • Coolio, can I complete US6 before class starts. Timebox = 25 minutes
  • Nope - got distracted by a rabbit hole of learning and wasted my morning - oh well. Off to class
  • Project worktime!
  • Updating test "can have a delete link" to make it visit the unique shelter page and expect it to have a delete shelter link
  • Error expected - missing link - I need to go to view page that needs link (the show page)
  • added a link to show page where should it land though? _I am trying the shelters#index page
  • PASSES TEST
  • Moving on to completing the delete
  • Updates test "can delete a shelter id and redirect to index"
  • I visit the unique shelter page and expect to see info about it AND a delete link that I can click which should take me back to my index page where the info is NO LONGER THERE, but I can check that other shelter info is still there
  • First error is nil - where is my typo? haha, hmmmm... zero typos - it looks like for some reason my temp @shelter doesn't link to my second test. What if I continue writing in that one test? Yup that helped! - so having two it-statements here was the issue, wonder why?
  • Woo, much better error, we are at the point where the error is telling us the webpage still has the information that was supposed to be deleted. So this means, the controller isn't performing the behavior! Let's go there!

Saturday, Aug 22, 2020
CONT Shelter - Deleting database values

  • Listening to Spotify: Soundtracks for Studying Created by: Katie O'Brien (very nice)
  • Ran RSPec to recall from yesterday. Reading from yesterday, I thought I had to go to the controller, but this looks like a route should exist. How does that work? Why didn't I get that error?
  • Wrote in a delete route
  • Same error (of course, because it is already routed to the index page....)
  • Side Quest: all my shelter instances are plural. That doesn't make sense, they should be singular since they are only one instance. Updated and tests still run
  • Nothing is gonna update this error for me because I made a mistake somewhere, there is no connection to the behavior delete. which is why I didn't get a route error to guide me. I am commenting out my action and my route and attempting to figure out how to force the error - aka how to convince the code to request a delete action!
  • RESEARCH rubyguide = How I wrote my delete shelter link wasn't helpful. All it did was link to another page, it didn't force a behavior. SO - I can write something more like: <%= link_to "Delete ____", PATH, method: "delete", { confirm: "Are you sure?", disable_with: "Processing..." } %>
  • Attempted with the confirm information, that gives me weird syntax errors, but if I remove it: I GET THE ROUTE ERROR I WANTED!
  • Route updated and new error = controller action missing :)
  • Updates destroy action
  • Error: ```Failure/Error: expect(current_path).to eq("/shelters") expected: "/shelters" got: "/shelters/613" ````
  • What the heck does that mean??
  • Attempting to understand the error:
    • Ok, from my test, when I click on delete shelters I should now be at index page
    • So the test expects the index page
    • BUT - it's getting the.. ID page
    • OHHH. There isn't a redirect! I wrote the redirect into the wrong html/ruby code before and now there isn't one anywhere. where do I place the redirect now??
    • Other redirects currently live in the controller action. That makes sense. The user clicks delete, sends the request (from the ruby html page), hits the routes, hits the controller action, and now redirects back to the index. Makes sense! :)
  • Awesome - new error!
  • Uh oh, looks like I wrote my test "wrong". I included too much info and didn't read the user story correctly! When I delete, I should be redirected to the index page. The index DOESN'T show all the info I put in the expect, only names!
  • Removed the two have_content(address) lines
  • AHHHH! It passes! It looks like it is working thus far!
  • Commit and move on to pets :)

PETS

  • PETS: Pets can be adopted from the Shelter. Pets belong to a shelter.
    Pet Index: Creating a second database and associating
  • User Story #7: Index
  • I need to create a pets database and connect to shelters (Follow Day 30 lesson ActiveRecord Associations)
  • Okay: there is some SETUP
    • I am working in the models folder now (no longer features folder)
    • I created a spec file under spec/models
    • I added the gem 'shoulda-matchers' (bundle install)
    • I added the shoulda-matchers configure to the rails_helper
  • Ran rspec - environment error (i made a folder instead of a file for pet_spec... wow)
  • Cool - we are up and running. Ready to dive into these associations Priya? Okay...
  • Updating pet_spec.rb with rails_helper and validations of pet with image, name, appr_age, sex (at this point, I have no database for pet)
  • Sweet, I created my first validation test, and it prompts the correct error
  • Error - no constant Pet! (Which means I should create a pet model, create_migration for pet database with details I want, look inside migration for any updates needed, and then actually migrate the db where you can see it update the schema with the db)
  • Awesome - some syntax errors in how i wrote my it validate_presence statements (looks like they need to broken up)
  • Correct error - Undefined Table!
  • Create table migration rails g migration CreatePets image:string name:string approximate_age:integer sex:string
  • looks like migration worked - confirmed in db/migrate
  • Run rspec again - correct error: migrations pending
  • Run rails db:migrate
  • Cool, schema updated AND confirmed new database in postico!
  • Yay - the empty/falsy error - we go to the model!
  • Woop woop! It passes
  • We still need to link the pets database to the shelter though (add a relationship test, create migration relationship, follow errors from there)
  • Added relationship test to pet_spec
  • Still getting the no association error -- going to pet.rb and shelter.rb to add associations to code (pets has belongs_to :shelter && validates_associated:shelter and shelter has has_many :pets)
  • Correct error - no association in database
  • Run rails g migration AddSheltersToPets shelter:references
  • Confirm in db/migrate
  • Run tests again - ooh migration pending error
  • run rails db:migrate
  • Passes test
  • I think I need a shelter_spec under spec/models as well and follow any error codes here
  • touch spec/models/shelter_spec.rb
  • Copied and pasted the pet_spec.rb info in shelter_spec.rb
  • Updates for shelter info
  • Begin with the validations - passes test
  • Update with relationships
  • COOL! It still passes all tests
  • Have I completed this user story?
  • I don't think so, I have done NOTHING about visiting a '/pets' page. This means I probably need to move to spec/features and make some tests in there :)
  • mkdir spec/features/pets and touch spec/features/pets/index_spec.rb
  • Let's write the US 7 test into index_spec.rb from Pets
  • Started with rails_helper and the RSpec.describe for Pets Index as a feature test
  • Added describe "As a visitor" with it "can visit a pets index page and I can see every pet in the system and the information about the pet"
  • Run rspec
  • Awesome - no failures, just the pending!
  • Coolio - ready to attack this test: I think I can create a visit path and then have an expect(page).to have_content to guide me
  • Looks like I need a @pet instance variable for my expetcts
  • Ready to run test
  • Error: I created a pet instance variable but no shelter to associate it too! haha
  • Ooh - look at that, a ROUTE ERROR!
  • Add get '/pets', to: 'pets#index'
  • New Error! - Need constant in controller! (Actually, just need the controler in general!)
  • touch app/controllers/pets_controller.rb
  • Error! - Need action index!
  • Upate def index end
  • Error! - Needs view html page
  • Add html view page, new error - can't find the info expected :)
  • Copied shelter index page to pets index page
  • Update for appropriate information
  • Error - @pets is nil WHY??
  • OHHH - I silly: I never created the @pets connection in my controller! haha
  • Coolio - next error is how I wrote my image file. Looks like the "asset 'image.png' is not present in the asset pipeline
  • This means I need an image.png (or whatever name) in the app/assets folder i think
  • Found a cute chihuhua on the internet and saved to app/assets/images; Updates image location in correct files
  • Run test
  • Hmm.. uh oh, it it treating it like just text... what did I do here?
  • Having a hard time figuring out how to get a string image file name from the database to match the assets folder I saved the image in
  • Found some research on: Capybara testing and images
  • Okay - I am wasting too much time. Maybe I can just use the linked image instead of an asset folder image.
  • On a research path to attempt to use a direct image_url_address
  • Updates my instance variable to hold an image_url_address
  • Updates expectations for have_css with image details
  • WOO! The image is finally showing up, however, the expectation is still an error :/
  • Failure/Error: expect(page).to have_css("img[src*='assets/#{@pet_1.image}']"). expected to find css. "img[src*='assets/https://www.101dogbreeds.com/wp-content/uploads/2019/01/Chihuahua-Mixes.jpg']" but there were no matches
  • That doesn't make sense since I can see it on the page....
  • It was because I left 'assets/' in the expectation when I removed the static image in assets
  • Added second pet to test - passes test and static page looks correct
  • Commit to GH

Pets from Shelter by ID

  • User Story 8, Shelter Pets Index
  • I need another shelter an another pet to test the only one shelter's pet's appear
  • To test visually, I also updated the index_spec.rb so I could save_and_open_page - new dog is there with correct shelter info
  • Updates it "can see all pets at unique shelter"
    • visit shelter specific page "/shelters/#{@shelter_1.id}/pets"
    • Should I be including the link yet? Probably not, let the errors guide me right?
    • Copied expectations from index (except shelter_name)
    • Add expect content shelter_name just once for header: "Pet's Located at #{shelter.name}"
  • Run the test
  • Route Error:
  • Route get '/shelters/:id/pets', to: 'pets#index'
  • WHOA: it passed already, better save_and_open_page to confirm
  • Uh oh - this is the main index page
  • This means my action is probably wrong, like, I don't want to see every pet in the database
  • Add new action pets#by_shelter to the route
  • THOUGHT - I probably should have had an 'expect not' for the third pet
  • Add def by_shelter end to pets controller
  • Added index_shelter.html.erb (&&Update all others from by_shelter to index_shelter)
  • COOL - blank page is opening now!
  • Add shelter pet index html ruby by copying index.html.erb file and updating
  • Before I run test - Add expect not for third pet (example expect(page).to have_no_content(@pet_3.name))
  • Test error: my html page is trying to access the database and can't because i didn't put access in the controller
  • Hmmm... how do I connect the pets to the shelter.id
    • I want to say I can just call shelter.pets.all
    • Oooh... funky error
    • Looks like I first need to create a shelter instance, THEN I can make my pets instance and connect
  • Updated view for @shelter instance
  • Run test
  • Error is because female is showing up on page; removes age and sex from pet_3 expect_not
  • Run test
  • PERF - passes test and completes story!
  • Commit and move on!

Show Feature for Pets

  • User Story 9, Pet Show
  • I need to be able to go to pets/unique_id and see all the information + two new columns (description and adoptable/pending)
  • Created a show_spec.rb file under spec/features
  • Created basic test, pass test, 1 pending
  • Update it "can see a unique pet with two new attributes: description and status"
    • put a visit and expect have_contents
  • Run test; Expected error - ROUTE
  • Update route get '/pets/:id', to: 'pets#show'
  • Run test; expected error - missing action
  • Update controller def show end
  • Run test; expected error - missing html page (hold on: I need to at least put a @pet basic connection in my show action
  • Udpate show action with @pet = Pet.find(params[:id])
  • Same error - good
  • Update show.html.erb for views/pets
    • Added two new attributes to pets that will flag errors - descriptions and status (I will need to update the pets database with two new columns)
  • Run test; expected error - missing description from pet
  • Terminal rails g migration AddDescriptionToPets description:string
  • Run test; expected error migrations pending
  • terminal rails db:migrate
  • PASSES TEST and completes user story #9

Pet Create

  • User Story 10, Shelter Pet Creation
  • Webpage: '/shelters/:shelter_id/pets/new'
  • new_spec.rb in spec/features/pets
  • Create test from user story
  • WHOA - they want the adoption status to be a default setting.. hmmmm... so more like an if statement, if status==true, then adoptable; else, pending
    • Where would this change happen?
    • The html? - probably where the if statement goes
    • The database? - Can I just use "true" in the string? Probably not, since it is the wrong data type...
      • I need to update the status column of my pets to have booleans and be default:true
      • Researched - using rails g migration UpdateDefaultStatus
  • Cool - I got a "blank" migrate file
  • Update with def up change_column end
  • Hmmm... this isn't working... I nuked it and decided to update my migrate for add status directly....
  • Well... that works so far (fingers crossed)
  • Update show.html.erb ruby code for if statement
  • That's a crazy looking error, but it looks like it's syntax. I have an end... what else...
    • If you use ruby code and need it to equal, use <%= %>
    • If you use ruby code straight, use <% %>
  • Removes equals and runs test
  • PERFECT! Now back to the new_spec
  • Finishing writing the test: some new info
    • Learned that we have a click_button option
    • From Friday's lesson - we need to save the new pet for testing purposes; I can use a local variable new_pet = Pet.last to save the last entry in the database
  • Run test (there is a linter error, but gonna try anyway
  • Weird, idk why there is a linter error, but correct error for route appears!
  • Update route
  • Action error
  • Update controller with new action
  • View/HTML error
  • Add ruby/html to view file with appropriate field names - prbably need to go back and update shelter html/ruby
  • Error - oops, I didn't link the shelter in the controller action new
  • Run test; can now follow errors :)
  • Error - can't find link on the unique shelter/pets page
  • Updated html for index_shelter.html.erb for pets
  • Left off trying to figure out where the link for "Add New Pet" is missing and what is going on with this test....
  • Looks like the weird route error was from a typo
  • Yay - correct route error
  • Got a disabled fiend for the shelter_id foreign key; I DON'T NEED THIS FILL IN SINCE IT SHOULD ALREADY BE ASSOCIATED WITH IT
  • Added route, got nil error for shelter
  • Added new action and shelter instance variable
  • It is stuck on the route post error.... so something must be wrong, more like a typo or syntax somewhere - READ THE ERROR MORE CLOSELY AND PAY ATTENTION TO DETAILS
  • Ooh.. looks like I dropped an s on shelter again in my path on the new html view page - THIS WAS IT!
  • Create action error - add def create with pet.create(params)
  • Params is forbidden - open pry to see what attributes I can call
  • Of course, so create private method to open up image, name, age, sex, description && update pet.create(pet_params)
  • Add redirect to create action
  • Error tells me I never gave access to shelter; update create action
  • Went on a deep dive into (using Nested Resources lesson from Day 32) where my association went wrong (first I had pet_id foreign keys in the shelter database; second I was accessing the foreign key shetler_id incorrectly)
  • Beginning to see familiar errors - validation failed: shelter must exist

Sunday, Aug 23, 2020
CONT Pet Create

  • Looks like my issue isn't anything except naming and how I've accessed information, so more in the controller/views but started with how I choose to name in spec/routes.
    • Realized because the conflict was occuring with how I named things when I made the shelter index page;
  • So I went back to the shelter pet index test, commented out everything I needed and ran it slowly
  • Updated route for :shelter_id instead of :id PER USER STORY! How did I miss that??
  • This prompts changes in how instance variables were called in controller
  • Cool! Shelter Pets Index and Pets Show are working againn!
  • Back to New/Create.... I'm scared, been on this test for a very long time
  • Updated the instances in new for @shelter and @shelter_id, now I am testing the fill_ins
  • Okay, working thus far; testing click buttong "Add this Pet"
  • Cool, post error
  • Great, let's follow the action create error
  • AHH! I CAN FINALLY SEE shelter_id in pet_params, added it to private pet_params method to allow permissions :)
  • ERMAGERD - Of course I kept getting description errors (DISCOVERED: used save_and_open_page and saw new pet WAS added this time, but no descriptions show up on the page because that is how the index page is written!)
  • Googled difference between new/save versus create... WOO, I can save a whole line :)
  • FINALLY DONE WITH THIS STORY :)

Pet Update

  • User Story 11, Pet Update
  • Created user_spec.rb
  • Used snippet and updated per user story
  • Ready to begin testing
  • First error - link doesn't exist on page
  • Updated html on show under pets
  • Route error - add get route for pets/id/edit
  • Action edit error - add edit action to pets controller
  • Coolio, html error; let's pry into edit action - I need to define the id coming in (pet#4) as something the html page can access!
  • Updates and run test
  • Same html error, but now if I create an html view page, I HAVE ACCESS TO @pet which is currently calling pet#4 in the test
  • touched under views/pets "edit.html.erb"
  • WOW.... understanding the connections is finally getting easier
  • Using the shelter/edit.html and the pet/new.html page to create the pet/edit.html
  • I wanted access to the shelter name, created instance in action:edit
  • Made sure the patch was going to the correct location (the form_tag)
  • Made sure submit_tag is a button
  • Made sure text_field_tags held current info (update save_and_open_page in test)
  • First error was a typo in my expected path
  • Second error is a mistake in how I am labelling my shelter
    • Pry in here to discover mistake: the shelter.find needed to hold the argument (@pet.shelter_id) for how I've assigned my instances :)
  • Patch route error! - Create patch pets/id to pets#update (last time I think I did shelter#edit and realized that's the wrong action BECAUSE I need the information to hit a new action and SAVE)
  • Update action error
  • Add update action
  • Test opens blank page - does this mean I need a redirect? OR SOMETHING WORSE....
  • Binding.pry in update
    • params tells me this is the UPDATED pet#4 - this is a good start
    • Created @pet but when I look at it... it's the old information... but the "action" param now says update...
    • Research: Looks like I can use .update
    • @pet.update(params) gives a forbidden error
    • @pet.update(pet_params) GIVES TRUE! Oooh
    • Now @pet works! OMG
    • Added two correct lines to action:update
  • Uh oh: still blank page and missing html path... REDIRECT!?!?!
  • Added redirect to update
  • AHHHH IT WORKED
  • SUPER PROUD OF SELF: I was able to test, follow, pry, debug, figure out, etc this entire test with confidence!!

Pet Delete/Destroy

  • User Story 12, Pet Delete
  • Create spec/pet delete_spec.rb
  • Copy user story
  • Use rspec snippet
  • Fill out test using user story - REALIZED I NEVER FLUSHED OUT THE SECOND TEST I WANTED TO RUN IN UPDATE - Going back for a second - Yeah - it can't update because the column approximate_age is integer - Can I just fix taht in the db or should I rails migrate - Looks like if you rails migrate it is easier to rollback or work with teams - Research: terminal - rails g migration ChangeDataTypeForApproximateAge - Research: db/migrate - change_column :table_name, :column_name, :date becomes change_column :pets, :approximate_age, :float - Run rails db:migrate - Run rspec - other uses of integer instead of float are now erroring - Followed errors and fixed - PERFECT!
  • Picking back up on DELETE_SPEC.rb
  • Run rspec
  • First error - typo in visit (forgot to put .id)
  • Expected error - missing link from pet show page
  • Unexpected error - pet information still on page (why no route)
    • Realized that when I was clicking on "delete pet" it couldn't tell the computer to delete the record - added method: :delete to html of "delete pet"
  • Route error! - Add delete route linked to destroy action
    • side error - forgot to put the actual delete link in delete pet on html (it was "/pets" and needed to be "/pets/#{@pet.id}")
  • Action destroy error! - add def destroy to controller
  • Time to PRY!
    • assigned current id to @pet
    • Pet.count is currently 4
    • @pet.destroy
    • Pet.count is now at 3!!!
    • Pet.all confirms it is gone! WOO
  • Run test again
  • Uh oh - wrong path at end - I need a redirect somewhere (added to destroy)
  • PASSES TEST
  • lets save_and_open_page
  • Perfect :)

USABALITY

  • Users should be able to use the site easily. This means making sure there are links/buttons to reach all parts of the site and the styling/layout is sensible.

Shelter Index Link - Edit

  • User Story 13, Shelter Update From Shelter Index Page
  • Where do I write this test? Do I make my own or update old test?
    • Seems like an update to old tests would make more sense and keep less files to sort
    • In this instance, I think these tests belong on the spec/feat/shel index_spec.rb file
  • Update index test with user story info (BELOW - how the test started before I put in actual test-code):

    it "text" do As a visitor When I visit the shelter index page Next to every shelter, I see a link to edit that shelter's info When I click the link I should be taken to that shelters edit page where I can update its information just like in User Story 5 end

  • Test after I mess with code:

    visit "/shelters" save_and_open_page

    expect(page).to have_content(@shelter_1.name) expect(page).to have_content(@shelter_2.name)

    expect(page).to have_link('Edit this Shelter') expect(page).to have_link('Edit this Shelter')

    click_link 'Edit this Shelter' expect(current_path).to eq("/shelters/#{@shelter_2.id}/edit")

  • Run test
  • Expected error: missing link on shelter index page
  • Update html with link (style: next to shelter name)
  • Ewww... ugly looking on the page (can be fixed later)
  • Weird error: ambiguous match (Research capybara upgrade guide
  • Made links more specific and it passes - if I need to go back and make them more generic, I believe I can :)
  • Passes test
  • Visually - NOT SO GREAT
  • Went back and updated test and made links generic again (USING THE FIRST METHOD)
  • Still passes - Complete this story for now - coming back to do more style using chrome dev tools and assets

Shelter Index Link - Delete

  • User Story 14, Shelter Delete From Shelter Index Page
  • Go to spec/shelter delete_spec to udpate for link on page
  • Using the last test, copy, paste, and update
  • Run test
  • Expected error - missing link on html page
  • Update shelter index (the delete path needs to be 'shelters/id' and the method is probably delete or destroy) it is not destroy, cabybara error
  • Run test
  • WHOA - it just passed
  • I need to go check my save_and_open_page
  • Well - look at that, complete!

Pet Index Link - Update/Edit

  • User Story 15, Pet Update From Pets Index Page
  • go to spec/pet index (this was hard, I really had to read the user story language, pet will update from pets index, therefore, the test belongs to pet_index)
  • copy and editing from shelter/spec for edit test
    • It says pet index OR shelter pet index (because I have two test files/html files here, it looks like I may need two UNIQUE tests here)
    • let's start in pet index
  • Run test
  • Expected error - missing link edit pet - Update html on pet index
  • grab new html code from shelter index, copy and update for pets
  • Run test
  • Woop! Runs correctly, looks like :)
  • Complete user story
  • WAIT - ARGGGGG - I told myself at the beginning there was a second test
  • Ewww - git commit errors and merge, I think I made it through
  • Running test; jik
  • Coolio - updating index_shelter_spec with similar from pets index
  • Run test
  • Expected error - shelter_pet_index does NOT have edit pet links
  • Copy pet index html to pet index_shelter html and update
  • Run test - passes; confirm with save_and_open_page
  • NOW I'VE COMPLETED THE TEST!

Pet Index Link - Delete/Destroy

  • User Story 16, Pet Delete From Pets Index Page
  • pets index test
  • copy from shelter index test for it "can delete"
  • Copy user story in and update
    • SAME ISSUE: two tests here - also index_shelter_spec.rb
  • Run test
  • Expected error - missing delete link from pets index html
  • Update html (rememebering to use method: :delete)
  • Passes test - check with save_and_open_page
  • Yup - Tinkerbell is missing :)
  • THIS DOES NOT COMPLETE USER STORY - but good commit spot
  • Update pet index_shelter spec and RUN TEST
  • Expected error - missing link delete pets from pet index_shelter html
  • Update html
  • Run test - my redirect is messed up
  • Running through the paths that are taken from index_shelter.html.erb
  • New error about new action I'm thinking of making
    • Idea for future: can I make an if statement in destroy and reduce the number of actions?
    • Left this comment thought in PetsController
  • Cool - passes test and confirmed with save_and_open_page
  • Completes User Story

Shelter Name Link - Make links every time shelter name appears

  • User Story 17, Shelter Links
  • Any html page that has shelter name must be updated
  • I have 4 shelter pages, so updating indx, new, edit, and show
  • Index page updated and run test
  • First error is typo error
  • Run test - Expected error - missing link matching shelter name on Index html
  • Update index html - incorrect redirect
  • Fixed and run test - Route Error!
  • Oh wait - I have an shelters#show associated with just shelters/:id, I need to update spec and html
  • Run test
  • Passes!
  • Edit page updated and run test
  • First error tells me I never assigned a second shelter
  • Run test
  • Second error tells me the page I am hitting doesn't have the info I want
  • Edited edit.html page for link of shelter.name
  • Error - I forgot an @ in front of a shelter reference on edit.html
  • Passes test
  • Don't need to update new spec or new html
  • Edit show spec and run test
  • Expected error - missing link
  • Update show html and run test
  • Error - typo missing @ in front of shelter
  • PASSES
  • The only thing left to do is go check the Pets html's and find any instances of shelter.name
  • Edit PETS index and run test
  • Expected error - missing link
  • Updated pets index html
  • Run Test
  • WHOA - new error - AH, since I want index to now access shelter, I need to create that connection in def index
  • Run Test
  • Passes test
  • Edit PETS shelter index and run test
  • Expected errpr - missing link
  • Updated pets shelter index html
  • Run Test
  • Passes test!
  • Edit PETS new and run test
  • Expected error - missing link
  • Update pets new html
  • Run Test
  • Passes test!
  • Edit PETS show and run test
  • Expected error - missing link
  • Update pets show html
  • Run Test
  • Passes test!
  • Edit PETS edit and run test
  • Expected error - missing link
  • Update pets edit html
  • Run Test
  • Passes test!
  • I HAVE COMPLETED THIS STORY!!
  • Completes User Story

Pet Name Links - Make links every time pet name appears

  • User Story 18, Pet Links
  • Changing ALL html files that have Pet.name to link for Pet/show
  • Found pet.names in pet index, index_shelter, edit, and show
  • Updated ALL specs with tests
  • Run MEGA TEST
  • FOUR Expected missing links - starting to fix each html one at a time
  • REMOVED test from edit
  • Update html in index, index_shelter_ and show
  • Run MEGA TEST
  • Mega Test Passes!!!
  • Completes User Story

All Pages have Pet Index link

  • User Story 19, Pet Index Link
  • All html should have link "All Pets" which takes to /pets
  • Considering doing both user story 19 and 20 at the same time
  • Screen management to see every html and every test
  • Running each one slowly with 19/20 at the same time
  • Shelter Index - PASSES
  • Shelter New - PASSES
  • Shelter Show - PASSES
  • Shelter Edit - PASSES
  • Pet Index - PASSES
  • Pet Index Shelter - PASSES
  • Pet New - PASSES
  • Pet Show - PASSES
  • Pet Edit - PASSES
  • Completes User Story 19 AND TWENTY

All Pages have Shelter Index Link

  • User Story 20, Shelter Index Link
  • Completes User Story

All Shelter Show Pages have shelter/petsindex

  • User Story 21, Shelter Pet Index Link
  • In test:shelter show_spec
  • Wrote test and Run
  • Expected error - missing link
  • Update shelter show html page
  • Passes Test!
  • Completes User Story

HEROKU

  • User Story 1, Deploy to Heroku
  • Create Rspec for heroku deployment IDK if this is correct, but I'm trying
  • How did I install Heroku to local? brew tap heroku/brew && brew install heroku
  • Followed cheatsheet
  • Well... that sucked....
  • Didn't finsih
  • 6PM Deadline

STYLING

  • User Story 22, Styling When I visit any page on the site Then I should see a reasonably well styled page

Mod 2 - Week 2-3: Adopt Don't Shop (paired)

Monday, Aug 24, 2020
Self-Preview before kickoff

  • Learning Goals are in digital notebook
  • We take one of our already completed repos (probably gonna want to use my partners)
  • Use our repo page as our main collab for cloning, collaborating, pushing (I think I would prefer a new repo page for the project)
  • 36 User Stories + 4 Extension Stories
  • Suggested timeline is provided at about 4-6 stories a day
  • It looks like we are advancing the adopt don't shop website further!
  • Things I see to work on
    • Deployment to Heroku
    • Below Topics raised this question in me - how does this save for unique user? Is there a user login page??
      • Possible User Login Information
    • Reviews && Ratings WITH option upload of picture
    • Favoriting a pet
    • Applications
    • Lots of Logic Constraints

Pairing Conversation

Mod 2 - Week 4-5: Monster Shop (group)

Mod 2 - Week 6: Monster Shop (solo)

Mod 3

Mod 4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment