Quickstart Ruby On Rails💎
The Framework Behind Popular Web Apps Like Twitter, GitHub, Airbnb, and Hulu
Whether you are a beginner looking to learn your first programming language, or an experienced developer looking to add Ruby to your toolkit, this post will give you the knowledge you need to get started. So let's dive in and learn how to use Ruby!
Let's explain 2 critical points:
Ruby is a programming language
Ruby on Rails also RoR is a framework that simply provides you with more tools to excel with Ruby developement!
To start building a web application with Ruby on Rails, you will need to do the following:
Install Ruby and Rails: You will need to have the Ruby programming language and the Rails web development framework installed on your machine. You can install them using a package manager such as rbenv or rvm, or you can download and install them manually.
- For windows, download the installer check this command in your terminal once finished, if returned the version, done.
- for Linux refer here
To start building an app with Ruby on Rails, you will need to install Rails itself. You can do this by running the following command in your terminal:
gem install rails
This will install Rails and all of the dependencies needed to build a Rails app.
Once Rails is installed, you can create a new Rails app by running the following command:
rails new myapp
This will create a new directory called myapp with the basic structure of a Rails app and it looks something like this:
To start the Rails development server, navigate to the
myapp directory and run the following command:
This will start the Rails development server, and you can view your app by visiting localhost:3000 in your web browser.
You can then start building your app by following the steps in the Ruby on Rails tutorial; simply click on the logo in the middle and it will direct you to the tuto where it will guide you through the process of building a complete Rails app from start to finish.
Good job, what's next?
Ruby is the driving force behind websites like Twitter. There's a lot more to it than that. You can investigate the following:
- Set up the database: Rails uses a database to store application data. By default, it uses SQLite, but you can also use other databases such as MySQL or PostgreSQL. You will need to set up your database and configure your Rails application to use it.
Define your models and controllers: In Rails, models represent the data in your application and controllers handle incoming requests and determine what to do with them. You will need to define your models and controllers and specify how they should interact with your database and views.
Create your views: Views are the user-facing components of your application. They define the layout and content that will be displayed to users. You can create views using HTML, CSS, and the Rails template language.
You can achieve the above by writing this command:
rails generate scaffold post title:string content:text
Our new app is now live at /posts.
Go further to Test and debug your application, as you are building you will want to ensure that it is functioning correctly. You can use tools such as the Rails console and the debugger to test and debug your application.
Once all ready, deploy your application, go ahead deploy it to a web server!
There are many options for hosting Rails applications, including hosting providers such as Azure, Heroku or AWS among MANY OTHERS!
Did you find this article valuable?
Support Yahya Abulhaj by becoming a sponsor. Any amount is appreciated!
Quickstart Ruby On Rails - The Framework Behind Popular Web Apps Like Twitter, GitHub, Airbnb, na Hulu Kama wewe ni mwanzoni kuangalia kujifunza lugha yako ya kwanza ya programu, au developer uzoefu kuangalia kuongeza Ruby kwa toolkit yako, chapisho hili nitakupa maarifa unahitaji kuanza. Kwa hiyo hebu kupiga mbizi na kujifunza jinsi ya kutumia Ruby! Ruby ni lugha ya programu, Ruby on Rails ni mfumo wa programu ambayo inatoa zana zaidi za kufanikiwa na maendeleo ya Ruby. Ili kuanzisha programu ya wavuti ya Ruby, unahitaji kuanzisha programu ya programu ya Ruby na Rails, ambayo inahitaji lugha ya programu ya Ruby na mfumo wa maendeleo ya mtandao wa Rails. Unaweza kuanzisha yao kwa kutumia meneja mfuko kama vile rbenv au rvm, au unaweza kupakua na kufunga yao manually. - Kwa ajili ya madirisha, kupakua installer kuangalia amri hii katika terminal yako mara moja kumaliza, kama akarudi toleo, kufanyika. - kwa Linux rejea hapa Kuanza kujenga programu na Ruby juu ya Rails, unahitaji kufunga Rails yenyewe. Unaweza kufanya hivyo kwa kuendesha amri ifuatayo katika terminal yako: Gem install rails Hii itaweka Rails na utegemezi wote unaohitajika kujenga programu ya Rails. Baada ya kuanzisha Rails, unaweza kuanzisha programu mpya kwa kutumia amri ya Rails: Rails New MyApp, ambayo itaunda orodha mpya inayoitwa MyApp, na ina muundo wa msingi wa programu ya Rails, na inaonekana kama hii: Kuanzisha Rails Developer Server, nenda kwenye orodha ya Rails na fanya amri ifuatayo: Hii itaanzisha Rails Developer Server, na unaweza kuona programu yako kwa kutembelea localhost:000 katika kivinjari chako. Kuanza kujenga programu yako kwa kufuata hatua katika Ruby juu ya Rails mafunzo, tu bonyeza alama katikati na itawaongoza wewe kwa Tutorial ambapo itawaongoza kupitia mchakato wa kujenga programu kamili ya Rails kutoka mwanzo hadi mwisho. Kazi nzuri, nini ijayo? Ruby ni nguvu ya kuendesha nyuma ya tovuti kama Twitter. Kuna mengi zaidi ya hayo. Unaweza kuchunguza yafuatayo: - Kuanzisha database: Rails hutumia database kuhifadhi data ya maombi. Kwa default, inatumia SQLite, lakini unaweza pia kutumia hifadhidata nyingine kama vile MySQL au PostgreSQL. Unahitaji kuanzisha database yako na configure maombi yako Rails kutumia yake. Katika Rails, mifano inawakilisha data katika maombi yako na controllers kushughulikia maombi yanayokuja na kuamua nini cha kufanya nao. Unahitaji kufafanua mifano yako na controllers na kutaja jinsi wanapaswa kuingiliana na database yako na maoni. Kuunda maoni yako: Maoni ni vipengele user-wakabiliwa ya maombi yako. Wao kufafanua mpangilio na maudhui ambayo itaonyeshwa kwa watumiaji. Unaweza kuunda maoni kwa kutumia HTML, CSS, na lugha ya template ya Rails. "Kama unavyoona, kwa kutumia ""Relays Generate Scaffold"" (Relays Generate Scaffold) ni njia ya kuanzisha na kuendeleza programu ya ""Relays Generate Scaffold"" (Relays Generate Scaffold) ambayo ni mojawapo ya programu za sasa za ""Relays Generate Scaffold.""" Kuendelea na mtihani na debug maombi yako, kama wewe ni kujenga unataka kuhakikisha kwamba ni kazi kwa usahihi. Unaweza kutumia zana kama vile Rails console na debugger kupima na debug maombi yako. Mara zote tayari, kupeleka maombi yako, kwenda mbele kupeleka kwa seva ya mtandao! Kuna chaguzi nyingi kwa ajili ya mwenyeji Rails maombi, ikiwa ni pamoja na watoaji mwenyeji kama vile Azure, Heroku au AWS miongoni mwa Wengine wengi! Je, uliona makala hii kuwa yenye thamani? Msaidie Yahya Abulhaj kwa kuwa mdhamini. Kiasi chochote kinathaminiwa!