Controller has to modify the session_id before saving the information.
user.rb
has_one :room
class Room < ApplicationRecord
belongs_to :user, optional: true
end
Rooms_controller.rb
n_room = room_params
n_room[:room][:session_id] = session.session_id
respond_to do |format|
binding.pry
if current_user.create_room(params[:n_room])
format.html { redirect_to '/rooms/#{@new_room.id}'}
But this is not working, the session_id is not stored in the rooms row.
Question 1: How to modify 'rooms_params'? Question 2: How to pass it to rooms model in the line 'current_user.create_room'? Thank you