如何在同一個控制器中調用其他操作?
後來我想通過@community or @user
和params[:comment][:body]
到part_two
如何在同一個控制器中調用其他操作?
我當前的代碼是這樣的。
def part_one
if params[:mode] == "1"
@community = Community.find(params[:id])
@body = "This is for Community"
elsif params[:mode] == "2"
@user = User.find(params[:id])
@body = "This is for User"
end
params[:comment][:body] = @body
-----here I want to call action [part_two]-------
end
def part_two
transaction that needs @community or @user, and params[:comment][:body]
end
非常感謝。它是否甚至將'params [:comment] [:body]'傳遞給part_two? – MKK
是的,'params [:comment] [:body]'也應該放在'part_two'中。讓我知道如果它不。 –
如果part_one和part_two都是控制器操作,則這確實無法按預期工作。 – sevenseacat