DEV Community

deveshprojectwork
deveshprojectwork

Posted on • Updated 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

Top comments (0)