Method reference error in text database implementation
NoMethodError in Posts # new
undefined method `errors'for nil: NilClass
<h2>Add New Post</h2> <% = form_for: post, url: posts_path do | f |%> <p> <% = f.text_field: title, placeholder: 'enter title'%> <% if @ post.errors.messages [: title] .any?%> <span><% = @ post.errors.messages [: title] %></span> <% end%> </p> <p> <% = f.text_area: body, placeholder: 'enter body text'%> <% if @ post.errors.messages [: body] .any?%> <span><% = @ post.errors.messages [: body] %></span> <% end%> </p> <p> <% = f.submit%> </p> <% end%>
class PostsController<ApplicationController def new @post = Post.new end def create @post = Post.new (post_params) if @ post.save redirect_to posts_path else render 'new' end end private def post_params params.require (: post) .permit (: title,: body) end end
Since an empty post instance is created by the new action, I think that the error part is a different part.
Answer # 1
Updating the atom body and checking the file again, the file information was restored to the previous save information.
Redefine it normally and resolve it safely.
Since a similar thing happened with atom before, was it debugged with an update?
- ruby - undefined method `map' for nil: nilclass cannot be resolved
- ruby on rails - "undefined method` id 'for nil: nilclass "error occurs when users/show action (view my page) is execut
- ruby on rails - i want to solve the error of undefined method `total_pages' that occurred while using gem: kaminari
- ruby - please tell me how to resolve the undefined method `id' for nil:nilclass error in rails
- ruby on rails - actionview::template::error (undefined method ~
- ruby - undefined method `deep_symbolize_keys' for "task:task":string error
- ruby on rails undefined method `password_digest='
- ruby on rails - undefined method `' for nil:nilclass in rake assets:precompile after deploy is executed
- ruby on rails - in rails command, undefined method `application' for rails:module (nomethoderror) comes out
- ruby - nomethoderror: undefined method `method name' for nil: please tell me how to deal with nilclass
- ruby - error resolution for undefined method `coments' for nil:nilclass
- ruby - nomethoderror in posts#edit undefined method `content' for nil:nilclass in rails
- ruby on rails - nomethoderror: undefined method `each' for 5:integer
- ruby - questions about undefined method
- ruby on rails 5 - undefined method `each 'for error in each of view
- ruby on rails - how to resolve undefined method `errors' for nil:nilclass
- ruby on rails - undefined method `content' error cannot be resolved
- ruby on rails - undefined method `name' for nil:nilclass
- ruby - undefined method `event_url 'for error cannot be resolved
- ruby - undefined method `build_address' for order (table doesn't exist): class send data to db
- ruby - in the rails folder, the chrome driver that was working stopped working
- ruby - implemented google maps, resulting in a position mark different from the address
- [ruby on rails] i would like to know how to use the youtube data api to save search data in a db
- ruby - about activerecord::recordnotfound in userscontroller#show
- how to calculate ruby z-score
- ruby - actioncontroller :: urlgenerationerror when validating rails comment function
- ruby - if you try to insert data into the name column that is not null constraint and leave it blank, it will be registered as &
- progate ruby on rails Ⅸ question about defining instance method in class
- ruby - i want rails controller @user = userwhere (logged user's date of birth + -3 years)