2

When I run my code on Cloud9 IDE, the next error appears:

Missing partial submissions/_submission with {:locale=>[:en], :formats=>[:html], :variants=>[], :handlers=>[:erb, :builder, :raw, :ruby, :coffee, :jbuilder]}. Searched in: * "/usr/local/rvm/gems/ruby-2.3.0/gems/web-console-2.0.0.beta3/lib/action_dispatch/templates" * "/home/ubuntu/workspace/app/views" * "/usr/local/rvm/gems/ruby-2.3.0/gems/web-console-2.0.0.beta3/app/views"

I have a Submissions Controller and my create code is like this:

def create
 @submission = Submission.new(submission_params)

 respond_to do |format|
  if @submission.save
    format.html { redirect_to root_path}
    format.json { render :show, status: :created, location: @submission }
  else
    format.html { render :new }
    format.json { render json: @submission.errors, status: :unprocessable_entity }
  end
 end
end

I don't know which is my error and where to locate it.

Plus, a full stack text http://pastebin.com/YnyQeetU

The code of index.html.erb http://pastebin.com/fZbXd0Wk

avm_69
  • 183
  • 2
  • 11
  • `Missing partial submissions/_submission` - as your error says you are missing partial `_submission.html.erb` . Where you have used it and what is the path to partial ? – dp7 Apr 25 '16 at 09:52
  • @dkp What do you mean by _submission.html.erb? I do not have that file, I have some files which names are _form, edit, index, show and new .html.erb – avm_69 Apr 25 '16 at 09:57
  • Please check your views, there might be some place where you are rendering `_submission.html.erb` partial. It would be better if you can add your relevant view which is getting rendered here. – dp7 Apr 25 '16 at 10:09
  • @dkp There is no reference to _submission.html.erb in /views/submissions. The most likely thing is this line of code – avm_69 Apr 25 '16 at 10:18
  • 1
    Can you just add the complete stack trace ? – dp7 Apr 25 '16 at 10:20
  • Replace the line `` with `` will fix your problem – Sambit Apr 25 '16 at 10:23
  • The full stack http://pastebin.com/YnyQeetU – avm_69 Apr 25 '16 at 10:28
  • 1
    `submissions/index.html.erb` - please add this view code to your question. – dp7 Apr 25 '16 at 10:39
  • 1
    `` - This line of code is causing the problem. Why you have added html comment here ? If you want to comment this line of code, you should do `<%#= render @submissions %>` – dp7 Apr 25 '16 at 10:47
  • It is not my code, just recieved it. Why is it wrong to have that line here? Is it supposed to be in another part of the code or I just comment it and everything should work fine? – avm_69 Apr 25 '16 at 10:50
  • 1
    It depends on your requirement. If you need to render that partial, then add the `_submissions.html.erb` to `views/submissions/` path and make use of partial. If you just don't need it now, comment it out . – dp7 Apr 25 '16 at 11:08

2 Answers2

1

Though the line is commented in HTML, the server tag is still being executed. Try to comment the server tag with <%#= link_to 'New Submission', new_submission_path %>. This will stop executing the server tag and you will not get the error.

More reference: How to comment lines in rails html.erb files?

Community
  • 1
  • 1
Sambit
  • 424
  • 6
  • 15
1

This line of code is causing the problem.

<!--<%= render @submissions %>--> 
#<!-- --> This is used to comment an HTML tag

If you do not want to render the partial you can simply comment that out as follows:

<%#= render @submissions %>
#<%# %> This is the way to comment embedded ruby code 
dp7
  • 6,651
  • 1
  • 18
  • 37