loading...

Day 27 : #100DaysofCode - Still reviewing the basic rails concepts . . .

sincerelybrittany profile image Brittany ・2 min read

Today, I learned more about rails, here are some of the notes I took down:

When building any app it is important to do the following:

  1. Plan out your urls for the app that you are building
  2. Figure out what your database("db") needs to fulfill your task. Confirm if your db needs to change or what tables you need to create.
  3. If you end up creating/needing a new table, ask yourself: Do you need a model? Do you need to create or use the model generator?
  4. Then after all that, you should play with your database within your console.

When you first look at a rails application after learning Sinatra, you will see a lot of similar files. For example, you will still find a config.ru file that your server will reference when you run rails server in your terminal. Dont be nervous, running rails server is the same as running rackup or shotgun within a Sinatra app except rails runs on localhost:3000 and Sinatra runs on localhost:9393.

Your config.ru file will load the environment still and run your rails application. It should look something like this:

require_relative 'config/environment'

run Rails.application

The Gemfile still holds all the dependencies.
The Rakefile, still loads all rake task for Rails.

And you still have models, controllers, and views. One major difference is routes. Routes are handled in a separate file and can be found in your config folder. An easy way to view the routes available to you on your rails application is to simply type rails routes in your terminal.

When building a rails app, know that naming conventions are important, so keep the following in mind:

  1. The table name should be lowercase with a pluralized name of the model.

  2. The model file name should be singular lowercase and underscored

  3. The class name for model should be singular camelcase.

Feel free to take a look at my practice rails application on Github.

Thank you for reading.

Sincerely,
Brittany

Song of the day: Roots Virtual Picnic

Posted on by:

sincerelybrittany profile

Brittany

@sincerelybrittany

Developer | Software Engineer 👩🏾‍💻 | Determined | Music & Dance | Completed #100DaysofCode | #WomenWhoCode

Discussion

markdown guide