Skip to content

Commit

Permalink
Refs #14: save changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikBrendel committed Nov 3, 2017
1 parent 20cdf96 commit f7020d5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
17 changes: 16 additions & 1 deletion app/controllers/authors_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,27 @@ def edit
end

def create
@author = Author.new(params.require(:author).permit(:first_name, :last_name, :homepage))
@author = Author.new(author_params)

if @author.save
redirect_to @author
else
render 'new'
end
end

def update
@author = Author.find(params[:id])

if @author.update(author_params)
redirect_to @author
else
render 'edit'
end
end
end

private
def author_params
params.require(:author).permit(:first_name, :last_name, :homepage)
end
1 change: 1 addition & 0 deletions spec/features/author/edit_author_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
end
it 'should edit with no error' do
@alan = FactoryGirl.create :author
visit edit_author_path(@alan)

fill_in 'author_first_name', with: 'Alan Mathison'
find('input[type="submit"]').click
Expand Down

0 comments on commit f7020d5

Please sign in to comment.