SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Evangelist
    Join Date
    Apr 2005
    Posts
    485
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    [rails} Get Lookup Table :vehicle_id from params[:mileage]

    okay, i'm not even sure if my title makes sense, but here's what i'm trying to do.

    list is still controlled by :scaffold so i have no access to update the list action as of now.

    i need to extract information from two tables in order to display show.rhtml.

    do i need to code the list action before i can do this? i tried...

    Code:
      def show
        @mileage = Mileage.find(@params["id"])
        @mileage_vehicle = Vehicle.find(@params["vehicle_id"])
        render_text @mileage_vehicle.name
      end
    ...but i received the following error:

    "Couldn't find Vehicle without an ID"

    i also tried...

    Code:
      def show
        @mileage = Mileage.find(@params["id"])
        @mileage_vehicle = Vehicle.find(@params["@mileage.vehicle_id"])
        render_text @mileage_vehicle.name
      end
    ...with the same error message.

    is there any way to get the vehicle_id from the scaffold list page or do i need to hand code the page before i can get access to it? i think i have to code the list page, but i'd like to avoid it at this point. i think you have to define what you send in the form tag and scaffolding doesn't send :vehicle_id (but does send :id).

    tia...

    tia...

  2. #2
    SitePoint Member
    Join Date
    Nov 2006
    Location
    Austin, TX
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It's kind of hard to figure out what you're trying to do, but typically the form variables are going to look like this:

    params[:mileage][:vehicle_id]
    wtf242
    ProgrammingBooks.org - Programming Books Ranked by Programmers
    Turn of the Crank - My blog
    Robot Walrus - My Art Prints/Posters Blog


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
  •