Skip to content
Kalman Hazins edited this page Feb 22, 2016 · 7 revisions

FAQs - Course 2: Module 3

If you have have a general question that is not specific to the Module 3 content, it may have already been answered here.

Table of Contents

Requirements


Q: rq06 implement redirection is failing?

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.

Q: Difference between persisted and new_record?

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

Q: Display completed TodoItems is failing?

A: Make sure you return the number of completed TodoItems. You will need to use a where clause to do this.

Q: Web console is activated error?

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

Q: Undefined method web-console error?

A: Remove config.web_console.development_only = true or config.web_console.development_only = true from application.rb