Displaying existing content in Rails 5.2 with ActionText

前提是你 提交于 2019-12-11 12:50:47

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!