- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试将 refile 连接到我的 View ,但出现以下错误:
这是我的模型:
class Job < ActiveRecord::Base
acts_as_paranoid
acts_as_taggable
acts_as_taggable_on :languages
belongs_to :company
belongs_to :category
validates :title,
:location,
:category,
:language_list,
:short_description,
:description,
:application_process,
presence: true
end
class Company < ActiveRecord::Base
acts_as_paranoid
has_many :jobs
attachment :company_logo, type: :image
validates :name, :url, :email, presence: true
end
= render layout: 'header' do
= simple_form_for(@job) do |j|
div[class='panel-heading']
h3[class='panel-title']
|Position Details
div[class='panel-body']
= j.input :title
= j.input :location
= j.association :category, as: :radio_buttons
= j.input :language_list, as: :check_boxes, collection: @tags
= j.input :short_description
= j.input :description, input_html: { class: 'textarea-height wysihtml5' }
= j.input :application_process
div[class='panel-heading']
h3[class='panel-title']
|Company Details
div[class='panel-body']
= j.simple_fields_for :company do |jc|
= jc.input :name
= binding.pry
= jc.input :company_logo, as: :attachment
= jc.input :url
= jc.input :email
div[class='panel-heading panel-heading-info']
h3[class='panel-title']
|Would you like your job posting featured?
div[class='panel-body']
p
|Featured posted are promoted with additional design elements to grab the
job seeker's attention. This additional marketing capability can be purchased
for an additonal $#{AppConfig.product['settings']['job_base_featured_price']}.
= j.input :is_featured
= j.button :button, type: 'button', class: 'btn-primary' do
= job_posting_button_step_label
=>
i[class='fa fa-arrow-circle-right']
attachment_field
未定义。
require 'refile/rails'
require 'refile/simple_form'
= jc.input :company_logo, as: :file, direct: true, presigned: true
最佳答案
经过长时间的战斗,我找到了解决这种情况的方法。首先我发现了这个 SO 帖子 Styling file upload button for simple_form_for with Bootstrap in Rails 3这让我尝试 https://github.com/jasny/bootstrap/ . Jasny 有一些不错的文件上传器,但所有的 gem 都已经过时了。 [注意,我希望这周有时间用补丁修复这个问题] 所以我将 Jasny 文件下载到供应商 javascripts 和 stylesheets 文件夹,如下所示:
我也用过 https://rails-assets.org/在我的 gemfile 中引入 holder.js:
source 'https://rails-assets.org' do
gem 'rails-assets-holderjs'
end
//= require refile
//= require holderjs
//= require jasny-bootstrap
// External Libraries Built For Bootstrap in Vendor
@import 'awesome-bootstrap-checkbox';
@import 'jasny-bootstrap';
= j.simple_fields_for :company do |jc|
= jc.input :name
div
label
= t('simple_form.labels.company.logo')
div[class="form-group fileinput fileinput-new" data-provides="fileinput"]
div[class="fileinput-new thumbnail" style="width: 200px; height: 200px;"]
img[data-src="holder.js/200x200" alt="..."]
div[class="fileinput-preview fileinput-exists thumbnail" style="max-width: 200px; max-height: 200px;"]
div
span[class="btn btn-default btn-file"]
span[class="fileinput-new"]
|Select image
span[class="fileinput-exists"]
|Change
= jc.input_field :logo, direct: true, presigned: true
a[href="#" class="btn btn-default fileinput-exists" data-dismiss="fileinput"]
|Remove
p[class="help-block"]
= t('simple_form.hints.company.logo')
= jc.input :url
= jc.input :email
关于ruby-on-rails - 重新归档 simple_form 未定义方法附件字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35285939/
我不确定这应该在 Java 脚本中还是在 HTML 部分中完成。我希望在 HTML 部分中使用这样的内容: "the_value_from_the_select_tag" %> Java 脚本中的工
我正在寻找一种方法来管理表单中的多个嵌入对象。 找到了 bowsersenior 的 formtastic 解决方案 Formtastic with Mongoid embedded_in relat
是否可以使用 CSS 将 simple_form 输入框的默认颜色从灰色更改为另一种颜色?这是我的 CSS: .simple_form div.input { width: 500px;
我正在尝试让我的 simple_form 提示显示为 twitter-bootstrap 工具提示,这样提示仅在用户选择输入字段或将鼠标悬停在输入字段上时出现。 表单项看起来像(在 haml 中):
我在我的 Rails 4.2 元素中使用 simple_form。在使用错误显示进行验证后,我在行/字段对齐方面遇到了一些问题。任何验证的字段都不会与验证失败的字段垂直对齐。
:boolean, :label => false, :boolean_style => :inline %> Accept true %> and true%> 它最终看起来像这样 将它们排在
我有很多控件的复杂表单,由于其灵 active ,我目前正在使用 simple_form gem。但是当我想做一些更复杂的事情时,我遇到了几个目前对我来说还很模糊的问题。我想介绍组合集合输入,它将呈现
简介:在应用程序中使用 simple_form,向属性添加验证,并在表单中的每个字段旁边正确显示错误。此外,我还有 2 个自定义验证,用于添加与模型属性无关的自定义错误消息。 问题:在基本的 Rail
如何使用表中的 simple_form 分组选项创建选择,而不是来自集合?试过: = f.input :countries, :collection => [["North America",[["U
在 simple_form github 上的示例 repo,有一个包含包装器信息的块。 https://github.com/rafaelfranca/simple_form-bootstrap/b
我正在使用 https://github.com/plataformatec/simple_form并试图发送一个额外的参数。我有一个 Task、List 和 ListTask 模型,在列表的新页面中
我正在查看这个 simple_form_for 表单(注册表单)(registrations/new.html.erb) 去用户/注册 resource_name, :url => registra
我在表单上使用 simple_form gem,并希望使用具有三个 text_fields 字段而不是三个选择字段的日期字段。 我试过这个: :string, :label => "Dia",
我想我要问一个由两部分组成的问题;如果这应该分成 2 个问题,我很抱歉。 首先,我试图将类(class)存储到 course 中与 course_days 具有 ActiveRecord 关系的表(类
我有一个名为“治疗”的模型。它本质上是一个与请求者和被请求者的 session 提案,也是一个 (1) :intro (2) :proposed_venue (3) :proposed_date (4
我正在尝试发送一个额外的参数,使用 simple_form 在 rails 中提交表单我认为这可以解决问题: 1) do |f| %> 但在 Controller 中,该参数被忽略 我在 here
我第一次在这里发帖! 我有一个表单,其中有很多字段并且它工作得很好,除非发生任何验证错误... 如果引发“validates_presence_of”,则会打开“ActiveRecord::Recor
我想为收藏品使用标签(例如,它们的翻译)。 = simple_form_for(@client) do |f| = f.error_notification .form-inputs
我正在切换我的应用程序以使用 simple_form但我对如何显示文本输入有点困惑。例如,当我执行以下操作时: f.input :foobar # 我得到一个 textarea 而不是在输入中输入一
我想在 simple_form 生成的输入标签上有一个额外的数据属性。 以下不起作用: 'date_picker', :data => {:datepicker => :datepicker} %
我是一名优秀的程序员,十分优秀!