[Help] How to pass current_user to update method?

Hi,

I have 3 models:

    Users
    has many :problems
    has many :answers through: :problems
    Problems
     belongs_to :user
     has_many :answers ,inverse_of :problem
     accepts_nested_attributes_for :answers, allow_destroy: true  , :reject_if => :all_blank


    Answers
            belongs_to :user

I have a method create on ProblemController:

@problem = current_user.problems.new(params)

This results to current_user_id being reference into new problem.

My concern is when the problem has been modified and “answers” has been added when problem has been edited.

The edit works fine but the current_user id is not being pass. And not sure if there’s any c

urrent_user.problems.update(params)

like functionality, I tried that but it doesn’t work.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs