我已经成功地使用载波上传图像文件。我希望表单能够接受图像文件和 pdf 文件。当我尝试上传 pdf 时,它不上传文件。它与该行有关:
process :resize_to_fill => [166,166]
Run Code Online (Sandbox Code Playgroud)
如果我把它去掉,pdf就可以了。问题是我需要那条线,因为我需要调整所有上传的图片的大小。这是上传者:
class PortfoliofileUploader < CarrierWave::Uploader::Base
include CarrierWave::MiniMagick
def store_dir
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
version :picture do
process :resize_to_fill => [166,166]
end
def extension_white_list
%w(jpg jpeg gif png pdf doc docx)
end
end
Run Code Online (Sandbox Code Playgroud)
有谁知道我该如何修复它以便图像和 pdf 可以工作?谢谢。
更新:
作品集展示页面(2个版本):
版本1:
<% @portfolio.portfolio_pics.collect{|picture| picture.port_pic.picture}.each do |pic| %>
<li><a href="#"><%= image_tag pic %></a></li>
<% end %>
Run Code Online (Sandbox Code Playgroud)
版本2:
<% @portfolio.portfolio_pics.each do |pic| %>
<li><a href="#"><%= image_tag pic.port_pic.picture %></a></li>
<% end %>
Run Code Online (Sandbox Code Playgroud) 我有隐藏的复选框。我将图像作为复选框的标签,以便在单击图像时单击复选框。我试图根据是否选中该框使图像具有不同的不透明度。这是我用于图像标签的 css:
.checkbox-label{
opacity: .2;
}
.checkbox-label:hover{
opacity: .5;
}
.checkbox-label-after-click{
opacity: 1;
}
Run Code Online (Sandbox Code Playgroud)
这是我移动课程的 javascript
<script>
$('.checkbox-label').click(function(){
var the_input = $(this).next('input');
if(the_input.checked){
$(this).addClass( "checkbox-label-after-click" );
} else {
$(this).removeClass("checkbox-label-after-click");
}
});
</script>
Run Code Online (Sandbox Code Playgroud)
基本上,当有人点击标签时,它应该抓取下一个输入,即复选框,标签的类应该改变。我也试过切换 addClass 和 removeClass 方法,这使得类切换在第一次点击时起作用,但永远不会。
这是html:
我如何让这个工作?
我有以下Ruby:
<%= simple_form_for @answer, url: presentation_survey_path(@presentation) do |f| %>
<%= f.collection_radio_buttons :option_id, @question.options_array, :first, :last, {label: false} do |b| %>
<div class="col-sm-4">
<%= b.label(class: 'btn btn-large', style: 'margin-right: 20px; margin-left: 20px;') {b.radio_button(id: b.object.last, class: 'answer-input', style: 'display: none;') + b.text } %>
</div>
<% end %>
Run Code Online (Sandbox Code Playgroud)
它正确生成html,除了它生成两个标签:
<span>
<label for="answer_option_id_15">
<div class="col-sm-4">
<label class="btn btn-large" for="answer_option_id_15" style="margin-right: 20px; margin-left: 20px;">
<input class="answer-input" id="Way too many" name="answer[option_id]" style="display: none;" type="radio" value="15" />
Way too many
</label>
</div>
</label>
</span>
Run Code Online (Sandbox Code Playgroud)
由于某种原因,它正在制造第一个标签.我只想保留第二个.标签:false不起作用.如何摆脱第一个标签?
ruby ruby-on-rails simple-form ruby-on-rails-4 simple-form-for
我正在尝试将一个字段添加到使用设计的注册页面.我按照Devise文档中的说明进行操作.新字段是"角色"字段.我已成功将其迁移到数据库.我现在正努力使注册有效.这是新的applicationcontroller:
class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
def devise_parameter_sanitizer
if resource_class == User
User::ParameterSanitizer.new(User, :user, params)
else
super # Use the default one
end
end
end
Run Code Online (Sandbox Code Playgroud)
这是更改的用户模型:
class User::ParameterSanitizer < Devise::ParameterSanitizer
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
def sign_up
default_params.permit(:email, :role)
end
end
Run Code Online (Sandbox Code Playgroud)
一旦我添加了这两个文件,服务器甚至无法加载.如何成功添加角色字段?
编辑
这是我的routes.rb文件 …
我有一个用户注册表:
<%= form_for(resource, :as => resource_name,
:url => registration_path(resource_name),
:id => "employer-form") do |f| %>
<%= devise_error_messages! %>
<p><%= f.email_field :email, :autofocus => true, :title => "Enter email", :value =>"Enter Email", :class =>"field" %></p>
<p><%= f.text_field :profile_name, :autofocus => true, :title => "Enter Username", :value => "Enter Username", :class =>"field" %></p>
<p class="clearfix">
<%= f.password_field :password, :title => "Enter Password", :value => "Enter Password", :class => "field field-half" %>
<%= f.password_field :password_confirmation, :title => "Retype Password", :value => "Retype Password", …
Run Code Online (Sandbox Code Playgroud) 我正在使用带有braintree沙箱的braintree gem并尝试设置web钩子.我有以下代码:
class PaymentsController < ApplicationController
def webhooks
challenge = request.params["bt_challenge"]
challenge_response = Braintree::WebhookNotification.verify(challenge)
return [200, challenge_response]
end
end
Run Code Online (Sandbox Code Playgroud)
但出于某种原因,当我在braintree的网站上按"创建网络钩子"时,我被告知:
Destination could not be verified.
Run Code Online (Sandbox Code Playgroud)
我检查了服务器日志并且它正在接收请求,但是由于某种原因返回http 500并说出以下内容:
2014-04-09T23:39:19.937280+00:00 app[web.1]: Completed 500 Internal Server Error in 71ms
2014-04-09T23:39:19.941486+00:00 app[web.1]: ActionView::MissingTemplate (Missing template payments/webhooks, application/webhooks with {:locale=>[:en], :formats=>[:xml, :html, :text, :js, :css, :ics, :csv, :png, :jpeg, :gif, :bmp, :tiff, :mpeg, :xml, :rss, :atom, :yaml, :multipart_form, :url_encoded_form, :json, :pdf, :zip], :handlers=>[:erb, :builder, :raw, :ruby, :coffee, :arb, :jbuilder, :haml]}. Searched in:
Run Code Online (Sandbox Code Playgroud)
这表明控制器正在寻找视图而无法找到它.我不知道该怎么做.Web挂钩操作中的代码直接来自braintree的网站:https://www.braintreepayments.com/docs/ruby/guide/webhook_notifications …
ruby ×3
braintree ×1
carrierwave ×1
checkbox ×1
css ×1
devise ×1
forms ×1
html-select ×1
imagemagick ×1
javascript ×1
jquery ×1
minimagick ×1
simple-form ×1
this ×1
webhooks ×1