Forum: Ruby on Rails grabbing associated value from database

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
8751e148329b04c44907b24b0a14222d?d=identicon&s=25 jonathan (Guest)
on 2007-06-20 18:07
(Received via mailing list)
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
8751e148329b04c44907b24b0a14222d?d=identicon&s=25 jonathan (Guest)
on 2007-06-20 20:27
(Received via mailing list)
Anyone know the easy way to do this?
813f535246722b7bf02aacc9ce818de8?d=identicon&s=25 Bob Showalter (Guest)
on 2007-06-20 21:32
(Received via mailing list)
On 6/20/07, jonathan <jonathan@projectbreakout.com> 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?
This topic is locked and can not be replied to.