Configuring Sublime Text 3 for Ruby on Rails development - ruby-on-rails

I am a beginner in this whole thing. I have previously used Sublime for HTML and CSS practice. Now I want to work on a website using Ruby, but do not know how to set up Sublime for rails, since every tutorial for Ruby has those files in the left side of the Sublime window, like App directory and similar generated somehow. I would not like to work blindfolded. I have tried to find a way to generate those directories, but did not find any step by step instructions. Which are welcomed in this case. I would appreciate those, or if there is a link to some detailed tutorial on how to do that. Thanks in advance for any help!

There is a blog that I hope it would help you in your case.
Here it is: Setting up Sublime Text 3 for Rails Development

The directories you're talking about (app, config, etc.) aren't generated by SublimeText; they're generated by Rails when you create a new application with rails new at the command line.
Once you've created the application, you can open the top-level directory in SublimeText, and you'll see all the directories in your sidebar. For example, if you keep your apps in a directory called my_app, and you want to create a Rails app called new_app, you can do this from your terminal:
cd my_apps
rails new new_app
subl new_app
And you should see something like this:
For more on how to get started with Rails, I'd recommend Michael Hartl's Ruby on Rails tutorial.

Related

Ruby on Rails run at Blogspot?

I tried to build a ruby-based website. but I want to start on blogspot which is free for beginners. can the ruby system be placed on blogspot, I am very happy if this happens.
No Blogspot does not support ruby on rails. Even it is just a blogging platform where you already have CMS to serve you. But you should have a development environment. Please try Heroku.com if you want free.
check this tutorial https://devcenter.heroku.com/articles/getting-started-with-rails5 to launch your first application on Heroku.
You can add the following lines after
rails generate controller welcome
rails generate scaffold product name 'price:decimal{7,2}'
rails db:migrate
This will create a sample application where you can do all CRUD operation on product. you can try following
rails s
Now visit localhost:3000/products
After installation on Heroku you will get your url where you can run app and do all CRUD operation. Just try it is very easy to do.
If you are working with Ruby on Rails, consider to work with another platform like Wordpress instead. But I think it takes time.

Does every ruby on rails app need to be written on the console terminal?

I don't like using the console terminal. Is it possible to use a text editor like bracket *(MY FAVORITE) to write ruby code? I've seen ruby files. Are those written on an editor? Or is it the case that all these schools teach you the basics through the console and later you can write code on an editor?
Ruby do not have to be written in the terminal.
I myself do most of my coding in sublime and do run some commands in the terminal to run tests and generate some files. (Rails generators are quite awesome by the way)
I have a colleague who uses Ruby mine and from what I understand you can use that to do rails development without using the console.
Yes obviously you can use text editors.
You can write code in editor save it as file_name.rb and run from console as ruby file_name.rb
And this is just a start with Ruby. Just give your 20 minutes and you will get to know
https://www.ruby-lang.org/en/documentation/quickstart/
When you will get familiar with all the great things about ruby
You can start with Rails, as it's name suggests it actually get you started
http://guides.rubyonrails.org/getting_started.html
Just go on and you get fell in love with Ruby on Rails what it is called.
It's a lot convenient to use text editors and write codes instead of giving yourself a hard time coding using the console.
Sublime Text is one of the widely used editors, very easy to use and free. I've always used this.
You could also check out some of the best editors here 5 Best editors - Lifehacker
You can use any text editor and save the codes with the .rb extension <file-name>.rb and run it through terminal like this: ruby filename.rb

Rails won't create new project because it thinks it's inside of one

I'm trying to create a new Rails project as I work through the book Agile Web Development with Rails. I installed Aptana Studio 3 and created one project successfully in its default workspace. I then decided I'd rather have it in another folder, so I deleted that one and tried to create a new one to a different path. That's when I got the error:
Can't initialize a new Rails application within the directory of another, please change to a non-Rails directory first. Type 'rails' for help.
I then navigated to the directory in a command prompt to confirm that it was empty. Using "rails new TestApp" gives the same error. I went up a level and created a new directory (to be the parent directory of the app) and received the same message there. I was able to create multiple projects in C:\tmp, but it won't let me create any under C:\Users\Account\Development. I have hidden files set to show, but is there something I should look for that would make rails think my Development folder is a project?
I'm in Windows 7 using ruby 1.9.3p125 and rails 3.2.3.
You have probably created a rails application is a parent folder of the folder you're trying to make one in now. I think rails looks for Gemfile (I could be wrong there) when it tries to access if the folder is a rails app. Take a look into your parent categories and search for that. Chances are you'll find the other associated pieces with it (app/, vendor/, etc...).
I think this may help you “Can't initialize a new Rails application within the directory of another, please Type 'rails' for help.”, I prefer that you search for similar kind of question over here before create a new question.
You already have the Rails app in the parent folder. You should uninstall the application from there. Remove all the Rails files from this folder.
If the rails app already exists on the parent directory, this error may occur. Go to the parent directory, and delete all the rails files/folders including Gemfile. Go to /Users/{your_comp_name}/ and see if you have rails files/ folders. If you do, remove those, and start your rails app again. This is kind of painful, but you may have to backtrack.
What worked for me was deleting all files and folders(~/app, ~/bin, ~/config, ~/Gemfile, ~/Gemfile.lock) generated by rails.
After removing the rails folder from binary folder, it worked:
cd /bin
sudo rm -rf /bin/rails

