Raymond,
On 20.8.2005, at 4.28, Raymond Brigleb wrote:
> I''m trying to get an AJAX list built into a Rails page
I''m working
> on. The page is an image, and underneath it you can add or remove  
> "options" such as t-shirt sizes or what have you.
>
> I''m passing params back to my controller from my view via ajax. I
> might have one of these in the view:
>
>         <%= text_field_tag(''option_title'',
'''',
>                                              {:id            =>  
> ''option-title-field'',
>                                                 :size        => 16,
>                                                 :class    =>  
> ''option-title''}) %>
>
> And then in my controller I''m parsing these text_field options
thusly:
>
>         option = Option.create({:title        => params 
> [:option_title],
>                                                         :price         
> => params[:option_price],
>                                                         :quantity    = 
> > params[:option_quantity],
>                                                         :image_id  
> => params[:id]})
>
> ...but unfortunately, that params[:id] doesn''t work. It comes out
> null.
You need to have a form field that defines the id:
<%= hidden_field_tag "id", @image.id %>
Then you should have the params[:id] at hand in the receiving  
controller action.
//jarkko
>
> Is there some way for me to see my Image''s id from within my AJAX
> calls, so that I can associate my newly created "options" with
the
> image they were created from?
>
> Thanks,
> Raymond
> _______________________________________________
> Rails mailing list
> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>
_______________________________________________
Rails mailing list
Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
http://lists.rubyonrails.org/mailman/listinfo/rails