Rails CRUD Full
Rails CRUD FULL
...................................................................................................................................................................
Link::::::::::::::::::::::::::
https://edgeguides.rubyonrails.org/getting_started.html
...................................................................................................................................................................
STEP 0 :::::::::::::::Set up the Devise
...............................................................................................................................................................................
...............................................................................................................................................................................
...............................................................................................................................................................................
STEP I :::::::::::::::Create the project
...............................................................................................................................................................................
...............................................................................................................................................................................
rails new blog
cd blog
rails s
STEP II :::::::::::::::Say Hello Rails
...............................................................................................................................................................................
config/routes.rb:...............................................................................................................................................................................
.......................................................................... A Set Routes..........................................................................Rails.application.routes.draw do
get "/articles", to: "articles#index"
# For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html
end
..........................................................................B Set Controller..........................................................................
$ bin/rails generate controller articles index
..........................................................................C Set View..........................................................................
app/views/articles/index.html.erb.
Code : <h1>Hello, Rails!</h1>
STEP III :::::::::::::::Setting the Application Home Page
...............................................................................................................................................................................
config/routes.rb:...............................................................................................................................................................................
Rails.application.routes.draw do
get 'welcome/index'
# For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html
endRails.application.routes.draw do
get 'welcome/index'
root 'welcome#index'
end
STEP IV :::::::::::::::Resource Method in Routes
...............................................................................................................................................................................
config/routes.rb:...............................................................................................................................................................................
Rails.application.routes.draw do
get 'welcome/index'
resources :articles
root 'welcome#index'
end
All Routes will Make
$ bin/rails routes Prefix Verb URI Pattern Controller#Action welcome_index GET /welcome/index(.:format) welcome#index articles GET /articles(.:format) articles#index POST /articles(.:format) articles#create new_article GET /articles/new(.:format) articles#new edit_article GET /articles/:id/edit(.:format) articles#edit article GET /articles/:id(.:format) articles#show PATCH /articles/:id(.:format) articles#update PUT /articles/:id(.:format) articles#update DELETE /articles/:id(.:format) articles#destroy root GET / welcome#index
Comments
Post a Comment