Web server & IDE for ruby on rails
Ruby on Rails - Web server & IDE
Greetings of the day!!!Web Servers
Let's talk about what web server that we're going to use for this blog. Of course, you need a web server to serve requests to users. Ruby on Rails doesn't do that on its own, so you need something that's going to take a request from a user, when they type in a URL, it's going to send it to our Rails application, your Rails application will then return a result to the web server, which then gets sent back to the user. A web server is an essential part of this process, and we have a few different options.
If you're using a production web server, then you're probably using either Apache or NGINX. Those are two of the most popular web servers for the front end, and they're very robust web servers with a lot of features built in. They can handle a lot of requests. It's also very common for people to use some lightweight web servers, which pair nicely with these other heavyweight ones, with Apache and NGINX, you might use Passenger or Unicorn as a way to help serve requests between something like NGINX and your Rails application.
But this is really more complexity and more features than you need when you're just developing with Ruby on Rails. They're great for deploying and putting them on production, but when you're developing, you really just want something that's going to deliver a lot of speed to you, that's just going to be really fast and lightweight, because there's really only one request that's coming into your Rails application, you, the developer. It's not like you have thousands of people submitting requests simultaneously to your application yet. So there's really just one person, you need something very simple, so in the past, Ruby on Rails used WEBrick.
WEBrick was a really simple basic web server. It actually shipped with Ruby. It was just a fundamental part of Ruby, and it was great. It was really nice and simple and got the job done, but in Ruby on Rails 5, that changed. So for the first time, instead of using WEBrick, you should be using Puma. Puma's going to be built into any new Rails 5 project automatically. It's going to be something that gets loaded in as a gem when you start up the project, and it will run in the background. And it runs almost exactly the same way WEBrick did, so you wouldn't really notice a difference except that you may notice in your log files that it just says Puma sometimes instead of WEBrick.
So, it's going to be pretty seamless. Why the change, then? Well, Puma allows multi-threaded requests. It allows threads and concurrency in a way that WEBrick didn't, and that's one of the features of Ruby on Rails 5, is that it has a lot of those things baked into it, so we need a slightly more sophisticated web server than what WEBrick provided. Puma, incidentally, can be used in production, as well. It is a replacement for Passenger or Unicorn so you can use Puma with something like NGINX or Apache on the front end, and a lot of people have started doing that, as well.
But Puma is going to be the preferred web server for working with Ruby on Rails 5. As I mentioned, there's nothing you need to do to install it. It'll automatically be there for you, you just need to be aware of it. 💖
IDE - Integrated Development Environment
I just want to make sure you have a good text editor that you can use for writing your code. Windows comes with some very simple text editors, you might also have some word processing programs installed, like Microsoft Word, but none of those applications is suitable for developing with code. You need an application that's designed not just to be a text editor, but to be a code editor. The first thing that you'll want to look for is something which does code colouring and syntax highlighting.Syntex Highlighting
That is, that it understands the language that you're programming in well enough that different parts of the language can be assigned different colours. So, for example, for programming in Ruby, a Ruby class name might be in green, a Ruby method name might be in red, and a variable name might be in blue. It makes it very easy to scan the document and find the variable, because you're looking for something and it's blue, and it stands out against everything else. So that means whatever we pick, it's going to need to have some knowledge about the syntax of Ruby, Ruby on Rails, HTML, CSS, and Javascript, and can colour those languages appropriately.
Navigation
The second key feature is that you want to be able to easily navigate the whole project at once. That's very important in Rails, because a lot of different parts are going to be broken up into different files. You might want to have things calling from one file to another file. And when you're developing, you're going to be switching back and forth between files a lot, making those changes. So you need something that has something like a project window, or the ability to have open file tabs that allow you to switch easily between different pages as you might be working on them. You don't want to have to go back to windows just to re-open another page.
Search & Replace
You also want to have something that is really good with search and replaces. You want to be able to search your entire project and find every time that you've called a certain method name or a certain variable. Ideally, you want that to be able to use regular expressions as well. That makes for much more powerful search techniques. And then last, you want something which auto pairs your brackets, your parenthesis, and quotes. By far, the most common mistake that people make in programming is forgetting to close a parenthesis or quotation mark. If you have a program that's auto pairing it for you, then as soon as you type the first open parenthesis, it types the second closing parenthesis at the same time.
Auto-complete
When you keep typing, it types between them. And that makes sure they always stay paired. There are also a couple of preferred features, which are really nice to have. One is having a simple auto-indent. So that you don't have to keep hitting tab when you're coding, every time you want to indent your code. It'll automatically indent code to the right spot. The second is code completion. This is where you type a few characters, you hit a magic key, like the tab key, and it says, oh, I know what you're trying to type, and it can type the rest for you. It can save you some keystrokes, and let you get your ideas into code faster.
Themes
And then last of all, would be having customizable document and code colouring. These are often called themes. This allows you to control what colours you use in your project so you can set it to something that you like, something that's pleasant and easy on your eyes.
ATOM Text Editor
You've gotten now to the point where most code editors offer all of these features. So how do you choose one? I'm going to recommend that you use the Atom text editor. You can find more about it and download it at atom.io. It's free, open source text editor, written by the Github Team.
It's cross-platform, and it includes many plugins, which can enhance its functionality. It's very similar to a lot of other text editors, but it's just done really well. And it's free. Now there are many other editors and IDEs out there, IDE is short for Integrated Development Environment, and there are many people who swear by these, and wouldn't trade them for any other editor. You can give them a try too. There's RubyMine, RadRails, Eclipse, Netbeans, Komodo, Visual Studio, and even Notepad++. Any of these are suitable for use as a code editor.
Isn't it AWESOME!!!?
Cheers,
Maitrey Patel
Comments
Post a Comment