SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Zealot sethtrain's Avatar
    Join Date
    Dec 2003
    Location
    Paducah, KY
    Posts
    174
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Observe two fields?

    Can I observe two fields with observer_field? I have a select menu for subject level and a select menu for content area and I wanted to get all fields from a table that correlate to that information. How should I approach this?

    Code:
    @cores = CoreContent.find(:all, :condition => "subject = '@params[resource_subject_id]' and level = '@params[resource_level_id]'")
    --
    sethtrain

  2. #2
    SitePoint Guru silver trophy Luke Redpath's Avatar
    Join Date
    Mar 2003
    Location
    London
    Posts
    794
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Not an answer to your question (sorry) but a quick tip nonetheless.

    Do not do:

    Code:
    @cores = CoreContent.find(:all, :condition => "subject = '@params[resource_subject_id]' and level = '@params[resource_level_id]'")
    You are leaving yourself wide open to SQL injection attacks. Rails can protect you from this by doing this instead:

    Code:
    @cores = CoreContent.find(:all, :condition => "subject = ? and level = ?", [ @params[resource_subject_id], @params[resource_level_id] ])

  3. #3
    SitePoint Zealot sethtrain's Avatar
    Join Date
    Dec 2003
    Location
    Paducah, KY
    Posts
    174
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks. Helpful tip!!
    --
    sethtrain

  4. #4
    SitePoint Wizard samsm's Avatar
    Join Date
    Nov 2001
    Location
    Atlanta, GA, USA
    Posts
    5,011
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Are you talking about the AJAX helper observe_field?

    If so (and I understand), observe_form might do what you want, but I don't think observe_feild can be coerced into looking at more than one select or input.
    Using your unpaid time to add free content to SitePoint Pty Ltd's portfolio?


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •