[Help] How to pass current_user to update method?


I have 3 models:

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

            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


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