Here's the call in the application.html.erb file:
<%= render :partial => 'tasks/_new' %>
Here's a partial display ( _new.html.erb ):
<% form_for @task do |f| -%> <%= f.text_field :body %> <%= submit_tag "Submit" %> <% end -%>
Here's the method in the task controller:
def new @task = Task.new respond_to do |format| format.html
Here is the error message I get:
Missing template tasks/__new.erb in view path app/views
And he says the error in this line:
<%= link_to "tasks", tasks_path %> <%= render :partial => 'tasks/_new' %>
The file is in the correct directory. The strange thing is that there is extra _ in the file name, in error. When I turn in and rename partly to __new.erb , an error appears here:
Called id for nil, which would mistakenly be 4 -- if you really wanted the id of nil, use object_id
And he says the error in this line:
<% form_for @task do |f| -%>
I also tried without _ in the code, as Petros suggested, but it returns the same error as above, Called id for nilβ¦
What's happening?
ruby-on-rails forms
San diago
source share