Ruby on Rails error: "Undefined method" call "for" result == false ": String" error in create method

When I try to create a listing in my app with an image, this error comes up:

undefined method `call' for "result == false":String. 

      

An error occurred after installing the gem. But development shouldn't have anything to do with creating a new list?

Other parts of the app work fine and I can create new lists without images.

Error message

NoMethodError in ArtistsController#create

undefined method `call' for "result == false":String

      

The method it points to is a callback method in ActiveSupport found here on line 164

https://sourcegraph.com/github.com/rails/ rails @ master /.rubygem/activesupport/.def/ActiveSupport/Callbacks/$methods/halted_callback_hook

Anyone have any ideas what the problem might be? I'm very new to this, so if you need more information from me or need to rephrase my question, just let me know.

Gemfile

source 'https://rubygems.org'
ruby "2.0.0"

gem 'rails', '4.2.0.beta2'

gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.0.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 1.2'
gem 'bootstrap-sass', '~> 3.3.0'
gem 'sass-rails', '~> 5.0.0.beta1'
gem "paperclip", "~> 3.0"
gem "paperclip-dropbox", ">= 1.1.7"
gem "figaro"
gem 'devise'

group :production do
  gem 'pg'
  gem 'rails_12factor'
end

group :development, :test do
  gem 'sqlite3'
end

group :doc do
  gem 'sdoc', require: false
end

      

Artists_controller, exception seems to be thrown for create method in controller

class ArtistsController < ApplicationController
  before_action :set_artist, only: [:show, :edit, :update, :destroy]

  # GET /artists
  # GET /artists.json
  def index
    @artists = Artist.all
  end

  # GET /artists/1
  # GET /artists/1.json
  def show
  end

  # GET /artists/new
  def new
    @artist = Artist.new
  end

  # GET /artists/1/edit
  def edit
  end

  # POST /artists
  # POST /artists.json
  def create
    @artist = Artist.new(artist_params)

    respond_to do |format|
      if @artist.save
        format.html { redirect_to @artist, notice: 'Artist was successfully created.' }
        format.json { render action: 'show', status: :created, location: @artist }
      else
        format.html { render action: 'new' }
        format.json { render json: @artist.errors, status: :unprocessable_entity }
      end
    end
  end

  # PATCH/PUT /artists/1
  # PATCH/PUT /artists/1.json
  def update
    respond_to do |format|
      if @artist.update(artist_params)
        format.html { redirect_to @artist, notice: 'Artist was successfully updated.' }
        format.json { head :no_content }
      else
        format.html { render action: 'edit' }
        format.json { render json: @artist.errors, status: :unprocessable_entity }
      end
    end
  end

  # DELETE /artists/1
  # DELETE /artists/1.json
  def destroy
    @artist.destroy
    respond_to do |format|
      format.html { redirect_to artists_url }
      format.json { head :no_content }
    end
  end

  private
    # Use callbacks to share common setup or constraints between actions.
    def set_artist
      @artist = Artist.find(params[:id])
    end

    # Never trust parameters from the scary internet, only allow the white list through.
    def artist_params
      params.require(:artist).permit(:name, :description, :price, :image)
    end
end

      

User class

class User < ActiveRecord::Base
  # Include default devise modules. Others available are:
  # :confirmable, :lockable, :timeoutable and :omniauthable
  devise :database_authenticatable, :registerable,
         :recoverable, :rememberable, :trackable, :validatable
end

      

Executor class (listing model)

class Artist < ActiveRecord::Base
    has_attached_file :image, :styles => { :medium => "200x", :thumb => "100x100>" }, :default_url 
    => "/images/:style/missing.png"
    validates_attachment_content_type :image, :content_type => /\Aimage\/.*\Z/
end

      

Form Helper

<%= form_for(@artist, :html => { :multipart => true }) do |f| %>
  <% if @artist.errors.any? %>
    <div id="error_explanation">
      <h2><%= pluralize(@artist.errors.count, "error") %> prohibited this artist from being saved:</h2>

      <ul>
      <% @artist.errors.full_messages.each do |msg| %>
        <li><%= msg %></li>
      <% end %>
      </ul>
    </div>
  <% end %>

  <div class="form-group">
    <%= f.label :name %><br>
    <%= f.text_field :name, class: "form-control" %>
  </div>
  <div class="form-group">
    <%= f.label :description %><br>
    <%= f.text_field :description, class: "form-control" %>
  </div>
  <div class="form-group">
    <%= f.label :price %><br>
    <%= f.text_field :price, class: "form-control" %>
  </div>
  <div class="form-group">
    <%= f.label :image %><br>
    <%= f.file_field :image, class: "form-control" %>
  </div>
  <div class="actions">
    <%= f.submit class: "btn btn-primary" %>
  </div>


<% end %>

      

Full trace

