首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ActionText未存储在create上

ActionText未存储在create上
EN

Stack Overflow用户
提问于 2022-05-27 09:09:58
回答 1查看 59关注 0票数 0

我正在构建Rails应用程序,希望管理员能够使用ActionText创建丰富的文本内容。我已经设置了应用程序根据手册,图像附件工作,但丰富的文本不,我看不到他们在我的本地数据库。怎么了,我错过了什么?P.s.:我想要一种形式的多个行动文本,但就目前而言,我只想让其中一个工作.

型号:

代码语言:javascript
复制
class Course < ApplicationRecord
    has_and_belongs_to_many :admins, join_table: 'courses_admins', class_name: 'Admin'
    has_many :lessons
    has_many :course_runs
    has_many :course_interests

    has_rich_text :what_you_learn
    # has_rich_text :skillset
    # has_rich_text :process
    # has_rich_text :harmonogram
    # has_rich_text :student_assignment

    has_one_attached :image
end

控制器POST方法:

代码语言:javascript
复制
# POST /courses or /courses.json
def create
    @course = Course.new(course_params)
    @course.image.attach(course_params[:image])


    respond_to do |format|
      if @course.save
        format.html { redirect_to course_url(@course), notice: "Course was successfully created." }
        format.json { render :show, status: :created, location: @course }
      else
        format.html { render :new, status: :unprocessable_entity }
        format.json { render json: @course.errors, status: :unprocessable_entity }
      end
    end
  end

和打字的对词:

代码语言:javascript
复制
def course_params
    params.require(:course).permit(
      :name,
      :annotation,
      :price,
      :capacity,
      :image,
      :what_you_learn
      # :skillset,
      # :process,
      # :harmonogram,
      # :student_assignment
    )
end
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-05-31 09:38:20

对感兴趣的人来说,问题是在.html.erb标记文件中,因为我复制了rich_text_area标记,而没有对其属性进行适当的演练。

变化

<%= form.rich_text_area :what_you_learn, class: 'form-control', name: "article-text", input_html: { rows: 10 } %>

<%= form.rich_text_area :what_you_learn, class: 'form-control', input_html: { rows: 10 } %>

然后,rich_text的内容不是以“文章文本”的形式发布的,而是正确地在params:what_you_learn内部发布的。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/72403056

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档