Neeraj Kumar
2005-Nov-03 17:21 UTC
What is object here in ...if object.respond_to?("errors") && object.errors.respond_to?("on")...
http://dev.rubyonrails.org/browser/trunk/actionpack/lib/action_view/helpers/active_record_helper.rb Line no: 151 alias_method :tag_without_error_wrapping, :tag def tag(name, options) if object.respond_to?("errors") && object.errors.respond_to?("on") error_wrapping(tag_without_error_wrapping(name, options), object.errors.on (@method_name)) else tag_without_error_wrapping(name, options) end end What''s "object" in there? In this case object is instance of what? _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
Doug Fales
2005-Nov-03 18:42 UTC
Re: What is object here in ...if object.respond_to?("errors") && object.errors.respond_to?("on")...
Hi Neeraj, Hopefully, object will be an instance of a model that you assigned in your controller''s action. See http://dev.rubyonrails.org/browser/trunk/actionpack/lib/action_view/helpers/form_helper.rb#L242 (form_helper.rb, line 242) for the definition of the InstanceTag#object method. FYI, the ''@object_name'' that is referenced on line 243 is the name of the object that you passed into the specific InstanceTag method. For instance, if you did a: text_field :user, :name then @object_name will be ''user'' and the InstanceTag#object method will yield the value of whatever was assigned to ''@user'' in your controller. -Doug On 11/3/05, Neeraj Kumar <neeraj.jsr-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> http://dev.rubyonrails.org/browser/trunk/actionpack/lib/action_view/helpers/active_record_helper.rb > > Line no: 151 > > alias_method :tag_without_error_wrapping, :tag > def tag(name, options) > if object.respond_to?("errors") && > object.errors.respond_to?("on") > > error_wrapping(tag_without_error_wrapping(name, options), > object.errors.on(@method_name)) > else > tag_without_error_wrapping(name, options) > end > end > > > > What''s "object" in there? In this case object is instance of what? > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > >
Neeraj Kumar
2005-Nov-03 19:00 UTC
Re: What is object here in ...if object.respond_to?("errors") && object.errors.respond_to?("on")...
Thanks Doug. -=- Neeraj On 11/3/05, Doug Fales <doug.fales-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Hi Neeraj, > > Hopefully, object will be an instance of a model that you assigned in > your controller''s action. See > > http://dev.rubyonrails.org/browser/trunk/actionpack/lib/action_view/helpers/form_helper.rb#L242 > (form_helper.rb, line 242) for the definition of the > InstanceTag#object method. > > FYI, the ''@object_name'' that is referenced on line 243 is the name of > the object that you passed into the specific InstanceTag method. For > instance, if you did a: > text_field :user, :name > then @object_name will be ''user'' and the InstanceTag#object method > will yield the value of whatever was assigned to ''@user'' in your > controller. > > -Doug > > > On 11/3/05, Neeraj Kumar <neeraj.jsr-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > http://dev.rubyonrails.org/browser/trunk/actionpack/lib/action_view/helpers/active_record_helper.rb > > > > Line no: 151 > > > > alias_method :tag_without_error_wrapping, :tag > > def tag(name, options) > > if object.respond_to?("errors") && > > object.errors.respond_to?("on") > > > > error_wrapping(tag_without_error_wrapping(name, options), > > object.errors.on(@method_name)) > > else > > tag_without_error_wrapping(name, options) > > end > > end > > > > > > > > What''s "object" in there? In this case object is instance of what? > > > > _______________________________________________ > > 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 >_______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails