【问题标题】:Rails form displaying actual object text显示实际对象文本的 Rails 表单
【发布时间】:2014-10-08 05:26:55
【问题描述】:

我有一个表单,允许一次更新我的treatment_strategies 表中的多个记录。它工作正常,但由于某种原因,它在视图本身的输入字段上方显示了大量文本。该文本似乎是所有对象本身:

[#<TreatmentStrategy id: 1, treatment_id: nil, agency_id: 1, name: "Develop agency leader     characteristics supporting i...", selected: false, created_at: "2014-10-08 04:48:13", updated_at: "2014-10-08 04:59:48", specifics: "", implementer: "", use_currently: false, feasible: false, previous_success: false, recommended: false>, #<TreatmentStrategy id: 2, treatment_id: nil, agency_id: 1, name: "Recruit, designate, and train leaders for the chan...", selected: false, created_at: "2014-10-08 04:48:13", updated_at: "2014-10-08 04:59:48", specifics: "", implementer: "", use_currently: false, feasible: false, previous_success: false, recommended: false>, #<TreatmentStrategy id: 3, treatment_id: nil, agency_id: 1, name: "Leaders mandate the use of the intervention strate...", selected: false, created_at: "2014-10-08 04:48:13", updated_at: "2014-10-08 04:59:48", specifics: "", implementer: "", use_currently: false, feasible: false, previous_success: false, recommended: false>, #<TreatmentStrategy id:

我怎样才能摆脱所有这些文字?

这是我的代码:

                = form_tag update_individual_treatment_strategies_path, :method => "put", :id => "myForm" do |f|    
                = for treatment_strategies in @current_agency.treatment_strategies.order('created_at ASC')
                    =fields_for "treatment_strategies[]", treatment_strategies do |f|                   
                        %tr
                            %td
                                = treatment_strategies.name
                            %td
                                .custom-cell-left
                                    = f.check_box :use_currently
                                    Use Currently
                                    %br
                                    = f.check_box :previous_success 
                                    Previous success
                                .custom-cell-right
                                    = f.check_box :feasible
                                    Feasible
                                    %br
                                    = f.check_box :recommended
                                    Recommended
                            %td.text-center
                                = f.check_box :selected
                            %td
                                = f.text_area :specifics
                            %td
                                = f.text_field :implementer

                = submit_tag 'Save', class: 'btn btn-primary', style: "display:none;"

【问题讨论】:

    标签: ruby-on-rails forms view


    【解决方案1】:

    知道了:我必须将行的“=”切换为“-”:

    = @current_agency.treatment_strategies.order('created_at ASC') 中的治疗策略

    HAML 仍在拨入...

    【讨论】:

      猜你喜欢
      • 2012-10-20
      • 2018-11-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多