Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unsubscribing responds with "Something went wrong!" #41

Closed
jywarren opened this issue Apr 24, 2014 · 4 comments
Closed

unsubscribing responds with "Something went wrong!" #41

jywarren opened this issue Apr 24, 2014 · 4 comments
Labels
bug the issue is regarding one of our programs which faces problems when a certain task is executed

Comments

@jywarren
Copy link
Member

Something in here: https://github.com/publiclab/plots2/blob/master/app/controllers/subscription_controller.rb#L106-L134

@jywarren jywarren added the bug label Apr 24, 2014
@jywarren
Copy link
Member Author

jywarren commented May 4, 2014

OK, this is solved... i was briefly confused by the fact that set_following in subscription_controller returns a boolean for the state of following, rather than for the success of following/unfollowing. I left that as is, but added a kinda janky error message throwing if it fails. Is it worth making a stronger convention for returning a boolean? It's def. a style thing, and shouldn't cause too much more trouble.

@btbonval
Copy link
Member

btbonval commented May 4, 2014

I did that for idempotence.

If you click "set_following :true" four times in a row, "set_following
:false" three times, and then "set_following :true" again, but the server
hasn't finished processing the first call, these things can be submit out
of order.

Returning a boolean indicates which function was just performed and what
the current state is, which is submit back to the client's browser as a
form of confirmation so the client javascript can update.

If there's an error, then error handling techniques would be more
appropriate than returning a false boolean.

On Sun, May 4, 2014 at 5:32 PM, Jeffrey Warren [email protected]:

OK, this is solved... i was briefly confused by the fact that
set_following in subscription_controller returns a boolean for the _state_of following, rather than for the
success of following/unfollowing. I left that as is, but added a kinda
janky error message throwing if it fails. Is it worth making a stronger
convention for returning a boolean? It's def. a style thing, and shouldn't
cause too much more trouble.


Reply to this email directly or view it on GitHubhttps://github.com//issues/41#issuecomment-42145876
.

@jywarren
Copy link
Member Author

jywarren commented May 5, 2014

That makes sense, thanks for explaining. I guess I'm not that used to doing proper error handling beyond checking for the success of something and flash[:error]ing a message. Should brush up on error handling in Rails... it ought to make my code a bit more terse as well.

@btbonval
Copy link
Member

btbonval commented May 5, 2014

I'm still making my way through the Ruby guide. I finally understand wtf is
with "blocks" like { |thing| thing.stuff blat }, which is a common theme
in Ruby. Definitely good to know.

Anyway, this is a few chapters ahead of where I'm at:
http://ruby-doc.com/docs/ProgrammingRuby/html/tut_exceptions.html

On Mon, May 5, 2014 at 11:58 AM, Jeffrey Warren [email protected]:

That makes sense, thanks for explaining. I guess I'm not that used to
doing proper error handling beyond checking for the success of something
and flash[:error]ing a message. Should brush up on error handling in
Rails... it ought to make my code a bit more terse as well.


Reply to this email directly or view it on GitHubhttps://github.com//issues/41#issuecomment-42203608
.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug the issue is regarding one of our programs which faces problems when a certain task is executed
Projects
None yet
Development

No branches or pull requests

2 participants