我有一个窗体,有复选框,trix编辑器,单选按钮和文本字段。当我在管理界面中编辑记录时,窗体将显示所有文本字段。我无法看到trix编辑器,复选框和单选按钮。编辑表单复选框,收音机和trix编辑器没有得到预填充ActiveAdmin
我知道as: :radio
和as: :check_boxes
和as: :trix_editor
应该工作,但他们没有得到预先填充已保存的值
这是我jobposting.rb文件。
任何帮助将非常感激。
form do |f|
f.inputs "New Job Posting" do
f.input :title
f.input :description, as: :trix_editor
f.input :how_to_apply, as: :trix_editor
f.input :job_type, as: :radio
f.input :city
f.input :user_id
f.input :categories, as: :check_boxes
f.input :publish
end
f.actions
end
和形式出现这样
它没有显示的字段(说明,如何申请),它应该有TRIX编辑器。对于电台(作业类型)和复选框(分类)字段显示其简单的是和no..where作为这些字段的实际值是这些
EDITED
Started GET "/admin/job_postings/3/edit" for ::1 at 2017-02-11 12:41:22 +0530
Processing by Admin::JobPostingsController#edit as HTML
Parameters: {"id"=>"3"}
AdminUser Load (0.4ms) SELECT "admin_users".* FROM "admin_users" WHERE "admin_users"."id" = $1 ORDER BY "admin_users"."id" ASC LIMIT 1 [["id", 1]]
JobPosting Load (0.3ms) SELECT "job_postings".* FROM "job_postings" WHERE "job_postings"."id" = $1 LIMIT 1 [["id", 3]]
CACHE (0.0ms) SELECT "job_postings".* FROM "job_postings" WHERE "job_postings"."id" = $1 LIMIT 1 [["id", "3"]]
Rendered /Users/KrishnaTeja/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/bundler/gems/activeadmin-2bb5021f81c2/app/views/active_admin/resource/edit.html.arb (270.1ms)
Completed 500 Internal Server Error in 367ms (ActiveRecord: 7.4ms)
ActionView::Template::Error (undefined method `categories' for #<Class:0x007ffdd084e420>):
1: insert_tag renderer_for(:edit)
app/admin/job_postings.rb:26:in `block (3 levels) in <top (required)>'
app/admin/job_postings.rb:18:in `block (2 levels) in <top (required)>'
Rendered /Users/KrishnaTeja/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/actionpack-4.2.7.1/lib/action_dispatch/middleware/templates/rescues/_source.erb (16.6ms)
Rendered /Users/KrishnaTeja/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/actionpack-4.2.7.1/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb (7.9ms)
Rendered /Users/KrishnaTeja/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/actionpack-4.2.7.1/lib/action_dispatch/middleware/templates/rescues/_request_and_response.html.erb (1.8ms)
Rendered /Users/KrishnaTeja/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/actionpack-4.2.7.1/lib/action_dispatch/middleware/templates/rescues/template_error.html.erb within rescues/layout (115.2ms)
这是我views/job_postings/_form.html.erb
如果选中categorie它不是来自任何有数组并遍历它的表。
<%= form_for @job_posting do |f| %>
<% if @job_posting.errors.any? %>
<div id="errors">
<h2><%= pluralize(@job_posting.errors.count, "error") %> prevented this post from saving:</h2>
<ul>
<% @job_posting.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>
<p>
<%= f.label :title %>
<%= f.text_field :title %>
</p>
<p>
<%= f.label :description %>
<%= f.trix_editor :description %>
</p>
<p>
<%= f.label :how_to_apply %>
<%= f.trix_editor :how_to_apply %>
</p>
<p>
<%= f.label :categories %>
<% [ 'Front End', 'Back End', 'Others'].each do |category| %>
<%= label_tag "job_posting_categories_#{category}", category %>
<%= check_box_tag "job_posting[categories][]", category, checked(category), id: "job_posting_categories_#{category}" %>
<% end %>
</p>
<p>
<%= f.label :job_type %>
<% [ 'FullTime', 'Contract', 'PartTime', 'Freelance', 'Intern'].each do |job_type| %>
<%= f.radio_button 'job_type', job_type %>
<%= job_type.humanize %>
<% end %>
</p>
<p>
<%= f.label :city %>
<%= f.text_field :city %>
</p>
<%= f.submit "Post Job" %>
<% end %>
能否请您发布的代码与'check_bo xes'和'radio'等等,因为就像你现在发布的那样,呈现的东西是完美的。我们需要根据需要查看代码,然后生成屏幕截图 – LBarry
@LBarry我添加了更多信息。对不起,不准确。 –
@KrishnaTejaKarnam:我们更喜欢在这里回答问题的答案。您是否会将其复制到自我回答中,然后在添加解决方案之前将问题回滚到最新状态?谢谢。 – halfer