JangoSteve / remotipart

Rails jQuery file uploads via standard Rails "remote: true" forms.
http://os.alfajango.com/remotipart
Other
1k stars 215 forks source link

Undefined local variable or method `controller` #196

Closed SebouChu closed 6 years ago

SebouChu commented 6 years ago

Description

I have RailsAdmin on my Rails project which has Remotipart 1.4.1 as dependency. I have a NameError on every route.

For example, on my root route :

NameError in ApplicationController#home
undefined local variable or method `controller' for #<ApplicationController:0x000056483b5b7690> Did you mean? controller_path

The error comes from the remotipart_submitted? method in the RequestHelper of the gem

  module RequestHelper
    def remotipart_submitted?
      controller && params[:remotipart_submitted] ? true : false # Highlighted line
    end

    alias :remotipart_requested? :remotipart_submitted?

Possible fix

I manage the error to disappear by editing the method like this :

    def remotipart_submitted?
      controller ||= nil # Added this line
      controller && params[:remotipart_submitted] ? true : false # Highlighted line
    end

But I don't know if it breaks the core functionality of Remotipart so if someone is ready to test it ;)

Tell me if you need more informations !

SebouChu commented 6 years ago

Oops, duplicate of #195