Hi all. I''m trying to use Ajax with a create form. It works perfectly, but now, the fields that I want to be not empty are not checked anymore. In fact, it does an error: Showing //item/_form.rhtml/ where line *#13* raised _undefined method `inject'' for nil:NilClass _ The line 13 corresponds to: |10: 11: <p><label for="item_category">Category</label><br/> 12: <select id="item_category_id" name="item[category_id]"> *13: <%= options_from_collection_for_select @categories, "id", "category", @item.category_id %>* 14: </select> 15: </p> 16: <!--[eoform:item]--> ||| In my item model I have: validates_presence_of :title || Is there another way to check fields using ajax? Thank you _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
On 4/26/05, Bruno Celeste <sadik-8wAwsZAdCYlg9hUCZPvPmw@public.gmane.org> wrote:> Hi all. > > > > I''m trying to use Ajax with a create form. It works perfectly, but now, the > fields that I want to be not empty are not checked anymore. > In fact, it does an error: Showing /item/_form.rhtml where line #13 raised > undefined method `inject'' for nil:NilClass > > > The line 13 corresponds to: > 10: > 11: <p><label for="item_category">Category</label><br/> > 12: <select id="item_category_id" name="item[category_id]"> > 13: <%= options_from_collection_for_select @categories, > "id", "category", @item.category_id %> > 14: </select> > 15: </p> > 16: <!--[eoform:item]-->Looking at this, it appears that @categories is nil. Are you assigning something to it in the action?> > > > In my item model I have: > validates_presence_of :title > > > > > Is there another way to check fields using ajax? > > > Thank you > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > >-- Cheers Koz
You are right! If I remove the "select", that works but if I let it, @categorie is nil. I don''t understand why... When I click on the button, the parameters seem to be correct: *Parameters*: {"item"=>{"title"=>"", "category_id"=>"2", "content"=>"", "author_id"=>"1"}} So, what''s going on ? Michael Koziarski a écrit :>On 4/26/05, Bruno Celeste <sadik-8wAwsZAdCYlg9hUCZPvPmw@public.gmane.org> wrote: > > >> Hi all. >> >> >> >>I''m trying to use Ajax with a create form. It works perfectly, but now, the >>fields that I want to be not empty are not checked anymore. >> In fact, it does an error: Showing /item/_form.rhtml where line #13 raised >> undefined method `inject'' for nil:NilClass >> >> >>The line 13 corresponds to: >> 10: >>11: <p><label for="item_category">Category</label><br/> >>12: <select id="item_category_id" name="item[category_id]"> >>13: <%= options_from_collection_for_select @categories, >>"id", "category", @item.category_id %> >>14: </select> >>15: </p> >>16: <!--[eoform:item]--> >> >> > >Looking at this, it appears that @categories is nil. Are you >assigning something to it in the action? > > > >> >> >>In my item model I have: >> validates_presence_of :title >> >> >> >> >>Is there another way to check fields using ajax? >> >> >>Thank you >> >>_______________________________________________ >>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