Skip to content

Commit

Permalink
autoset user id based on current_user
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh Burns committed Jun 19, 2019
1 parent f0e8efc commit e744979
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
3 changes: 2 additions & 1 deletion app/controllers/publications_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
class PublicationsController < ApplicationController
before_action :set_publication, only: [:show, :edit, :update, :destroy]
before_action :authenticate_user!, except: [:show, :index]

# GET /publications
# GET /publications.json
Expand All @@ -24,7 +25,7 @@ def edit
# POST /publications
# POST /publications.json
def create
@publication = Publication.new(publication_params)
@publication = Publication.new(publication_params.merge(user: current_user))

respond_to do |format|
if @publication.save
Expand Down
11 changes: 7 additions & 4 deletions app/views/publications/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,13 @@
<%= form.file_field :file, multiple: false, direct_upload: true %>
</div>

<div class="field">
<%= form.label :user_id %>
<%= form.text_field :user_id %>
</div>
<!--
- <div class="field">
- <%= form.label :user_id %>
- <%= form.text_field :user_id %>
- </div>
-
-->

<div class="actions">
<%= form.submit %>
Expand Down

0 comments on commit e744979

Please sign in to comment.