Rails Rich Text (Trix) return NoMethodError: undefined method `render' for nil:NilClass

Viewed 111

When I try to run a rake task, Trix return this error NoMethodError: undefined method "render" for nil:NilClass in this file:

/bundle/ruby/2.7.0/gems/actiontext-6.0.0/lib/action_text/content.rb:91:in `to_rendered_html_with_layout'
/bundle/ruby/2.7.0/gems/actiontext-6.0.0/lib/action_text/content.rb:95:in `to_s'
/bundle/ruby/2.7.0/gems/actiontext-6.0.0/app/models/action_text/rich_text.rb:12:in `to_s'

In console, in development environment, when I request a model instance and get model.content works. But, when I request this in rake task (paused by byebug or printing with puts) I get this error: *Error in evaluation*.

In normal runnig everything is working, same for rails console. This error shows only in rake task, even though I just fetching the model from the database and trying to call model.content.

model.content is not blank.

0 Answers
Related