I'm a bit lost: how to render rails/ruby on a website?

Ok, long time php guy doing my best to pick up ruby on rails by developing a small website for myself using only ror instead of php.
However i'm a bit stuck, and i think it is because i'm not exactly understanding how rails actually works.
I am running centos 5.5 / apache2. I have successfully installed ruby, rubygems, and subsequently rails and passenger. All these are 'working', i can run ruby commands, gem commands etc.
But how do I start using rails on my website? If I create an .erb or .rb file with some simple ruby commands, it just displays as plain text when I navigate to it.
Do I need to configure apache to 'execute' .rb or .erb files (similar to the way .php files execute?).
Any help would be GREATLY appreciated!!
You might check out the Rails Getting Started Guide: http://guides.rubyonrails.org/getting_started.html
I suggest you read a huge tutorial on this topic: http://guides.rubyonrails.org/getting_started.html.
Ruby is the language, and Ruby on Rails is a framework. From the guide:
Rails is a web application development
framework written in the Ruby
language. It is designed to make
programming web applications easier by
making assumptions about what every
developer needs to get started. It
allows you to write less code while
accomplishing more than many other
languages and frameworks. Experienced
Rails developers also report that it
makes web application development more
fun.
I'd read Chapter 4, if you already know all this, as it talks about the actual webserver.
Rails comes with it's own webserver, so Apache isn't needed.
Sounds like you need to really get a handle on Rails and what it is first. This site has some great information for beginners, and should help you understand what you are working with and your next steps to get an application running:
http://guides.rubyonrails.org/getting_started.html
I've also heard some good things about the information here:
http://railsforzombies.org/
Check out Ruby on Rails Tutorial for getting started in Rails.
As #Blender mentioned, rails comes with an in build web server called webrick. (Think of it same as apache .. for now)
so all you have to do is go to the rails project directory, and run the command
if you are using rails < 3.x
ruby script/server
if you are using rails > 3.x
rails server
once u done this your rails project will start in webrick server and by default in port 3000
http://localhost:3000
you may consider apache/ some other rails server setup for production deployment, but to get started you dont need apache at all
and welcome to ruby world ! :D
HTH
sameera

Ruby on Rails database.yml information

I'm a designer and brand new to programming.
I have just opened my localhost and can see "Welcome aboard". It has 3 steps to complete - all of which simple to most, are complexing to me.
config/database.yml ok it wants to know my username and password. Where do I get these and where do I post them to to get them to work? I opened my database.yml and it is
SQLite version 3.x
gem install sqlite3-ruby
I hear people talking about git and all this but confused on how to do these 3 steps -
1.
Create your databases and edit config/database.yml
Rails needs to know your login and password.
2.
Use script/generate to create your models and controllers
To see all available options, run it without parameters.
3.
Set up a default route and remove or rename this file
Routes are set up in config/routes.rb.
Is this just too over my head? I wouldn't mind hiring someone to teach get it all going for me because I really want to learn to code Ruby on Rails.
Thanks!
Note - All resolved by deleting and reinstalling. Now I understand what is actually happening.
Since you're using an SQLite database, you don't need to configure any username or password to get going with the database -- the default configuration should work out of the box and creates a new database file automatically for you.
For your other questions, the Getting Started with Rails guide over at guides.rubyonrails.org is an excellent introduction that walks you through all the steps in creating a new Rails application. Start by going through this tutorial step by step -- if you get stuck somewhere along the way you can always come back here and post follow-up questions.
If you don't have any idea what a database is you should just leave database.yml alone and use the provided defaults (use sqlite, does not require a password/login). For getting started with Rails, this should be enough. Just delete the public/index.html file.
I would really recommend you to buy a book (Rails 3) (3rd edition is for Rails 2.3) which guides you through the creation of a Rails app - with a lot of examples. The guides are an alternative, but also might be a little difficult to read with close-to-none preknowledge of programming.
I think you might find Michael Hartl's Ruby on Rails Tutorial helpful. It's available for purchase as a PDF or you can view the online version for free. It covers all the major steps of developing a Rails application, including using Git.

Resources