resources rails code example

Example 1: get and to rails

@patient = Patient.find(params[:id])

Example 2: rails resources only

resources :controller_name, only: [:create, :new]

Example 3: rails resources

resources :controller_name # => new create edit update index show destroy

resources :controller_name, only: [:index, :new, :create, :edit, :update]
# <=>
resources :controller_name, except: [:destroy, :show]

Example 4: resources rails

resources :name_of_your_controller

Example 5: rails resources

get '/patients/:id', to: 'patients#show'
# url: your_site/patients/12

Tags:

Ruby Example