【发布时间】:2015-07-28 23:27:02
【问题描述】:
这就是我的演出控制器中的内容
def downloadpage
ActiveRecord::Base.transaction do
if current_user.points >= @gig.pointsneeded
current_user.points -= @gig.pointsneeded
@gig.user.points += @gig.pointsneeded
current_user.save
@gig.user.save
redirect_to @gig.boxlink
else
redirect_to :back, notice: "You don't have enough points"
end
end
end
def success_download
end
def downloadpage,在用户相互购买时进行积分交换。(我没有买家和卖家)而不是“用户和当前用户”。现在你看到我有 @987654323 def download page中的@,交易成功后直接跳转到演出的网址。
我打算创建一个名为“success_download”的页面,视图会有类似
yey you did it
<%= @gig.boxlink %>
在def download page 中,而不是redirect_to @gig.boxlink,说
redirect_to success_download_path
问题是@gig在def success_download中不可用,但在def download page中,
如何继承?
【问题讨论】:
-
你在哪里设置@gig?是否在 before_action 中?
-
你也可以通过
redirect_to success_download_path, gig: @gig.boxlinkfrom -
@Nithin 并在 views/gig/success_download 中使用 对吗?
标签: ruby-on-rails ruby ruby-on-rails-4 model-view-controller model