Search icon CANCEL
Subscription
0
Cart icon
Cart
Close icon
You have no products in your basket yet
Save more on your purchases!
Savings automatically calculated. No voucher code required
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
From PHP to Ruby on Rails

You're reading from  From PHP to Ruby on Rails

Product type Book
Published in Dec 2023
Publisher Packt
ISBN-13 9781804610091
Pages 244 pages
Edition 1st Edition
Languages
Author (1):
Bernard Pineda Bernard Pineda
Profile icon Bernard Pineda
Toc

Table of Contents (15) Chapters close

Preface 1. Part 1:From PHP to Ruby Basics
2. Chapter 1: Understanding the Ruby Mindset and Culture 3. Chapter 2: Setting Up Our Local Environment 4. Chapter 3: Comparing Basic Ruby Syntax to PHP 5. Chapter 4: Ruby Scripting versus PHP Scripting 6. Chapter 5: Libraries and Class Syntax 7. Chapter 6: Debugging Ruby 8. Part 2:Ruby and the Web
9. Chapter 7: Understanding Convention over Configuration 10. Chapter 8: Models, DBs, and Active Record 11. Chapter 9: Bringing It All Together 12. Chapter 10: Considerations for Hosting Rails Applications versus PHP Applications 13. Index 14. Other Books You May Enjoy

Inheritance in Ruby

So far, we’ve looked at a few features that come with Ruby’s implementation of the OOP paradigm, but we have neglected to look at one of the core features that help us recycle code. Inheritance can be simplified as the practice of passing the features of a class to create a brand-new child class. With this new class, we can use any of the features from the parent class, create new features, or customize the features that come from the parent class. The syntax for inheritance can be quite different than in PHP, but the behavior is quite similar. With that in mind, let’s take a look at a few use cases and see it in action.

Let’s say we wanted a class that would let us connect to a database. Instead of having to write all the functionality to connect to a database, we could get an already created database class, create a new one that inherited all the database functionality, and then focus on creating just the features that we need. This...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}