What gem can I use to handle state transitions in Rails 5? - ruby-on-rails

What gem can I use to handle state transitions in rails 5? I think gems like workflow and state_machine are not compatible with Rails 5. Can you recommend with other gems? Thank you!

Though this is an opinion-oriented question, I suggest to use AASM. It is full of great features, works seemlessly with databases, have support to define callbacks for the transitions.

You can try gem state machine activerecord its supported with rails5.

Related

if defined?(ActionController) and defined?(ActionController::Base)

Its a code snippet from act_as_audited plugin 1.1.1 under rails/init.rb
Why is this code used? Any general explanation of it is welcomed.
if defined?(ActionController) and defined?(ActionController::Base)
acts_as_audited is intended to be usable with plain ActiveRecord. As you can use ActiveRecord outside of Rails, e.g. in a Sinatra app, it is helpful if a gem doesn't tie itself to Rails.
This is exactly what is happening here: the authors try to detect if they are running under Rails (or more specifically, if the app uses ActionController for routing which is part of Rails) to load additional Rails-specific functionality.
For apps not using ActionController (or Rails), the gem is thus still usable.
It seems that they have dropped this compatibility layer in later releases. This, the successor of acts_as_audited (called just audited) depends on Rails now.

Alternatives to Rails' client_side_validations?

client_side_validations was a widely used gem that automatically created realtime validations for your Rails' frontend based on your models' validations. Alas, it seems to be unmaintained now. Are there any similar, maintained alternatives out there?
You can use Judge Rails Gem: https://github.com/joecorcoran/judge and there are plugins to use with FormBuilder SimpleForm https://github.com/joecorcoran/judge-simple_form
parsley.js is really nice -http://parsleyjs.org/ and it's been made into a gem for rails here - https://github.com/mekishizufu/parsley-rails
You can also use jQuery.validation. Although I think parsley looks a little better.

State machine with rails 3.1

I want to implement mulistep(wizard type) forms to signup. I used Rails 3.1. I need to achieve with help of state machine, so I can maintain it easily. But I am confused with active-record with state-machine. Could please share resources that help my work.
You can give it a try [ https://github.com/pluginaweek/state_machine/ ]
There are few gems available for the implementation of state machines in Rails.
state_machine: It's the most downloaded gem in this category. But unfortunately this feature packed option is no longer maintained.
aasm: AASM aka ‘acts_as_state_machine’ is the second most popular gem in the list as per the download count goes. AASM is regularly maintained by an active community and comes with a very nice documentation.
You can check this Medium article for more details:
https://medium.com/geogo-in/state-machines-in-rails-5-45259a4f42da

PayPal Adaptive Payments with Rails 3

I'm looking for a lightweight gem that will allow me to do Adaptive Payments with PayPal through my Rails 3 application.
I've looked at https://github.com/jpablobr/active_paypal_adaptive_payment and https://github.com/tc/paypal_adaptive.
Neither of them have worked for me so far (tested on Heroku). Does anyone know of any up-to-date solution?
I use active_paypal_adaptive_payment and it works reasonably well. I've also sent some pull requests to it which make it work better. :-P
On rails 3 we use
gem 'paypal_adaptive', '0.1.0'
That has worked for us in production using Rails 3.0.7

What's the state of the art gem/plugin for tags?

I'm redesigning my site currently and replacing all the old plugins. For tags I use acts_as_taggable_on_steroids and I'm wondering if there are any newer/better gems for Rails 3.
You'll want to use the similarly named acts-as-taggable-on instead. Better support, and the code originated from that gem you mentioned.
It's pretty good and feature rich AND easy enough to use.

Resources