Initial commit
This commit is contained in:
16
app/views/layouts/application.html.erb
Normal file
16
app/views/layouts/application.html.erb
Normal file
@@ -0,0 +1,16 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>CancanAttrTest</title>
|
||||
<%= stylesheet_link_tag "application", :media => "all" %>
|
||||
<%= javascript_include_tag "application" %>
|
||||
<%= csrf_meta_tags %>
|
||||
</head>
|
||||
<body>
|
||||
<p class="notice"><%= notice %></p>
|
||||
<p class="alert"><%= alert %></p>
|
||||
|
||||
<%= yield %>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
29
app/views/posts/_form.html.erb
Normal file
29
app/views/posts/_form.html.erb
Normal file
@@ -0,0 +1,29 @@
|
||||
<%= form_for(@post) do |f| %>
|
||||
<% if @post.errors.any? %>
|
||||
<div id="error_explanation">
|
||||
<h2><%= pluralize(@post.errors.count, "error") %> prohibited this post from being saved:</h2>
|
||||
|
||||
<ul>
|
||||
<% @post.errors.full_messages.each do |msg| %>
|
||||
<li><%= msg %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<div class="field">
|
||||
<%= f.label :user_id %><br />
|
||||
<%= f.text_field :user_id %>
|
||||
</div>
|
||||
<div class="field">
|
||||
<%= f.label :title %><br />
|
||||
<%= f.text_field :title %>
|
||||
</div>
|
||||
<div class="field">
|
||||
<%= f.label :body %><br />
|
||||
<%= f.text_area :body %>
|
||||
</div>
|
||||
<div class="actions">
|
||||
<%= f.submit %>
|
||||
</div>
|
||||
<% end %>
|
||||
6
app/views/posts/edit.html.erb
Normal file
6
app/views/posts/edit.html.erb
Normal file
@@ -0,0 +1,6 @@
|
||||
<h1>Editing post</h1>
|
||||
|
||||
<%= render 'form' %>
|
||||
|
||||
<%= link_to 'Show', @post %> |
|
||||
<%= link_to 'Back', posts_path %>
|
||||
27
app/views/posts/index.html.erb
Normal file
27
app/views/posts/index.html.erb
Normal file
@@ -0,0 +1,27 @@
|
||||
<h1>Listing posts</h1>
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<th>User</th>
|
||||
<th>Title</th>
|
||||
<th>Body</th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
</tr>
|
||||
|
||||
<% @posts.each do |post| %>
|
||||
<tr>
|
||||
<td><%= post.user_id %></td>
|
||||
<td><%= post.title %></td>
|
||||
<td><%= post.body %></td>
|
||||
<td><%= link_to 'Show', post %></td>
|
||||
<td><%= link_to 'Edit', edit_post_path(post) %></td>
|
||||
<td><%= link_to 'Destroy', post, method: :delete, data: { confirm: 'Are you sure?' } %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</table>
|
||||
|
||||
<br />
|
||||
|
||||
<%= link_to 'New Post', new_post_path %>
|
||||
5
app/views/posts/new.html.erb
Normal file
5
app/views/posts/new.html.erb
Normal file
@@ -0,0 +1,5 @@
|
||||
<h1>New post</h1>
|
||||
|
||||
<%= render 'form' %>
|
||||
|
||||
<%= link_to 'Back', posts_path %>
|
||||
20
app/views/posts/show.html.erb
Normal file
20
app/views/posts/show.html.erb
Normal file
@@ -0,0 +1,20 @@
|
||||
<p id="notice"><%= notice %></p>
|
||||
|
||||
<p>
|
||||
<b>User:</b>
|
||||
<%= @post.user %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<b>Title:</b>
|
||||
<%= @post.title %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<b>Body:</b>
|
||||
<%= @post.body %>
|
||||
</p>
|
||||
|
||||
|
||||
<%= link_to 'Edit', edit_post_path(@post) %> |
|
||||
<%= link_to 'Back', posts_path %>
|
||||
Reference in New Issue
Block a user