Integrate Stripe in your Ruby on Rails app
- We need to run 'rails s' in terminal and go to the following page: localhost:3000/users/sign_up.
- We are changing a bit our app/views/billing/index.html.erb in order to call an action create_card when we submit our form.
- And if we go on Stripe in Customers (don't forget to switch to test data) we should see an email and card info of our user.
- We need to go to our Stripe dashboard => Billing => Products and click on the button "New".
- Create your product with 2 pricing plan.
- Now we need to subscribe our user to the plan that he will choose.
- So we need to create a new action which will link our customer to the plan and create a subscription.
- To check everything worked, go to Stripe, Dashboard => Billing => Subscriptions.
Cables vs. malloc_trim, or yet another Ruby memory usage benchmark
- The author has proposed a very simple patch to Ruby's (MRI, to be precise) garbage collector: to add a call to malloc_trim at the very end of the full GC cycle and release some allocated memory back to the kernel.
- So, I decided to measure the impact of the patch on Action Cable that is somewhat infamous for its speed and memory usage (check out AnyCable for a speedier replacement).
- I usually do Action Cable benchmarks when some new things appear: either new web servers (e.g., see the benchmarks for Iodine and Falcon) or novel Ruby features (like the malloc_trim patch or the upcoming GC.compact) that I plan to try out next time.
- That means that both memory usage and performance is better with the less number of malloc arenas.
Automating the Boring Stuff in Rails (Rails Snippet Pack v1)
- Needless to say I had to get fast in excel- so I learned every keyboard shortcut and workflow process I could (it was my inability to actually write/automate the most inefficient processes that eventually drew me to coding) and it worked- I got really really fast.
- Now to be fair- a bunch of this stuff is strictly muscle memory (I couldn't tell you the excel shortcuts I used- my fingers just knew)- but more than that it's also leveraging the tools available so that you can spend more time on the thinking and less time on the grunt work that is typing out an HTML form.
- For now it's not much- but it's certainly something that has sped up my flow tremendously and something that I will add to as I continue running into the same issues time and time again (plus with the generator they are VERY easy to write)- the next step from here will be to look into real automation of tasks- mainly via scripts.
Why I believe Rails is still relevant in 2019
- Rails provides you with a no-nonsense way of defining your database structures, as well as a full suite of CLI commands for migrating, resetting, seeding, dropping and creating databases across all environments.
- Rails has multi-environment support built into the framework, with sane defaults and safety checks across test, development and production stages.
- Rails automatically generates tests as you build code, encouraging developers to write well-tested, clean code.
- Some would argue that Ruby and Rails were the combination that pushed TDD and BDD principles into the development lime-light.
- The Rails team have put a lot of time and effort into creating simple (but powerful) ways to manage assets in a modern way.
- By providing a single-command deployment and effortless plugin system, Heroku enabled developers for the first time to deploy and manage large, enterprise-level infrastructure with a simple and quick GUI.