【发布时间】:2014-11-09 22:53:53
【问题描述】:
我想知道是否有人可以给我一些指导,让我知道接下来要采取的最佳步骤,因为我还在学习 rails。基本上,我有一个网站,允许用户注册、登录、注销和编辑他们的个人资料。我这样做是为了进行身份验证。我有一个网站管理区域,供网站所有者而不是公众使用。我选择这样做是因为它是一个电子商务网站,我希望用户部分更加定制。我现在想创建以下页面。
用户查看其订单历史记录的状态页面, 兑换优惠券的奖励页面, 供用户查看他们当前注册了哪些订阅的页面。
我在下面包含了我的用户代码,但如果有人可以帮助我解决这个问题,我将不胜感激,因为我无法完全理解下一步的最佳选择!
class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
has_attached_file :avatar, :styles => { :medium => "300x300>", :thumb => "100x100#" }, :default_url => "/images/:style/missing.png"
validates_attachment_content_type :avatar, :content_type => /\Aimage\/.*\Z/
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
validates :name, presence: true
has_many :listings, dependent: :destroy
# # a listings existence depends on the existence of the user that created it
# has_many :sales, class_name: "Order", foreign_key: "seller_id"
has_many :purchases, class_name: "Order", foreign_key: "buyer_id"
【问题讨论】:
标签: ruby-on-rails ruby ruby-on-rails-4 github