-
Notifications
You must be signed in to change notification settings - Fork 56
Home
If you have have a general question that is not specific to the Module 1 content, it may have already been answered here.
- rq06 - implement redirection
- What's the difference between the
persisted?
andnew_record?
methods? - rq09 - display completed TodoItems
A: A common mistake is to instead use the following code, which won't work:
redirect_to @todo_item
To figure out the right answer, take note of the hint from the directions:
Hint: you are changing the URI redirected by the controller’s create method. Use rake routes to help determine the appropriate helper_method_prefix, URI, and controller#method mappings. Append _url to the helper method prefix when implementing this redirection.
A:
persisted?
Returns true if the record is persisted, i.e. it’s not a new record and it was not destroyed, otherwise returns false.
new_record?
Returns true if this object hasn’t been saved yet – that is, a record for the object doesn’t exist in the database yet; otherwise, returns false.
More documentation can be found at the following links:
http://apidock.com/rails/ActiveRecord/Persistence/persisted%3F
http://apidock.com/rails/ActiveRecord/Persistence/new_record%3F
A: Make sure you return the number of completed TodoItems. You will need to use a where
clause to do this.