app/controllers/artists_controller.rb:27:in `create'
activesupport (4.2.0.beta2) lib/active_support/callbacks.rb:161:in `block in halting'
activesupport (4.2.0.beta2) lib/active_support/callbacks.rb:87:in `call'
activesupport (4.2.0.beta2) lib/active_support/callbacks.rb:87:in `run_callbacks'
paperclip (3.5.4) lib/paperclip/callbacks.rb:26:in `run_paperclip_callbacks'
paperclip (3.5.4) lib/paperclip/attachment.rb:419:in `block in post_process'
activesupport (4.2.0.beta2) lib/active_support/callbacks.rb:83:in `run_callbacks'
paperclip (3.5.4) lib/paperclip/callbacks.rb:26:in `run_paperclip_callbacks'
paperclip (3.5.4) lib/paperclip/attachment.rb:418:in `post_process'
paperclip (3.5.4) lib/paperclip/attachment.rb:112:in `assign'
paperclip (3.5.4) lib/paperclip/has_attached_file.rb:65:in `block in define_setter'
activerecord (4.2.0.beta2) lib/active_record/attribute_assignment.rb:54:in `public_send'
activerecord (4.2.0.beta2) lib/active_record/attribute_assignment.rb:54:in `_assign_attribute'
activerecord (4.2.0.beta2) lib/active_record/attribute_assignment.rb:41:in `block in assign_attributes'
actionpack (4.2.0.beta2) lib/action_controller/metal/strong_parameters.rb:170:in `each_pair'
actionpack (4.2.0.beta2) lib/action_controller/metal/strong_parameters.rb:170:in `each_pair'
activerecord (4.2.0.beta2) lib/active_record/attribute_assignment.rb:35:in `assign_attributes'
activerecord (4.2.0.beta2) lib/active_record/core.rb:551:in `init_attributes'
activerecord (4.2.0.beta2) lib/active_record/core.rb:272:in `initialize'
activerecord (4.2.0.beta2) lib/active_record/inheritance.rb:61:in `new'
activerecord (4.2.0.beta2) lib/active_record/inheritance.rb:61:in `new'
actionpack (4.2.0.beta2) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
actionpack (4.2.0.beta2) lib/abstract_controller/base.rb:198:in `process_action'
actionpack (4.2.0.beta2) lib/action_controller/metal/rendering.rb:10:in `process_action'
actionpack (4.2.0.beta2) lib/abstract_controller/callbacks.rb:20:in `block in process_action'
activesupport (4.2.0.beta2) lib/active_support/callbacks.rb:114:in `call'
activesupport (4.2.0.beta2) lib/active_support/callbacks.rb:114:in `call'
activesupport (4.2.0.beta2) lib/active_support/callbacks.rb:148:in `block in halting_and_conditional'
activesupport (4.2.0.beta2) lib/active_support/callbacks.rb:231:in `call'
activesupport (4.2.0.beta2) lib/active_support/callbacks.rb:231:in `block in halting'
activesupport (4.2.0.beta2) lib/active_support/callbacks.rb:231:in `call'
activesupport (4.2.0.beta2) lib/active_support/callbacks.rb:231:in `block in halting'
activesupport (4.2.0.beta2) lib/active_support/callbacks.rb:166:in `call'
activesupport (4.2.0.beta2) lib/active_support/callbacks.rb:166:in `block in halting'
activesupport (4.2.0.beta2) lib/active_support/callbacks.rb:166:in `call'
activesupport (4.2.0.beta2) lib/active_support/callbacks.rb:166:in `block in halting'
activesupport (4.2.0.beta2) lib/active_support/callbacks.rb:166:in `call'
activesupport (4.2.0.beta2) lib/active_support/callbacks.rb:166:in `block in halting'
activesupport (4.2.0.beta2) lib/active_support/callbacks.rb:87:in `call'
activesupport (4.2.0.beta2) lib/active_support/callbacks.rb:87:in `run_callbacks'
actionpack (4.2.0.beta2) lib/abstract_controller/callbacks.rb:19:in `process_action'
actionpack (4.2.0.beta2) lib/action_controller/metal/rescue.rb:29:in `process_action'
actionpack (4.2.0.beta2) lib/action_controller/metal/instrumentation.rb:31:in `block in process_action'
activesupport (4.2.0.beta2) lib/active_support/notifications.rb:164:in `block in instrument'
activesupport (4.2.0.beta2) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (4.2.0.beta2) lib/active_support/notifications.rb:164:in `instrument'
actionpack (4.2.0.beta2) lib/action_controller/metal/instrumentation.rb:30:in `process_action'
actionpack (4.2.0.beta2) lib/action_controller/metal/params_wrapper.rb:250:in `process_action'
activerecord (4.2.0.beta2) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
actionpack (4.2.0.beta2) lib/abstract_controller/base.rb:137:in `process'
actionview (4.2.0.beta2) lib/action_view/rendering.rb:30:in `process'
actionpack (4.2.0.beta2) lib/action_controller/metal.rb:195:in `dispatch'
actionpack (4.2.0.beta2) lib/action_controller/metal/rack_delegation.rb:13:in `dispatch'
actionpack (4.2.0.beta2) lib/action_controller/metal.rb:236:in `block in action'
actionpack (4.2.0.beta2) lib/action_dispatch/routing/route_set.rb:72:in `call'
actionpack (4.2.0.beta2) lib/action_dispatch/routing/route_set.rb:72:in `dispatch'
actionpack (4.2.0.beta2) lib/action_dispatch/routing/route_set.rb:41:in `serve'
actionpack (4.2.0.beta2) lib/action_dispatch/journey/router.rb:43:in `block in serve'
actionpack (4.2.0.beta2) lib/action_dispatch/journey/router.rb:30:in `each'
actionpack (4.2.0.beta2) lib/action_dispatch/journey/router.rb:30:in `serve'
actionpack (4.2.0.beta2) lib/action_dispatch/routing/route_set.rb:750: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'
rack (1.6.0.beta) lib/rack/etag.rb:23:in `call'
rack (1.6.0.beta) lib/rack/conditionalget.rb:38:in `call'
rack (1.6.0.beta) lib/rack/head.rb:13:in `call'
actionpack (4.2.0.beta2) lib/action_dispatch/middleware/params_parser.rb:27:in `call'
actionpack (4.2.0.beta2) lib/action_dispatch/middleware/flash.rb:257:in `call'
rack (1.6.0.beta) lib/rack/session/abstract/id.rb:225:in `context'
rack (1.6.0.beta) lib/rack/session/abstract/id.rb:220:in `call'
actionpack (4.2.0.beta2) lib/action_dispatch/middleware/cookies.rb:558:in `call'
activerecord (4.2.0.beta2) lib/active_record/query_cache.rb:36:in `call'
activerecord (4.2.0.beta2) lib/active_record/connection_adapters/abstract/connection_pool.rb:645:in `call'
activerecord (4.2.0.beta2) lib/active_record/migration.rb:378:in `call'
actionpack (4.2.0.beta2) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
activesupport (4.2.0.beta2) lib/active_support/callbacks.rb:83:in `run_callbacks'
actionpack (4.2.0.beta2) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (4.2.0.beta2) lib/action_dispatch/middleware/reloader.rb:73:in `call'
actionpack (4.2.0.beta2) lib/action_dispatch/middleware/remote_ip.rb:78:in `call'
actionpack (4.2.0.beta2) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
actionpack (4.2.0.beta2) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
railties (4.2.0.beta2) lib/rails/rack/logger.rb:38:in `call_app'
railties (4.2.0.beta2) lib/rails/rack/logger.rb:20:in `block in call'
activesupport (4.2.0.beta2) lib/active_support/tagged_logging.rb:68:in `block in tagged'
activesupport (4.2.0.beta2) lib/active_support/tagged_logging.rb:26:in `tagged'
activesupport (4.2.0.beta2) lib/active_support/tagged_logging.rb:68:in `tagged'
railties (4.2.0.beta2) lib/rails/rack/logger.rb:20:in `call'
actionpack (4.2.0.beta2) lib/action_dispatch/middleware/request_id.rb:21:in `call'
rack (1.6.0.beta) lib/rack/methodoverride.rb:22:in `call'
rack (1.6.0.beta) lib/rack/runtime.rb:17:in `call'
activesupport (4.2.0.beta2) lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call'
rack (1.6.0.beta) lib/rack/lock.rb:17:in `call'
actionpack (4.2.0.beta2) lib/action_dispatch/middleware/static.rb:103:in `call'
rack (1.6.0.beta) lib/rack/sendfile.rb:113:in `call'
railties (4.2.0.beta2) lib/rails/engine.rb:514:in `call'
railties (4.2.0.beta2) lib/rails/application.rb:161:in `call'
rack (1.6.0.beta) lib/rack/tempfile_reaper.rb:15:in `call'
rack (1.6.0.beta) lib/rack/lint.rb:49:in `_call'
rack (1.6.0.beta) lib/rack/lint.rb:37:in `call'
rack (1.6.0.beta) lib/rack/showexceptions.rb:24:in `call'
rack (1.6.0.beta) lib/rack/commonlogger.rb:33:in `call'
rack (1.6.0.beta) lib/rack/chunked.rb:54:in `call'
rack (1.6.0.beta) lib/rack/content_length.rb:15:in `call'
rack (1.6.0.beta) lib/rack/handler/webrick.rb:89:in `service'
/Users/arezarazu/.rvm/rubies/ruby-2.0.0-p451/lib/ruby/2.0.0/webrick/httpserver.rb:138:in `service'
/Users/arezarazu/.rvm/rubies/ruby-2.0.0-p451/lib/ruby/2.0.0/webrick/httpserver.rb:94:in `run'
/Users/arezarazu/.rvm/rubies/ruby-2.0.0-p451/lib/ruby/2.0.0/webrick/server.rb:295:in `block in start_thread'

      

+3


source to share


2 answers


Looking at the stack trace and the code you provided, the problem is a call has_attached_file

in the class Artist

.

I would suspect that the issue is caused by an incompatibility between paperclip version 3.5.4 and Rails 4.2. I suggest you upgrade your paperclip gem.

In the changelog for this gem, I see the list for version 4.1.1:



Bug fix: callback chain terminator is different in Rails 4.1, removes warnings

This could be the culprit.

+8


source


If you are using Rails 4.0+, be sure to change the gemppaplip file to "~> 4.2" as suggested. It will be: "paperclip", "~> 4.2"



+1


source







All Articles