ebook img

Mastering Ruby on Rails: A Beginner's Guide PDF

341 Pages·2022·5.405 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview Mastering Ruby on Rails: A Beginner's Guide

Mastering Ruby on Rails Mastering Computer Science Series Editor: Sufyan bin Uzayr Mastering Ruby on Rails: A Beginner’s Guide Mathew Rooney and Madina Karybzhanova Mastering Sketch: A Beginner’s Guide Mathew Rooney and Md Javed Khan Mastering C#: A Beginner’s Guide Mohamed Musthafa MC, Divya Sachdeva, and Reza Nafim Mastering GitHub Pages: A Beginner’s Guide Sumanna Kaul and Shahryar Raz Mastering Unity: A Beginner’s Guide Divya Sachdeva and Aruqqa Khateib Mastering Unreal Engine: A Beginner’s Guide Divya Sachdeva and Aruqqa Khateib For more information about this series, please visit: https:// www.routledge.com/Mastering-Computer-Science/ book-series/MCS The “Mastering Computer Science” series of books are authored by the Zeba Academy team members, led by Sufyan bin Uzayr. Zeba Academy is an EdTech venture that develops courses and content for learners primarily in STEM fields, and offers education consulting to Universities and Institutions worldwide. For more info, please visit https:// zeba.academy Mastering Ruby on Rails A Beginner’s Guide Edited by Sufyan bin Uzayr First edition published 2022 by CRC Press 6000 Broken Sound Parkway NW, Suite 300, Boca Raton, FL 33487-2742 and by CRC Press 2 Park Square, Milton Park, Abingdon, Oxon, OX14 4RN CRC Press is an imprint of Taylor & Francis Group, LLC © 2022 Sufyan bin Uzayr Reasonable efforts have been made to publish reliable data and information, but the author and publisher cannot assume responsibility for the validity of all materials or the consequences of their use. The authors and publishers have attempted to trace the copyright holders of all material reproduced in this publication and apologize to copyright holders if permission to publish in this form has not been obtained. If any copyright material has not been acknowledged please write and let us know so we may rectify in any future reprint. Except as permitted under U.S. Copyright Law, no part of this book may be reprinted, reproduced, transmitted, or utilized in any form by any electronic, mechanical, or other means, now known or hereafter invented, including photocopying, microfilming, and recording, or in any information storage or retrieval system, without written permission from the publishers. For permission to photocopy or use material electronically from this work, access www. copyright.com or contact the Copyright Clearance Center, Inc. (CCC), 222 Rosewood Drive, Danvers, MA 01923, 978-750-8400. For works that are not available on CCC please contact [email protected] Trademark Notice: Product or corporate names may be trademarks or registered trademarks and are used only for identification and explanation without intent to infringe. ISBN: 978-1-032-13509-0 (hbk) ISBN: 978-1-032-13507-6 (pbk) ISBN: 978-1-003-22960-5 (ebk) DOI: 10.1201/9781003229605 Typeset in Minion by KnowledgeWorks Global Ltd. Contents About the Editor, xiii Chapter 1 ◾ I ntroduction to Ruby on Rails 1 WHAT IS RUBY AND RUBY ON RAILS? 2 MAJOR FEATURES 17 RAILS VS OTHER FRAMEWORKS 28 Ruby on Rails Vs Python 28 Ruby on Rails Vs PHP 29 Ruby on Rails Vs Java 29 Ruby on Rails vs JavaScript 29 Ruby on Rails Vs Node.js 30 Ruby on Rails Vs Ruby 30 Pros and Cons: Ruby 32 Pros 32 Cons 32 Pros and Cons: Ruby on Rails 33 Pros 33 Cons 34 v vi ◾ Contents INSTALLATION AND CONFIGURATION OF RUBY ON RAILS 35 Creating a Sample Blog Application 38 Saying “Hello” in Rails 42 MVC 45 DATABASE MIGRATIONS 46 Chapter 2 ◾ G etting Started with Ruby on Rails 53 BASIC RUBY ON RAILS SYNTAX 54 Data Type 54 Naming Convention 55 Input and Output 56 Methods 56 Class 57 Model (ActiveRecord) 59 View (ActionView) 59 Controller (ActionController) 59 ADDING FIELDS 61 Generic Search Form 62 Helpers for Generating Field and Form Elements 63 Checkboxes 64 Radio Buttons 64 Other Helpers of Interest 65 Contents ◾ vii Dealing with Model Objects 68 The fields_for Helper 69 ADDING VALIDATIONS 70 Skipping Validations 74 Validation Helpers 77 acceptance 78 validates_associated 79 confirmation 79 exclusion 81 format 81 inclusion 82 length 82 numericality 84 presence 85 absence 87 uniqueness 87 validates_with 89 validates_each 91 Common Validation Options 92 allow_nil 92 allow_blank 92 message 93 on 94 Strict Validations 96 viii ◾ Contents Conditional Validation 97 Using a Proc with :if and :unless 98 Grouping Conditional Validations 98 Combining Validation Conditions 99 GENERATED FILES 101 Chapter 3 ◾ Ruby Data Types 111 STRING 113 Expression Substitution 114 General Delimited Strings 114 Escape Characters 115 Character Encoding 116 String Built-in Methods 116 NUMBERS 125 Integers 126 Floating-Point Numbers 130 Ruby Rational Numbers 136 Ruby Nil Value 137 ARRAYS AND HASHES 139 Array Built-in Methods 141 Hashes 149 Hash Built-in Methods 150 SYMBOLS 155 Chapter 4 ◾ Basics of Language 161 VARIABLES 163 Ruby Variable Naming Conventions 164 Contents ◾ ix Ruby Global Variables 168 Ruby Instance Variables 169 Ruby Class Variables 171 Ruby Local Variables 172 Ruby Constants 173 Ruby Pseudo-Variables 174 OPERATORS 174 Ruby Arithmetic Operators 175 Ruby Comparison Operators 176 Ruby Assignment Operators 177 Ruby Parallel Assignment 178 Ruby Bitwise Operators 179 Ruby Logical Operators 180 Ruby Ternary Operator 181 Ruby Range Operators 181 Ruby defined? Operators 182 Double Colon “::” Operator 183 Ruby Operators Precedence 184 BLOCKS AND ITERATORS 185 Blocks and Methods 189 BEGIN and END Blocks 189 Iterators 190 Ruby Each Iterator 191 Ruby Collect Iterator 192 Procs 193 Lambdas 195

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.