title: Rails is not assigning a user id to my wiki object
body: <p>I'm a beginner, and have been learning Ruby on Rails for about 4 months now. </p>
  
  <p>I'm building a basic wiki app that is supposed to allow for private wikis. Right now, when a user creates a wiki, rails is not assigning a user id to the wiki. When I look at the wiki in the rails console, everything is there - created_at, title, body, wiki id - but the user_id is always nil. How can I fix this? </p>
  
  <p>Here is my Wikis Controller: </p>
  
  <pre><code>class WikisController &lt; ApplicationController
        def index
  
          @wikis = Wiki.all     
        end
  
        def new
          @wiki =Wiki.new
          authorize @wiki
        end
  
        def show
          @wiki = Wiki.find(params[:id])
        end
  
        def edit
          @wiki = Wiki.find(params[:id])
          authorize @wiki
        end
  
        def update
          @wiki = Wiki.find(params[:id])
          authorize @wiki
          if @wiki.update_attributes(wiki_params)
            flash[:notice] = "Wiki was updated."
            redirect_to @wiki
          else
            flash[:error] = "There was an error updating the wiki."
            render :edit
          end
        end
  
        def create
          @wiki = Wiki.new(wiki_params)
          authorize @wiki
          if @wiki.save
            flash[:notice] = "Wiki was saved."
            redirect_to @wiki
          else
            flash[:error] = "There was an error saving the wiki. Please try again."
            render :new
          end 
        end
  
        def destroy
          @wiki = Wiki.find(params[:id])
          name = @wiki.title
          if @wiki.destroy
            flash[:notice] =  "\"#{name}\" was deleted."
            redirect_to wikis_path
            else
            flash[:error] = "There was an error deleting the wiki."
            redirect_to @wiki
          end
        end
      end
  
      private
  
        def wiki_params 
          params.require(:wiki).permit(:title, :body, :private, :user_id)
        end
  </code></pre>
  
  <p>... and here are my models: </p>
  
  <pre><code>    class User &lt; ActiveRecord::Base
  
  
      def admin?
        role == 'admin'
      end
  
      def member?
        role == 'member'
      end
  
      def premium_member?
        role == 'premium_member'
      end
  
  
      has_many :collaborations
      has_many :wikis, through: :collaborations
  
        devise :database_authenticatable, :registerable,
               :recoverable, :rememberable, :trackable, :validatable, :confirmable
  
      end
  </code></pre>
  
  <p>join table...</p>
  
  <pre><code>class Collaboration &lt; ActiveRecord::Base
    belongs_to :user
    belongs_to :wiki
  end
  </code></pre>
  
  <p>wiki model...</p>
  
  <pre><code>class Wiki &lt; ActiveRecord::Base
    has_many :collaborations
    has_many :users, through: :collaborations
  
  end
  </code></pre>
  
  <p>and finally, the schema: </p>
  
  <pre><code>create_table "collaborations", force: true do |t|
      t.integer "user_id"
      t.integer "wiki_id"
    end
  
    create_table "users", force: true do |t|
      t.string   "name"
      t.string   "role",                   default: "member", null: false
      t.string   "email",                  default: "",       null: false
      t.string   "encrypted_password",     default: "",       null: false
      t.string   "reset_password_token"
      t.datetime "reset_password_sent_at"
      t.datetime "remember_created_at"
      t.integer  "sign_in_count",          default: 0,        null: false
      t.datetime "current_sign_in_at"
      t.datetime "last_sign_in_at"
      t.string   "current_sign_in_ip"
      t.string   "last_sign_in_ip"
      t.string   "confirmation_token"
      t.datetime "confirmed_at"
      t.datetime "confirmation_sent_at"
      t.string   "unconfirmed_email"
      t.datetime "created_at"
      t.datetime "updated_at"
    end
  
    add_index "users", ["email"], name: "index_users_on_email", unique: true
    add_index "users", ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
  
    create_table "wikis", force: true do |t|
      t.string   "title"
      t.string   "body"
      t.integer  "user_id"
      t.datetime "created_at"
      t.datetime "updated_at"
      t.boolean  "private",    default: false
    end
  </code></pre>