Issue
I'm learning Rails and I'm trying to use partials to clear my code.
When I refresh the post/new page, the only thing I have is the "Créer un article". Nothing in my partial _form appears..
I don't understand my mistake, did I miss something?
Here is my view:
<h1>Créer un article</h1>
<%= render 'form' %>
Here is the partial:
<% form_with model: @post do |f| %>
<div class="form-group">
<label>Titre</label>
<%= f.text_field :title, class:'form-control' %>
</div>
<div class="form-group">
<label>Slug</label>
<%= f.text_field :slug, class:'form-control' %>
</div>
<div class="form-group">
<label>Contenu</label>
<%= f.text_area :content, class:'form-control'%>
</div>
<div class="form-group">
<%= f.submit "Valider", class: "btn btn-primary" %>
<a href="<%= posts_path %>" class="btn btn-secondary">Retour</a>
</div>
<% end %>
Log from rails local server:
Started GET "/posts/new" for ::1 at 2019-12-26 17:38:03 +0100
Processing by PostsController#new as HTML
Rendering posts/new.html.erb within layouts/application
Rendered posts/_form.html.erb (Duration: 20.7ms | Allocations: 2408)
Rendered posts/new.html.erb within layouts/application (Duration: 22.8ms | Allocations: 2711)
[Webpacker] Everything's up-to-date. Nothing to do
Completed 200 OK in 40ms (Views: 34.5ms | ActiveRecord: 0.0ms | Allocations: 7669)
Solution
you missing equal sign (=) from first line, it should be like this below
<%= form_with model: @post do |f| %>
Answered By - widjajayd Answer Checked By - Willingham (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.