Skip to content

phamonyut/shopaccount

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ShopAccount

Training project

Features

  • CRUD
  • Searable
  • Pagination
  • Bootstrap

Getting Started

  • สร้างโปรเจค rails new shopaccount -d mysql

  • สร้าง scaffold rails g scaffold product title:string price:float count:integer

  • สร้าง database + table rake db:create rake db:migrate

  • แก้ product_controller.rb

def increase
  product = Product.find(params[:product_id])
  product.count = product.count + 1
  product.save
  redirect_to products_path
end

def decrease
  product = Product.find(params[:product_id])
  product.count = product.count - 1
  product.save
  redirect_to products_path
end
  • แก้ route.rb
root 'products#index'
resources :products do
  get 'increase'
  get 'decrease'
end
  • แก้ product\index.html.erb
<td><%= link_to 'Increase', product_increase_path(product) %></td>
<td><%= link_to 'Decrease', product_decrease_path(product) %></td>

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published