Queues - Ting Wong - Rails Zoo #14
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Rails Zoo
Congratulations! You're submitting your assignment!
Comprehension Questions
animals/:idpage. This then gets mapped to the#showmethod in the controller which displays an animal with theidof the one selected. The display occurs in the view, so the controller calls the view,show.html.erb, the view (which includes the HTML) is then populated with the details of the requested animal and is sent back to the browser.show.html.erb. For the image link, I wanted to provide anifstatement so that if no image link was available, the animal details page would be blank (rather than show a broken image link). I gained a bit more clarity, though not total clarity, on how you could write code alongside the HTML.show.html.erbwhere I used theifstatement to display the image? Can you comment specifically on how to wrap the code in either<%= ... %>,<% ... %>or simply leaving it out for the<img src= ... >line?Animal.new(in our def new) in addition to ourAnimal.create? I understand that we need a method that displays a form for our Animal, but am unsure as to why we need the initialAnimal.newwhen.createcan handle both the new instance and creation of the Animal.Also, I'm unsure in the editing route,
get 'tasks/:id/edit', to: 'tasks#edit', as: 'edit_task'patch 'tasks/:id', to: 'tasks#update'How does the
patchaction know to post it to the right Animal.id? Specifically, where do we specify this in our code?|