rails --视图页面 路由 controller

定义方法,在新的页面获取用户的收藏品,在路由增加

resource  :xxx do

  collection do 
    get :my_collections
  end
end

def my_collections                                          
  #@contracts = Contract.where('address = ?', current_user.address )
   @contracts = Contract.where('address = ?', params[:address] )
end

后期会增加用户的登录,判断正确的用户,来获取用户的address或者telephone,使用params[:address]也是可以的

猜你喜欢

转载自blog.csdn.net/Toml_/article/details/131591165