问题
I have upgraded my app to rails 5.2 and inclined to use ActionText since old trix-editor/gem is no longer working. Now new posts display their "descriptions" but how can I display my old posts' DESCRIPTIONS with the new installed ActionText?
post.rb has_rich_text :description
posts_controller.rb
...params.require(:post).permit(:description)
_form.html.erb
<%= f.rich_text_area :description %>
show.html.erb
<%= @post.description %>
Descriptions are only fetching from new records in ActionText but not displaying from existing "description" columns for old posts
回答1:
I had a similar issue and I couldn't find a clean solution in the rails repo or anywhere. As a workaround, in your case, I would try:
show.html.erb: .
<%= @post.try(:description).body || @post[:description] %>
That wont solve the issue, but it would help you to populate old post values.
来源:https://stackoverflow.com/questions/56816455/displaying-existing-content-in-rails-5-2-with-actiontext