Update scaffolding form field

Discussion in 'Ruby' started by dafritz, Jun 4, 2007.

  1. dafritz

    dafritz Guest

    This may be a basic question, but i have an "image" field in a "news"
    table, and have a form that uploads the image. Following the upload,
    the "new" action is called in the rails scaffolding so i can add the
    rest of the news to db entry. I however want the "image" field to
    contain the image id that was just created in my image table. I send
    the value to the new action, but cannot get the field to default to
    this value. I have tried :locals => { :image => :id} to see if that
    overrides the default value set in the partial. As i am fairly
    unfamiliar with where the scaffolding is storing the information for
    this form I am having trouble figuring this out. Here is the code for
    the view. The second form is the form I am using to upload the image.
    So my question is how do i get the image field to use a default value
    that was passed to the view rather than what is stored as default in
    my db.



    <h1>New news</h1>

    <%= start_form_tag :action => 'create' %>
    <%= render :partial => 'form'%>
    <%= submit_tag "Create" %>

    <%= end_form_tag %>

    <%= form_tag({:action=>'save_picture'}, :multipart => true)%>
    <input type="file" name="picture_file" />
    <input type="submit" name="Upload" />
    </form>

    <%= link_to 'Back', :action => 'list' %>
    dafritz, Jun 4, 2007
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Michael Tobis

    PyNSol: Objects as Scaffolding

    Michael Tobis, Jul 6, 2005, in forum: Python
    Replies:
    0
    Views:
    273
    Michael Tobis
    Jul 6, 2005
  2. Lyle Johnson
    Replies:
    9
    Views:
    118
    Curt Hibbs
    Jan 24, 2005
  3. George Moschovitis
    Replies:
    0
    Views:
    96
    George Moschovitis
    Aug 31, 2005
  4. Mike Novecento

    [Rails] Scaffolding of BLOB?

    Mike Novecento, Sep 20, 2005, in forum: Ruby
    Replies:
    0
    Views:
    116
    Mike Novecento
    Sep 20, 2005
  5. George Moschovitis
    Replies:
    0
    Views:
    102
    George Moschovitis
    Dec 21, 2005
Loading...

Share This Page