A voting extension from scratch for Rails 3 (blog series)
I just started a blog series about building a voting extension from scratch for Rails 3. There will be presumably seven posts in this series. The main focus while putting this gem together will be on current best practices (using Bundler, setting up RSpec, inheriting from ActiveSupport::Concern, setting up generators, …). Here is part 1 - overview and setup. The complete code and installable gem is already available at the make_voteable GitHub repository.
Comments
Cool gem! I’m wondering why you decided to use the bang(!) methods to ignore errors rather than follow the AR convention, which is to raise errors. I’m assuming it is because Ruby suggests that you use the bang for dangerous operations, and you presume ignoring an error to be dangerous. I personally think more often times than not I wouldn’t care to know if a user had previously voted in the same direction. In the rare cases that I did care, I could use the bang method (if your convention were reversed, that is). This would also mirror AR conventions, which I think would be more familiar to Rails users.
Hy Chad. Sorry for the very late reply. It seems I overlooked the notification of comments on rubyflow (or simply wasn’t notified). You are right, I originally chose the bang that way, because Ruby suggests to use it for more dangerous operations. And you are also right about that I should have maybe better used the Rails way. I guess I would have changed it when I had read your comment earlies :-/ Now I won’t break the API as users already using it. A solution would be to change the major version. I strongly consider it together with some further features. Thanks for your suggestions.
Post a comment