0
我正在開發的支付系統在我app.for這個我考慮railcasts參考EP-141 我遵循所有的步驟,每個情節,但我得到這個錯誤作爲未定義的方法`paypal_url」
undefined method `paypal_url'
我試過但沒有找到答案。
這裏我有BookingDetail maodel如下
class BookingDetail < ActiveRecord::Base
belongs_to :room
attr_accessible :member_type_id, :room_type_id, :start_date, :end_date, :room_rate_id, :room_no, :customer_id, :room_id
def total_price
room_type.to_a.sum(&:room_rate)
end
def paypal_url(return_url)
values = {
:business => '',
:cmd => '_cart',
:upload => 1,
:return => return_url,
:invoice => id
}
room_type.each_with_index do |item, index|
values.merge!({
"room_rate_#{index+1}" => item.room_rate,
"room_type_#{index+1}" => item.room_type,
"room_id_#{index+1}" => item.room_rate.room_id,
"quantity_#{index+1}" => item.quantity
})
end
"https://www.sandbox.paypal.com/cgi-bin/webscr?" + values.to_query
end
末
此行給了我錯誤
<%=link_to "Checkout",@room.paypal_url(rooms_url)%>
沒有我要做什麼呢?
這樣做。但這是爲has_one:booking_detail,但在我的模型中,我有has_many:booking_details然後我應該怎麼寫 – r15
然後它取決於你想要哪些鏈接的多個booking_details – Abid
好的謝謝你的幫助 – r15