DEV Community

deveshprojectwork
deveshprojectwork

Posted on • Edited on

Rail Setup

  ## Rail Setup
    $ rails new <app>
    * $ bundle update - this will update the GEM, already created in first command
    $ rails generate scaffold username:string password:string
           1. $ rails generate scaffold recipe
    $ rake db:migrate RAILS_ENV=development
    $ rails db:migrate - run the script on the local server
    $ rails new <app>
    $ bundle update - this will update the GEM, already created in first command
    $ rails generate scaffold username:string password:string
    $ rails generate scaffold recipe
    $ rake db:migrate RAILS_ENV=development
    $ rails db:migrate - run the script on the local server

    $ Inside HTML
      <% tweet = Tweet.fin(1) %>  this will not be shown on the HTML
      <h1><%= tweet.status %></h1>  this will print on the HTML screen

    $ layout 
      to the /app/views/layouts/application.html.erb/
      <html>
          <body>
            <%= yield %>   {this will take all the other page &rest layout }
          </body>
      </html>


  ### Chapter 1 <a name="chapter-1"></a>

Scaffold

    * $ rails new <app>
    * $ bundle update - this will update the GEM, already created in first command
    * $ rails generate scaffold username:string password:string
    * $ rails generate scaffold recipe
    * $ rake db:migrate RAILS_ENV=development
    * $ rails db:migrate - run the script on the local server

Change to Config/routes.rb by -:

Destroy Scaffold & Text Genration

    $ root to: 'users#index'
    $ get 'about', to:'pages#about'
    $ $ rails -s -: run the application

    $ rails destroy scaffold <app> or rails d scaffold books - Destroy
    $ rails generate controller pages index contact about -: generate the controller
    $ rails new myapp --database=postgresql
    $ render plain: 'hello'
    $ puts 'hello'

Calling the Gem for rest-client(API)

    $ gem install rest-client
    $ bundle update

    $ rails routes
    $ rails generate model book title:string author:string
    $ rails generate controller book

Debug

1. <%= debug(params) %>
2. <%= debug(@data) %>
3. rails c
4. Google Developer
5. buy bug
6. Pry Gem 

Error :uninitialized constant LoginController Did you mean? LoginsController
Change delete 'logout', to: 'login#destroy' to delete 'logout', to: 'logins#destroy

rails new myApp --skip-active-record
https://codeburst.io/how-to-build-a-good-api-using-rubyonrails-ef7eadfa3078

Speedy emails, satisfied customers

Postmark Image

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay