Tag: 回形针

尝试使用回形针上传图像时Rails收到错误

我只是开始学习rails并继续遇到我通常通过搜索来解决的错误。 我按照http://guides.rubyonrails.org/getting_started.html上的教程完成了它,现在我正在尝试将图像上传到博客文章中。 但现在我被困在一个听起来非常简单的事情,使用回形针上传图像。 我得到的错误如下: 未定义的方法`附件’为# 这是我的文件: articles_controller.rb class ArticlesController < ApplicationController def index @articles = Article.all end def show @article = Article.find(params[:id]) end def new @article = Article.new end def edit @article = Article.find(params[:id]) end def create @article = Article.new(article_params) #@article = Article.create(article_params) if @article.save redirect_to @article else render 'new' end end def update @article […]

没有路线匹配固定图像的

当current_user单击pin时,该图像如何保存到current_user ? 按钮: 产出 : pry(main)> Inspiration.first id: 1, user_id: 1, image_file_name: “choose-optimism.png”, image_content_type: “image/png”, image_file_size: 230082, pry(main)> Inspiration.last id: 2, # Creating the issue of the route error & image not rendering user_id: 2, image_file_name: “choose-optimism.png”, image_content_type: “image/png”, image_file_size: 230082, 固定图像的id不同,给出错误: No route matches [GET] “/system/inspirations/images/000/000/002/medium/choose-optimism.png” 工作图像有001 : /system/inspirations/images/000/000/001/medium/choose-optimism.png?1478840469 解决此问题的最佳方法是什么,以便我可以继续传递不同的ID,但使用相同的图像? 调节器 @inspirations = @user.inspirations […]

Rails 3 / paperclip / imagemagick – 合并两个图像

