-
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 3 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
- Getting 'Web Console is activated in the test environment, which is usually a mistake' error
- Getting 'undefined method `web_console'' error
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.
A: web-console
is a great gem and until recently, it was automatically put into development and test groups in the Gemfile. Apparently, (very recently) it was decided that it should live only in development environment and NOT test environment (https://github.com/gsamokovarov/web-console/commit/4f6b6cf3877d2b261570c75ade5650c5cec7aece)
Because of this, in your Gemfile you need to take web-console out of the block that puts it into :development AND :test groups and instead just put it into a :development group as follows
gem 'web-console', '~> 2.0', group: :development
group :development, :test do
gem 'byebug'
gem 'spring'
end
A: Remove config.web_console.development_only = true
or config.web_console.development_only = true
from application.rb