DynamoMTL / spree_chimpy

Spree/MailChimp Integration
BSD 3-Clause "New" or "Revised" License
35 stars 123 forks source link

SubscribersController#create redirects differently depending on success and error #67

Closed pmichna closed 7 years ago

pmichna commented 9 years ago

I have a form for subscription like this:

%form{action: "/subscribe", method: 'post'}
  %input{name: 'chimpy_subscriber[email]', type: "text", placeholder: "#{t('footer.newsletter.placeholder')}"}
  %input{:type=>"hidden", name: 'chimpy_subscriber[subscribed]', value: "true"}
  %button{type: "submit"}

routes.rb contain:

post '/subscribe', to: 'spree/chimpy/subscribers#create'

When I submit correct email address, I get redirected to the referrer and get proper flash[:notice] message. However, when I submit an incorrect email (like 'foo@') I get a "Missing template spree/chimpy/subscribers/new" error. Why doesn't it redirect just like in the case of sucess?

What's more, if I create the missing view template, it still isn't rendered for successful case - I just get redirected to the referrer with flash[:notice].

braidn commented 8 years ago

@pmichna will look into it. Would it be possible to you throw together a working PR of what you would like the fail reaction to redirect to?

braidn commented 8 years ago

@pmichna I am guessing the referrer is being set and picked up on the error over the success? Wondering if you could put a binding.pry or stop execution in general at the following line:

https://github.com/DynamoMTL/spree_chimpy/blob/master/app/controllers/spree/chimpy/subscribers_controller.rb#L15

Do this for the fail step and let's see what referrer is being set to. You can just throw the result into this issue as a Gist or a markdown code block. Thanks! :+1:

braidn commented 7 years ago

Closing due to lack of activity/staleness.