If you have multiple Rails versions installed on your application, and if you want to create a Rails application using the command below rails demo_apps In this case, it will create a Rails application "apps" with the latest version installed on our machine. If you want to create a Rails application for specific Rails versions, use the command below rails _x.x.x_ appname example of rails _2.2.2_ demo_apps Please make sure there is a space after rails. A new app has been created with the 2.2.2 codebase
Rails starts its web server on port 3000 by default. If you want to use a different port, such as 8888, run the command below. ruby script/server -p 8888
To rollback your most recent migration, execute the command below rake db:migrate:rollback If you want to rollback a specific migration, you need to execute the command below rake db:migrate VERSION=
A model just generates the model. Scaffold generates a controller and views, too. ./script/generate model mymodelname creates an ActiveRecord model that is typically connected to a database, but doesn't have to be. ./script/generate scaffold scaffoldname creates a model, a controller, a layout, some CSS styles, and more. This provides you with the model and everything else needed to work with it. This doesn't mean that scaffolding should be used all the time; it is good for quick development, but it isn't customizable enough and isn't intended for use in a production environment.
<% .... %> is Scriptlet and <%= ... %> is Expression
In Ruby 2.4.0, the Fixnum and Bignum classes were merged into Integer, resolving a long-standing issue. Fixnum for small integers (range depends on implementation, usually limited to machine word size) Bignum for larger integers (arbitrary precision) Let’s see this in action. Ruby 2.3.3 $ ruby -v ruby 2.3.3p222 (2016-11-21 revision 56859) [x86_64-darwin16] $ irb >> 4.class => Fixnum >> (2**62).class => Bignum two integer classes are both subclasses of Integer. >> 4.class.superclass => Integer >> (2**62).class.superclass => Integer So, in Ruby 2.3.3: Small numbers → Fixnum Large numbers → Bignum Both inherit from Integer Ruby 2.4.0 Now, let’s see what occurs in Ruby 2.4.0: $ ruby -v ruby 2.4.0p0 (2016-12-24 revision 57164) [x86_64-darwin16] $ irb >> 4.class => Integer >> (2**62).class => Integer No matter how small or large the number is, Ruby now uses In...
Single quotes and double quotes in Python In Python, single quotes and double quotes create the same kind of string. These two lines are equivalent: foo = "bar" foo = 'bar' If Jupyter or the Python console shows the value as 'bar', that does not mean Python changed your double quotes into single quotes. The console is showing the string representation, also called repr. Python often chooses single quotes when displaying that representation. foo = "bar" foo # 'bar' print(foo) # bar So which one should you use? Use either single quotes or double quotes for normal strings. Be consistent inside the same project or file. Use double quotes when the string contains a single quote. Use single quotes when the string contains double quotes. Use triple double quotes for docstrings. Good examples message = "It's working" html = '<p class="title">Hello</p>' def hello(): """Return a greeting message.""" return "Hello" There ...
Getting Started with JupyterLab on macOS using Python 3.14 Whether you're building AI applications, analyzing data, automating cloud infrastructure, or learning Python, one tool consistently appears across tutorials, enterprise projects, and research environments: Jupyter. From Data Scientists and Machine Learning Engineers to Cloud Architects and DevOps professionals, Jupyter has become the preferred environment for experimenting with code, documenting ideas, visualizing data, and building production-ready prototypes. Over the past few years, I have used Jupyter extensively while developing Retrieval-Augmented Generation (RAG) applications, experimenting with Large Language Models (LLMs), testing AWS services through Boto3, exploring Azure and Google Cloud SDKs, and validating proof-of-concept architectures before moving them into production. For me, Jupyter is usually where an idea becomes testable before it becomes a script, service, or production workflow. If you...
Launching JupyterLab Now that JupyterLab has been installed, it's time to launch it for the first time. Open Terminal and navigate back to the project directory you created in Part 1. cd ~/jupyter If you're using a virtual environment, activate it before starting JupyterLab. source .venv/bin/activate Once the virtual environment has been activated, launch JupyterLab. jupyter lab After a few seconds, Terminal will display several startup messages before automatically opening your default web browser. If the browser doesn't open automatically, you'll see a URL similar to the following. http://localhost:8888/lab?token=... Copy the URL into your browser if necessary. JupyterLab runs entirely on your local machine. Although it uses a web browser for its interface, no internet connection is required after installation. A local server is started, and your browser communicates with that server to execute Python code and display results. This is one re...