I will summarize the error sentences that I have encountered while doing the tasks so far. However, I think the solution is on a case-by-case basis, so it might be a good idea to think of such an error statement as follows ... It's just a memorandum.
Name Error
(Example 1) Name Error in Books#index undefind local variable or method 'book' Did you mead? @book @book ↓ The local variable method book is not defined. Isn't it @book or @books? ** => Possible ** There are many misspellings. Let's take a look at the page pointed out again.
(Example 2) Name Error in Books#index uninitialized constant user::Relationship 24 passive-relationships.find-by(following_id:user_id).oresent? ↓ Uninitialized constant user :: Relationship (= Unable to read the defined class) ** => Possible ** Again, this is often a misspelling. Let's take a look at model, view and controller.
No Method Error
(Example) No Method Error in Books#create undefind method 'user' for nil :nilclass ↓ Method error (undefined method called) A method called'user is not defined. ** => Possible ** ① in Books # create → user column is not added to the Books table 2 If there is Did you mean ?, rewrite it. By the way,'each', which does not specify columns, often appeared in this error statement (I forgot to solve it).
(Example 1) Action Controller::Unknown Format in Homescontroller#top ↓ Missing view file error for action ** => Possible ** You may not have created a view file.
(Example 2) Action COntroller::Url Generation Error in Member::Addresses#index No route matches {action=> "edit" :controller=>"member/addresses#index" id=>nil} missing required keys:[id] ↓ Since there is no id in the part specified by edit, it could not be matched and URL generation failed. ** => Possible ** You may not have specified an id in the controller edit.
(Example) Template is missing controller render:show ↓ There is no template. ** => Possible ** The view of the action set in the controller may not be set.
(Example) ArgumentError in Books#index first argument in form cannot contain nil or be empty ↓ Argument error The first argument of the form cannot contain nil or be empty. ** => Possible ** For example, it happens when updating by leaving the name of the logged-in user who must enter a value blank on the edit screen. Therefore, it may be solved by (1) outputting an error message when updating with a blank, and (2) writing validation.
(Example) Load Error in Usercontroller#show unable to autoload constant Relationship ↓ Load error Unable to autoload constant Relationships. ** => Possible ** In my case, the model Relationship was spelled incorrectly in the follow function.
It is like this. I will update it when it increases again.
Recommended Posts