当用户在我的rails应用程序上传图像时,imagemagick处理两个转换: has_attached_file :photo, :styles => { :listsize => “50×50#”, :articlesize => “300×300” }, 生成列表大小(方形50x50px)图像。 此时是否可以将此图像与标准透明png合并,使图像看起来更像图标? (我有png图像,我只是想知道是否可以渲染另一个将这个默认透明png放在:listsize图像上的照片样式)。 谢谢

使用Ruby on Rails 3显示’file_field’的’size’属性的问题

我正在使用Ruby on Rails 3,我有一个这样的表单: … “test_id”, :style => “display: block”, :size => “13” %> … 当我去查看页面的来源时,这是生成的HTML代码: 这意味着’size’属性没有。 我试过Firefox,Chrome和Safari:相同的输出,但它似乎已正确设置所有内容。 这是与RoR3相关的问题吗?

ActiveAdmin中的Formtastic提示问题(不需要的对象ID输出)

当我使用formtastic DSL for ActiveAdmin编辑表单时,我得到以下输出: #<#:0x00000006bd1018> Image 为什么这会从obj.inspect的结果以及如何删除这部分开始呢? 导致此错误的代码在这里: form :html => { :multipart => true } do |f| f.inputs do #… f.input :image, required: false, hint: f.template.image_tag(f.object.image.url(:medium)).html_safe #… end f.actions end

回形针不保存,没有错误

我跌跌撞撞 – 经历过文档,教程等,我不确定我做错了什么。 该项目中的另一个模型是为Paperclip设置的,并在测试时起作用。 它将附件文件信息保存并检索到数据库中,并将文件放入public / system中的子文件夹中。 我基本上将相关代码复制到我正在处理的模型上 该模型具有以下行: has_attached_file :document 该模型链接到的表具有必要的列: document_file_name document_content_type document_file_size document_updated_at 编辑视图有这个(以haml为单位): %h1 Knowledge Base: Edit Article = message_block :on => @article – form_for(@article, :url => knowledge_base_article_path(@article), :html => {:multipart => true}) do |f| #knowledgebase.clearfix %label Upload KB Document: %br = f.file_field :document – if @article.document.exists? %p = link_to “Current […]

Paperclip不支持.doc文件

在rails 4.0.2中,我使用paperclip gem上传文件。 但它不支持.doc文件。 在文件上传字段下方,它显示错误消息“具有与其内容不匹配的扩展名” 在模型中,检查内容类型的validation如下: validates_attachment_content_type :document, :content_type => [‘application/txt’, ‘text/plain’, ‘application/pdf’, ‘application/msword’, ‘application/vnd.openxmlformats-officedocument.wordprocessingml.document’, ‘application/vnd.oasis.opendocument.text’, ‘application/x-vnd.oasis.opendocument.text’, ‘application/rtf’, ‘application/x-rtf’, ‘text/rtf’, ‘text/richtext’, ‘application/doc’, ‘application/docx’, ‘application/x-soffice’, ‘application/octet-stream’] 现在使用的gem rails (4.0.2, 4.0.0, 3.2.13, 3.2.8, 3.0.4, 3.0.3) paperclip (3.5.2, 2.3.11, 2.3.8) 我该如何解决这个问题?

重定向禁止/坏uri(脸谱)回形针图像

我正在尝试将用户的facebook url保存到我的数据库中,但是我收到以下错误。 redirection forbidden: http://graph.facebook.com/1240771104/picture -> https://fbcdn-profile-a.akamaihd.net/hprofile-ak-prn2/t… 我已经引用了这个问题,但我认为他只是调用一个图像而不是将其保存到带有创建块的数据库中。 这是我的用户模型…… def self.find_for_facebook_oauth(auth, signed_in_resource=nil) user = User.where(:provider => auth.provider, :uid => auth.uid).first if user return user else registered_user = User.where(:email => auth.info.email).first if registered_user return registered_user else user = User.create( name:auth.extra.raw_info.name, provider:auth.provider, uid:auth.uid, email:auth.info.email, image:auth.info.image, password:Devise.friendly_token[0,20], ) end end end 我在’def.self_for_facebook’下面添加了一个URI帮助器,因为我认为我只需要将http发送到https。 所以我从另一个堆栈问题中收集到了。 private def process_uri(uri) require ‘open-uri’ […]

ruby1.8.7上的回形针2.7.0

我有一个非常古老的rails应用程序(rails 2.3.10和ruby 1.8.7),我们想在另一台服务器上移动它。 除了paperclip 2.7,我可以重新安装所有相同版本的gem。 当我试图安装它时,我在activesupport上收到一个错误,它似乎需要ruby 1.9.3。 根据paperclip doc,这不应该发生,你们中的一些人可以帮助我吗? 我尝试了所有gem,除了回形针,没有gem,并安装旧版本的activesupport。 您可以在下面找到我的测试。 app@new-server:/home/app/current# sudo gem list *** LOCAL GEMS *** app@new-server:/home/app/current# sudo gem install paperclip -v=2.7.0 Fetching: i18n-0.6.4.gem (100%) Successfully installed i18n-0.6.4 Fetching: multi_json-1.7.7.gem (100%) Successfully installed multi_json-1.7.7 Fetching: tzinfo-0.3.37.gem (100%) Successfully installed tzinfo-0.3.37 Fetching: minitest-4.7.5.gem (100%) Successfully installed minitest-4.7.5 Fetching: atomic-1.1.10.gem (100%) Building native extensions. […]

问题回形针与ajax

我正在阅读本教程: http : //sleekd.com/general/adding-multiple-images-to-a-rails-model-with-paperclip/因为我需要在独立模型中保存产品图像。 但是,当Product.create执行时,请不要保存产品图像模型的数据。 注意:我使用新的包操作,因为我需要使用ajax来创建新产品。 我需要帮助。 我的代码 控制器 class Admin::PacksController @pack } end end def create_starred_product product = Product.new(params[:product]) product.save … end 视图 {:controller => “products”, :action => “create_starred_product”}, :html => {:multipart => true} do |f| %> ….#OTHER FIELDS OF PRODUCT. ITS SAVE METHOD IS OK Imágenes Imagen “textarea” -%> 楷模 class Product :pack_products […]