Why is there no image after creating a record in Refinery CMS?

依然范特西╮ 提交于 2020-01-05 05:47:08

问题


I tried to create a refinerycms engine with a photo field in it, and came across this problem when rendering a page with an image.

I searched for answers with no result.

ArgumentError (Didn't recognise the geometry string ):
  dragonfly (0.9.15) lib/dragonfly/image_magick/processor.rb:104:in `thumb'
  dragonfly (0.9.15) lib/dragonfly/function_manager.rb:39:in `call'
  dragonfly (0.9.15) lib/dragonfly/function_manager.rb:39:in `block (2 levels) in call_last'
  dragonfly (0.9.15) lib/dragonfly/function_manager.rb:38:in `catch'
  dragonfly (0.9.15) lib/dragonfly/function_manager.rb:38:in `block in call_last'
  dragonfly (0.9.15) lib/dragonfly/function_manager.rb:37:in `each'
  dragonfly (0.9.15) lib/dragonfly/function_manager.rb:37:in `call_last'
  dragonfly (0.9.15) lib/dragonfly/processor.rb:5:in `process'
  dragonfly (0.9.15) lib/dragonfly/job.rb:79:in `apply'
  dragonfly (0.9.15) lib/dragonfly/job.rb:268:in `block in apply'
  dragonfly (0.9.15) lib/dragonfly/job.rb:268:in `each'
  dragonfly (0.9.15) lib/dragonfly/job.rb:268:in `apply'
  dragonfly (0.9.15) lib/dragonfly/response.rb:25:in `to_response'
  dragonfly (0.9.15) lib/dragonfly/server.rb:43:in `block in call'
  dragonfly (0.9.15) lib/dragonfly/server.rb:39:in `catch'
  dragonfly (0.9.15) lib/dragonfly/server.rb:39:in `call'
  journey (1.0.4) lib/journey/router.rb:68:in `block in call'
  journey (1.0.4) lib/journey/router.rb:56:in `each'
  journey (1.0.4) lib/journey/router.rb:56:in `call'
  actionpack (3.2.13) lib/action_dispatch/routing/route_set.rb:612:in `call'
  railties (3.2.13) lib/rails/engine.rb:479:in `call'
  railties (3.2.13) lib/rails/railtie/configurable.rb:30:in `method_missing'
  journey (1.0.4) lib/journey/router.rb:68:in `block in call'
  journey (1.0.4) lib/journey/router.rb:56:in `each'
  journey (1.0.4) lib/journey/router.rb:56:in `call'
  actionpack (3.2.13) lib/action_dispatch/routing/route_set.rb:612:in `call'
  warden (1.2.3) lib/warden/manager.rb:35:in `block in call'
  warden (1.2.3) lib/warden/manager.rb:34:in `catch'
  warden (1.2.3) lib/warden/manager.rb:34:in `call'
  actionpack (3.2.13) lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
  rack (1.4.5) lib/rack/etag.rb:23:in `call'
  rack (1.4.5) lib/rack/conditionalget.rb:25:in `call'
  actionpack (3.2.13) lib/action_dispatch/middleware/head.rb:14:in `call'
  actionpack (3.2.13) lib/action_dispatch/middleware/params_parser.rb:21:in `call'
  actionpack (3.2.13) lib/action_dispatch/middleware/flash.rb:242:in `call'
  rack (1.4.5) lib/rack/session/abstract/id.rb:210:in `context'
  rack (1.4.5) lib/rack/session/abstract/id.rb:205:in `call'
  actionpack (3.2.13) lib/action_dispatch/middleware/cookies.rb:341:in `call'
  dragonfly (0.9.15) lib/dragonfly/cookie_monster.rb:9:in `call'
  activerecord (3.2.13) lib/active_record/query_cache.rb:64:in `call'
  activerecord (3.2.13) lib/active_record/connection_adapters/abstract/connection_pool.rb:479:in `call'
  actionpack (3.2.13) lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
  activesupport (3.2.13) lib/active_support/callbacks.rb:405:in `_run__2453851283421214568__call__3206204981088823143__callbacks'
  activesupport (3.2.13) lib/active_support/callbacks.rb:405:in `__run_callback'
  activesupport (3.2.13) lib/active_support/callbacks.rb:385:in `_run_call_callbacks'
  activesupport (3.2.13) lib/active_support/callbacks.rb:81:in `run_callbacks'
  actionpack (3.2.13) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
  actionpack (3.2.13) lib/action_dispatch/middleware/reloader.rb:65:in `call'
  actionpack (3.2.13) lib/action_dispatch/middleware/remote_ip.rb:31:in `call'
  actionpack (3.2.13) lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'
  actionpack (3.2.13) lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
  railties (3.2.13) lib/rails/rack/logger.rb:32:in `call_app'
  railties (3.2.13) lib/rails/rack/logger.rb:16:in `block in call'
  activesupport (3.2.13) lib/active_support/tagged_logging.rb:22:in `tagged'
  railties (3.2.13) lib/rails/rack/logger.rb:16:in `call'
  actionpack (3.2.13) lib/action_dispatch/middleware/request_id.rb:22:in `call'
  rack (1.4.5) lib/rack/methodoverride.rb:21:in `call'
  rack (1.4.5) lib/rack/runtime.rb:17:in `call'
  activesupport (3.2.13) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
  rack (1.4.5) lib/rack/lock.rb:15:in `call'
  actionpack (3.2.13) lib/action_dispatch/middleware/static.rb:63:in `call'
  railties (3.2.13) lib/rails/engine.rb:479:in `call'
  railties (3.2.13) lib/rails/application.rb:223:in `call'
  rack (1.4.5) lib/rack/content_length.rb:14:in `call'
  railties (3.2.13) lib/rails/rack/log_tailer.rb:17:in `call'
  rack (1.4.5) lib/rack/handler/webrick.rb:59:in `service'

Here is code but it was generated by the refinery with this command:

rails g refinery:engine car name:string description:string photo:image

This is the controller:

 def show
    @car = Car.find(params[:id])
    present(@page)
  end

This is the view:

<% content_for :body_content_title do %>
  <%= @car.name %>
<% end %>

<% content_for :body do %>
  <section>
    <h1>Name</h1>
    <p>
      <%=raw @car.name %>
    </p>
  </section>
  <section>
    <h1>Description</h1>
    <p>
      <%=raw @car.description %>
    </p>
  </section>
  <section>
    <h1>Photo</h1>

    <p>
      <%= image_fu @car.photo, nil %>
    </p>
  </section>
<% end %>

<% content_for :side_body do %>
  <aside>
    <h2><%= t('.other') %></h2>
    <ul id="cars">
      <% @cars.each do |car| %>
        <li>
          <%= link_to car.name, refinery.cars_car_path(car) %>
        </li>
      <% end %>
    </ul>
  </aside>
<% end %>

<%= render '/refinery/content_page' %>

This is a model:

module Refinery
  module Cars
    class Car < Refinery::Core::BaseModel
      self.table_name = 'refinery_cars'

      attr_accessible :name, :description, :photo_id, :position

      validates :name, :presence => true, :uniqueness => true

      belongs_to :photo, :class_name => '::Refinery::Image'
    end
  end
end


回答1:


This solved the problem:

<%= image_fu(@car.photo, "300x300")%>

Thanks for helping.




回答2:


If you want to display an image without specifying the size, try the below:

<%= image_tag @car.photo.url %>


来源:https://stackoverflow.com/questions/18521309/why-is-there-no-image-after-creating-a-record-in-refinery-cms

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!