Feature item display
-
app/controllers/categories_controller.rb 0 → 100644
1 class CategoriesController < ApplicationController 2 before_filter :get_categories 3 4 def show 5 params[:per_page] ||= 5 -
Master
@dieutb per_page should belong to model. Can you move it to Category model?
https://github.com/amatsuda/kaminari#configuring-default-per_page-value-for-each-model
-
-
app/controllers/categories_controller.rb 0 → 100644
1 class CategoriesController < ApplicationController 2 before_filter :get_categories 3 4 def show 5 params[:per_page] ||= 5 6 params[:page] ||= 1 -
-
app/controllers/products_controller.rb 0 → 100644
-
1 1 module ApplicationHelper 2 def currency_number(price=0, currency="usd") -
Master
@dieutb rails has helpers like number_to_currency. You can use it instead of write new method http://api.rubyonrails.org/
-
-
app/models/product.rb 0 → 100644
1 class Product < ActiveRecord::Base 2 belongs_to :category 3 belongs_to :user 4 5 dragonfly_accessor :image do 6 # default 'public/images/product_default.jpg' 7 end 8 9 validates :pid, :title, :price, :category_id, :image, :stock, :release_date, :public_date, presence: true 10 validates :pid, uniqueness: true 11 12 scope :recommend, -> {where(recommend: true)} -
MasterEdited
@dieutb use space before } and after { Please take a look on convention
-
-
app/services/datetime_service.rb 0 → 100644
-
-
9 9 span.icon-bar 10 = link_to 'Home', root_path, class: 'navbar-brand' 10 h1.logo 11 a(href="#{root_path}" class='navbar-brand') 12 = image_tag "logo.png" 13 'Venshop 11 14 .collapse.navbar-collapse 12 15 ul.nav.navbar-nav 13 16 = render 'layouts/navigation_links' 14 17 15 18 ul.nav.navbar-nav.navbar-right 16 19 - if current_user.present? 17 20 li 18 a= current_user.email 21 = link_to (current_user.name || current_user.email), edit_user_registration_path -
Master
@dieutb You can use decorator to wrap this method instead of putting in views There is a gem for decorator: https://github.com/drapergem/draper
-
-
app/services/datetime_service.rb 0 → 100644
1 class DatetimeService 2 def self.strptime(str = nil, type="%Y-%m-%d") -
Master
Yes I have use it in controller, too
-
-
1 1 module ApplicationHelper 2 def currency_number(price=0, currency="usd") -
Master
It is the syntax for currency in view. In view have many places show price. When we want change syntax, we just only edit function in helper
-
-
1 1 module ApplicationHelper 2 def currency_number(price=0, currency="usd") -
Reporter
'In view have many places show price' --> so you can write
currency_numberto wrapnumber_to_currency
-
-
Status changed to closed
Toggle commit list