first commit
This commit is contained in:
26
app/views/articles/_form.html.erb
Normal file
26
app/views/articles/_form.html.erb
Normal file
@@ -0,0 +1,26 @@
|
||||
<%= form_with model: article do |form| %>
|
||||
<div>
|
||||
<%= form.label :title %><br>
|
||||
<%= form.text_field :title %>
|
||||
<% article.errors.full_messages_for(:title).each do |message| %>
|
||||
<div><%= message %></div>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<%= form.label :body %><br>
|
||||
<%= form.text_area :body %>
|
||||
<% article.errors.full_messages_for(:body).each do |message| %>
|
||||
<div><%= message %></div>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<%= form.label :status %><br>
|
||||
<%= form.select :status, Visible::VALID_STATUSES, selected: article.status || 'public' %><br>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<%= form.submit %>
|
||||
</div>
|
||||
<% end %>
|
3
app/views/articles/edit.html.erb
Normal file
3
app/views/articles/edit.html.erb
Normal file
@@ -0,0 +1,3 @@
|
||||
<h1>Edit Article</h1>
|
||||
|
||||
<%= render "form", article: @article %>
|
15
app/views/articles/index.html.erb
Normal file
15
app/views/articles/index.html.erb
Normal file
@@ -0,0 +1,15 @@
|
||||
<h1>Articles!</h1>
|
||||
|
||||
Our blog has <%= Article.public_count %> articles and counting!
|
||||
|
||||
<ul>
|
||||
<% @articles.each do |article| %>
|
||||
<% unless article.archived? %>
|
||||
<li>
|
||||
<%= link_to article.title, article %>
|
||||
</li>
|
||||
<%end%>
|
||||
<% end %>
|
||||
</ul>
|
||||
|
||||
<%= link_to "New Article", new_article_path %>
|
3
app/views/articles/new.html.erb
Normal file
3
app/views/articles/new.html.erb
Normal file
@@ -0,0 +1,3 @@
|
||||
<h1>New Article</h1>
|
||||
|
||||
<%= render "form", article: @article %>
|
17
app/views/articles/show.html.erb
Normal file
17
app/views/articles/show.html.erb
Normal file
@@ -0,0 +1,17 @@
|
||||
<h1><%= @article.title %></h1>
|
||||
|
||||
<p><%= @article.body %></p>
|
||||
|
||||
<ul>
|
||||
<li><%= link_to "Edit", edit_article_path(@article) %></li>
|
||||
<li><%= link_to "Destroy", article_path(@article), data: {
|
||||
turbo_method: :delete,
|
||||
turbo_confirm: "Are you sure?"
|
||||
} %></li>
|
||||
</ul>
|
||||
|
||||
<h2>Comments</h2>
|
||||
<%= render @article.comments %>
|
||||
|
||||
<h2>Add a comment</h2>
|
||||
<%= render "comments/form" %>
|
Reference in New Issue
Block a user