Skip to content

Commit

Permalink
Refs #13: edit author page
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikBrendel committed Nov 3, 2017
1 parent bb5bdd7 commit 9aa2303
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
2 changes: 1 addition & 1 deletion app/controllers/authors_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def new
end

def edit
@article = Author.find(params[:id])
@author = Author.find(params[:id])
end

def create
Expand Down
25 changes: 15 additions & 10 deletions app/views/authors/edit.html.erb
Original file line number Diff line number Diff line change
@@ -1,29 +1,34 @@
<h1>Editing author</h1>

<%= form_for :article, url: article_path(@article), method: :patch do |f| %>
<%= form_for :author, url: author_path(@author), method: :patch do |f| %>

<% if @article.errors.any? %>
<% if @author.errors.any? %>
<div id="error_explanation">
<h2>
<%= pluralize(@article.errors.count, "error") %> prohibited
this article from being saved:
<%= pluralize(@author.errors.count, 'error') %> prohibited
this author from being saved:
</h2>
<ul>
<% @article.errors.full_messages.each do |msg| %>
<% @author.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>

<p>
<%= f.label :title %><br>
<%= f.text_field :title %>
<%= f.label :first_name %><br>
<%= f.text_field :first_name %>
</p>

<p>
<%= f.label :text %><br>
<%= f.text_area :text %>
<%= f.label :last_name %><br>
<%= f.text_field :last_name %>
</p>

<p>
<%= f.label :homepage %><br>
<%= f.text_field :homepage %>
</p>

<p>
Expand All @@ -32,4 +37,4 @@

<% end %>

<%= link_to 'Back', articles_path %>
<%= link_to 'Back', authors_path %>

0 comments on commit 9aa2303

Please sign in to comment.