Grabbing associated value from database


#1

i’m posting a promo code from a form and need to grab the relavant
information from the database to apply it properly to the amount be
paid so that the discount is applied.

the value posted is params[:promo_code][:code]

how can i grab this from the database


#2

Anyone know the easy way to do this?


#3

On 6/20/07, jonathan removed_email_address@domain.invalid wrote:

i’m posting a promo code from a form and need to grab the relavant
information from the database to apply it properly to the amount be
paid so that the discount is applied.

the value posted is params[:promo_code][:code]

how can i grab this from the database

Assuming you have a table called promo_codes (and an associated
PromoCode model), you could fetch the data with:

@row = PromoCode.find_by_code(params[:promo_code][:code])

Is that what you’re asking?