mirror of
https://github.com/projekteuler/projekteuler.git
synced 2026-01-27 02:28:50 +01:00
Add problem type
This commit is contained in:
25
app/views/problems/_form.html.erb
Normal file
25
app/views/problems/_form.html.erb
Normal file
@@ -0,0 +1,25 @@
|
||||
<%= form_for(@problem) do |f| %>
|
||||
<% if @problem.errors.any? %>
|
||||
<div id="error_explanation">
|
||||
<h2><%= pluralize(@problem.errors.count, "error") %> prohibited this problem from being saved:</h2>
|
||||
|
||||
<ul>
|
||||
<% @problem.errors.full_messages.each do |message| %>
|
||||
<li><%= message %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<div class="field">
|
||||
<%= f.label :title %><br>
|
||||
<%= f.text_field :title %>
|
||||
</div>
|
||||
<div class="field">
|
||||
<%= f.label :content %><br>
|
||||
<%= f.text_area :content %>
|
||||
</div>
|
||||
<div class="actions">
|
||||
<%= f.submit %>
|
||||
</div>
|
||||
<% end %>
|
||||
6
app/views/problems/edit.html.erb
Normal file
6
app/views/problems/edit.html.erb
Normal file
@@ -0,0 +1,6 @@
|
||||
<h1>Editing problem</h1>
|
||||
|
||||
<%= render 'form' %>
|
||||
|
||||
<%= link_to 'Show', @problem %> |
|
||||
<%= link_to 'Back', problems_path %>
|
||||
27
app/views/problems/index.html.erb
Normal file
27
app/views/problems/index.html.erb
Normal file
@@ -0,0 +1,27 @@
|
||||
<h1>Listing problems</h1>
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Title</th>
|
||||
<th>Content</th>
|
||||
<th colspan="3"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
<% @problems.each do |problem| %>
|
||||
<tr>
|
||||
<td><%= problem.title %></td>
|
||||
<td><%= problem.content %></td>
|
||||
<td><%= link_to 'Show', problem %></td>
|
||||
<td><%= link_to 'Edit', edit_problem_path(problem) %></td>
|
||||
<td><%= link_to 'Destroy', problem, method: :delete, data: { confirm: 'Are you sure?' } %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<br>
|
||||
|
||||
<%= link_to 'New Problem', new_problem_path %>
|
||||
4
app/views/problems/index.json.jbuilder
Normal file
4
app/views/problems/index.json.jbuilder
Normal file
@@ -0,0 +1,4 @@
|
||||
json.array!(@problems) do |problem|
|
||||
json.extract! problem, :id, :title, :content
|
||||
json.url problem_url(problem, format: :json)
|
||||
end
|
||||
5
app/views/problems/new.html.erb
Normal file
5
app/views/problems/new.html.erb
Normal file
@@ -0,0 +1,5 @@
|
||||
<h1>New problem</h1>
|
||||
|
||||
<%= render 'form' %>
|
||||
|
||||
<%= link_to 'Back', problems_path %>
|
||||
14
app/views/problems/show.html.erb
Normal file
14
app/views/problems/show.html.erb
Normal file
@@ -0,0 +1,14 @@
|
||||
<p id="notice"><%= notice %></p>
|
||||
|
||||
<p>
|
||||
<strong>Title:</strong>
|
||||
<%= @problem.title %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<strong>Content:</strong>
|
||||
<%= @problem.content %>
|
||||
</p>
|
||||
|
||||
<%= link_to 'Edit', edit_problem_path(@problem) %> |
|
||||
<%= link_to 'Back', problems_path %>
|
||||
1
app/views/problems/show.json.jbuilder
Normal file
1
app/views/problems/show.json.jbuilder
Normal file
@@ -0,0 +1 @@
|
||||
json.extract! @problem, :id, :title, :content, :created_at, :updated_at
|
||||
Reference in New Issue
Block a user