diff --git a/app/controllers/papers_controller.rb b/app/controllers/papers_controller.rb index f4a6d37..d54b485 100644 --- a/app/controllers/papers_controller.rb +++ b/app/controllers/papers_controller.rb @@ -7,6 +7,10 @@ def new @paper = Paper.new end + def edit + @paper = Paper.find(params[:id]) + end + def show @paper = Paper.find(params[:id]) end @@ -20,6 +24,16 @@ def create render 'new' end end + + def update + @paper = Paper.find(params[:id]) + + if @paper.update(paper_params) + redirect_to @paper + else + render 'edit' + end + end end private diff --git a/app/views/papers/edit.html.erb b/app/views/papers/edit.html.erb new file mode 100644 index 0000000..145f44b --- /dev/null +++ b/app/views/papers/edit.html.erb @@ -0,0 +1,40 @@ +
+ <%= f.label :title %>
+ <%= f.text_field :title %>
+
+ <%= f.label :venue %>
+ <%= f.text_field :venue %>
+
+ <%= f.label :year %>
+ <%= f.text_field :year %>
+
+ <%= f.submit %> +
+ +<% end %> + +<%= link_to 'Back', papers_path %> \ No newline at end of file diff --git a/app/views/papers/index.html.erb b/app/views/papers/index.html.erb index ae2c28a..01ee970 100644 --- a/app/views/papers/index.html.erb +++ b/app/views/papers/index.html.erb @@ -9,6 +9,7 @@