Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

第一週作業 #448

Open
wants to merge 34 commits into
base: store-v1
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
6e8e5e8
修改 application.js
sdlong Mar 8, 2016
aca50c2
新增 partial: navbar
sdlong Mar 8, 2016
7a28add
rails g controller products
sdlong Mar 8, 2016
83f84ac
設定空的前台首頁
sdlong Mar 8, 2016
eccbf03
gem simple_form
sdlong Mar 8, 2016
ea3b87c
rails generate simple_form:install --bootstrap
sdlong Mar 8, 2016
3db74ff
修改 admin/products/new
sdlong Mar 8, 2016
e075415
修改 admin/products/new
sdlong Mar 8, 2016
2921b26
加入產品修改功能
sdlong Mar 8, 2016
9f6c57c
gem install carrierwave and mini_magick
sdlong Mar 8, 2016
de93e4e
rails g uploader image
sdlong Mar 8, 2016
50ac645
新增 model: photo
sdlong Mar 8, 2016
8c86dcd
設定 photo 與 product 的資料庫關聯
sdlong Mar 8, 2016
0d95d51
設定圖片上傳後裁切的尺寸
sdlong Mar 8, 2016
1142ed1
將 public/uploaders 資料夾放進 gitignore
sdlong Mar 8, 2016
f58322d
新增商品時可以上傳商品圖片
sdlong Mar 8, 2016
6e3c724
商品修改頁也能修替換圖片
sdlong Mar 8, 2016
4e1e7b1
建立前台商品 index
sdlong Mar 8, 2016
d397de1
建立前台商品 show
sdlong Mar 8, 2016
839b102
建立 layout: admin
sdlong Mar 8, 2016
d908dfb
重構後台商品列表
sdlong Mar 8, 2016
1a826b5
navbar 的下拉選單放入後台連結
sdlong Mar 8, 2016
a3d3d0d
加上 Bootstrap 的 Alert 效果
sdlong Mar 8, 2016
493b362
建立購物車按鈕
sdlong Mar 8, 2016
3443c0f
用 icon 點綴頁面設計
sdlong Mar 8, 2016
6d56e2e
修飾 css, 讓售價顯示更美觀
sdlong Mar 8, 2016
fab3596
rails g controller admin::users
sdlong Mar 8, 2016
d1bf3cc
建立基礎的使用者清單頁面
sdlong Mar 8, 2016
8e52abc
將使用者清單頁面套入後台權限與 layout
sdlong Mar 8, 2016
919da42
後台邊欄放入使用者管理的連結
sdlong Mar 8, 2016
533d319
顯示使用者現在權限
sdlong Mar 8, 2016
ade4cd1
放入轉換權限的按鈕
sdlong Mar 8, 2016
52abc50
完成設定使用者權限的功能設定
sdlong Mar 8, 2016
fb6af95
將『建立二個商品資料』放入種子檔
Mar 10, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
商品修改頁也能修替換圖片
  • Loading branch information
sdlong committed Mar 9, 2016
commit 6e3c7248179ff4719f71f94ea1c4ab24266423ef
6 changes: 6 additions & 0 deletions app/controllers/admin/products_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ def new

def edit
@product = Product.find(params[:id])

if @product.photo.present?
@photo = @product.photo
else
@photo = @product.build_photo
end
end

def create
Expand Down
11 changes: 11 additions & 0 deletions app/views/admin/products/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,17 @@
<%= f.input :price %>
</div>

<% if @photo.image.present? %>
<span>目前商品圖</span> <br>
<%= image_tag(@photo.image.thumb.url) %>
<% end %>

<div class="form-group">
<%= f.simple_fields_for :photo do |c| %>
<%= c.input :image , as: :file %>
<% end %>
</div>

<%= f.submit "Submit", data: { disable_with: "Submitting..." } %>

<% end %>