To add image field in shop
This commit is contained in:
@@ -71,6 +71,6 @@ class Settings::ShopsController < ApplicationController
|
|||||||
|
|
||||||
# Never trust parameters from the scary internet, only allow the white list through.
|
# Never trust parameters from the scary internet, only allow the white list through.
|
||||||
def shop_params
|
def shop_params
|
||||||
params.require(:shop).permit(:name,:address,:city,:township,:state,:country,:phone_no,:reservation_no,:license,:activated_at,:license_data,:base_currency,:cloud_token,:cloud_url,:owner_token,:id_prefix,:is_rounding_adj,:quick_sale_summary,:calc_tax_order,:show_account_info)
|
params.require(:shop).permit(:logo, :name,:address,:city,:township,:state,:country,:phone_no,:reservation_no,:license,:activated_at,:license_data,:base_currency,:cloud_token,:cloud_url,:owner_token,:id_prefix,:is_rounding_adj,:quick_sale_summary,:calc_tax_order,:show_account_info)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
class Shop < ApplicationRecord
|
class Shop < ApplicationRecord
|
||||||
ShopDetail = Shop.find_by_id(1)
|
ShopDetail = Shop.find_by_id(1)
|
||||||
|
|
||||||
|
# Shop Image Uploader
|
||||||
|
mount_uploader :logo, ShopImageUploader
|
||||||
end
|
end
|
||||||
|
|||||||
59
app/uploaders/shop_image_uploader.rb
Normal file
59
app/uploaders/shop_image_uploader.rb
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
class ShopImageUploader < CarrierWave::Uploader::Base
|
||||||
|
|
||||||
|
# Include RMagick or MiniMagick support:
|
||||||
|
# include CarrierWave::RMagick
|
||||||
|
include CarrierWave::MiniMagick
|
||||||
|
|
||||||
|
# Choose what kind of storage to use for this uploader:
|
||||||
|
storage :file
|
||||||
|
# storage :fog
|
||||||
|
|
||||||
|
def root
|
||||||
|
Rails.root.join 'public/'
|
||||||
|
end
|
||||||
|
|
||||||
|
# Override the directory where uploaded files will be stored.
|
||||||
|
# This is a sensible default for uploaders that are meant to be mounted:
|
||||||
|
def store_dir
|
||||||
|
"image/shop_images"
|
||||||
|
# "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
|
||||||
|
end
|
||||||
|
|
||||||
|
# def cache_dir
|
||||||
|
# '/tmp/images'
|
||||||
|
# end
|
||||||
|
|
||||||
|
# Provide a default URL as a default if there hasn't been a file uploaded:
|
||||||
|
# def default_url(*args)
|
||||||
|
# # For Rails 3.1+ asset pipeline compatibility:
|
||||||
|
# # ActionController::Base.helpers.asset_path("fallback/" + [version_name, "default.png"].compact.join('_'))
|
||||||
|
#
|
||||||
|
# "/images/fallback/" + [version_name, "default.png"].compact.join('_')
|
||||||
|
# end
|
||||||
|
|
||||||
|
# Process files as they are uploaded:
|
||||||
|
# process scale: [200, 300]
|
||||||
|
process :resize_to_fit => [200, 150]
|
||||||
|
#
|
||||||
|
# def scale(width, height)
|
||||||
|
# # do something
|
||||||
|
# end
|
||||||
|
|
||||||
|
# Create different versions of your uploaded files:
|
||||||
|
# version :thumb do
|
||||||
|
# process resize_to_fit: [50, 50]
|
||||||
|
# end
|
||||||
|
|
||||||
|
# Add a white list of extensions which are allowed to be uploaded.
|
||||||
|
# For images you might use something like this:
|
||||||
|
def extension_whitelist
|
||||||
|
%w(jpg jpeg gif png)
|
||||||
|
end
|
||||||
|
|
||||||
|
# Override the filename of the uploaded files:
|
||||||
|
# Avoid using model.id or version_name here, see uploader/store.rb for details.
|
||||||
|
# def filename
|
||||||
|
# "something.jpg" if original_filename
|
||||||
|
# end
|
||||||
|
|
||||||
|
end
|
||||||
@@ -12,7 +12,7 @@
|
|||||||
<%= f.input :unit_price %>
|
<%= f.input :unit_price %>
|
||||||
<%= f.input :description %>
|
<%= f.input :description %>
|
||||||
<%= f.input :information %>
|
<%= f.input :information %>
|
||||||
<%= f.input:taxable %>
|
<%= f.input :taxable %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<label>Product Image</label>
|
<label>Product Image</label>
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-xs-12 col-sm-12 col-md-8 col-lg-8">
|
<div class="col-xs-12 col-sm-12 col-md-8 col-lg-8">
|
||||||
|
<div class="card">
|
||||||
|
<div class="body">
|
||||||
<%= simple_form_for([:settings,@settings_shop]) do |f| %>
|
<%= simple_form_for([:settings,@settings_shop]) do |f| %>
|
||||||
<%= f.error_notification %>
|
<%= f.error_notification %>
|
||||||
<div class="form-inputs p-l-10">
|
<div class="form-group p-l-15">
|
||||||
<%= f.input :name ,:input_html=>{:class=>"col-md-10"},:required=>true%>
|
<%= f.input :name ,:input_html=>{:class=>"col-md-10"},:required=>true%>
|
||||||
|
|
||||||
<%= f.input :address %>
|
<%= f.input :address %>
|
||||||
<%= f.input :city %>
|
<%= f.input :city %>
|
||||||
<%= f.input :township %>
|
<%= f.input :township %>
|
||||||
@@ -22,15 +23,32 @@
|
|||||||
<%= f.input :quick_sale_summary %>
|
<%= f.input :quick_sale_summary %>
|
||||||
<%= f.input :calc_tax_order %>
|
<%= f.input :calc_tax_order %>
|
||||||
<%= f.input :show_account_info %>
|
<%= f.input :show_account_info %>
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class="form-actions">
|
|
||||||
|
<label>Shop Image</label>
|
||||||
|
<div class="panel padding-10">
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="menu-item-img">
|
||||||
|
<% if f.object.logo? %>
|
||||||
|
<p><%= f.object.name %></p>
|
||||||
|
<%= image_tag f.object.logo.url, :class => "img-thumbnail" %>
|
||||||
|
<% else %>
|
||||||
|
<%= image_tag "/image/menu_images/default.png", :class => "img-thumbnail" %>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
<%= f.file_field :logo, :class => "img-thumbnail" %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-actions p-l-15">
|
||||||
<%= f.submit "Submit",:class => 'btn btn-primary btn-lg waves-effect' %>
|
<%= f.submit "Submit",:class => 'btn btn-primary btn-lg waves-effect' %>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-xs-12 col-sm-12 col-md-4 col-lg-4">
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-xs-12 col-sm-12 col-md-4 col-lg-4">
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="body">
|
<div class="body">
|
||||||
<h5><i class="material-icons md-18">view_headline <%= t("views.right_panel.header.page_detail") %></i></h5>
|
<h5><i class="material-icons md-18">view_headline <%= t("views.right_panel.header.page_detail") %></i></h5>
|
||||||
@@ -64,5 +82,5 @@
|
|||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -96,8 +96,10 @@
|
|||||||
<td><%= @settings_shop.calc_tax_order %></td>
|
<td><%= @settings_shop.calc_tax_order %></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
<td style="width:20%">Shop Image</td>
|
||||||
|
<td><%= image_tag @settings_shop.logo, :size => '200x200'%></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
<td><%= link_to t("views.btn.edit"), edit_settings_shop_path(@settings_shop),:class => 'btn btn-primary btn-sm waves-effect' %>
|
<td><%= link_to t("views.btn.edit"), edit_settings_shop_path(@settings_shop),:class => 'btn btn-primary btn-sm waves-effect' %>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|||||||
Reference in New Issue
Block a user