Creating a new Rails app( not finished yet)

Syeda Ismat Farjana
2 min readJun 22, 2020

starting postgresql :

`pg_ctl -D /usr/local/var/postgres start`

After running the rail welcome page:

4 FEATURES:

  1. show the list of blogs => index => get
  2. show one selected blogpost => get
  3. create blog post => new / create=> post
  4. edit/update selected post => patch/put
  5. delete selected post =>delete

rails routes: shows available routes for the application

STEPS:

  1. routes.rb : write root 'blog#index'
  2. `resources :blogs` to create all the paths to the required controller method. (get '/blogs', to: 'blogs#index' ) , (get '/blogs/:id', to: 'blogs#show' ), (get '/blogs/:id/edit', to: 'blogs#edit' ), (get '/blogs/new', to: 'blogs#new'), (post '/blogs', to: 'blogs#create' )
  3. controller file => blogs_controller.rb =>

def index

end

3. view folder => create blogs folder => create index.html.erb => add something to see if it works.

4. view folder => blogs folder => create _form.html.erb

5. view folder => blogs folder => create new.html.erb => add the form

6. controller file => blogs_controller.rb =>

def new

end

7. In terminal: rails g model Blog title:string body:text author:string => it creates amigtare file

8. rails db:migrate

9. controller file => blogs_controller.rb =>

def create

end

10. controller file = >private method :

11. controller file => blogs_controller.rb =>

def show

end

12.. controller file = >private method : set_article

13. view folder => blogs folder => create show.html.erb => to show that specific post

14. controller file => blogs_controller.rb =>

def edit

end

15. view folder => blogs folder => create edit.html.erb => to edit that specific post

16. controller file => blogs_controller.rb =>

def update

end

17. controller file => blogs_controller.rb =>

def delete

end

18. adding comment section.

19. in controller:

def show
@comment = Comment.new
end

20. rails g model Comment body:text article:references

21. rails db:migrate

22. routes =>

root ‘articles#index’
resources : articles do
resources :comments
end

23. comments_controller.rb

24.

25.

26. heroku run db:migrate

--

--

Syeda Ismat Farjana

I am a physician, eager to learn Coding and eventually jump into the world of AI so I can work for the future.