respond_to on view not working

13 views
Skip to first unread message

Sam Wilder

unread,
Oct 31, 2011, 12:42:11 PM10/31/11
to CouchRest
I am using Couchrest_model v1.1.2

I have a Model with view. Lets say there is a model User with view
defined as -
view :by_email

Now when I call User.respond_to? by_email, or anything like
( :by_email or 'by_email'), I get a false.
However on calling User.by_email, I do get proper response.

Is there a way to add the functionality of respond_to?

Samuel Lown

unread,
Nov 3, 2011, 7:15:27 AM11/3/11
to couc...@googlegroups.com
Hi,

Just to check, have you enclosed the view method in a design block?

   design do
     view :by_email
   end
 
respond_to? works fine on my setup with a User model. Perhaps you'd like to add some failing tests?

sam



--
You received this message because you are subscribed to the Google Groups "CouchRest" group.
To post to this group, send email to couc...@googlegroups.com.
To unsubscribe from this group, send email to couchrest+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/couchrest?hl=en.




--
www.samlown.com
www.autofiscal.com
www.planetaki.com/sam

Sam Wilder

unread,
Nov 3, 2011, 9:46:32 AM11/3/11
to couc...@googlegroups.com
Hi Samuel,
Thanks for responding.
I think that is exactly the problem. When using the older syntax, respond_to? was not working, but with new design do syntax, it does work.

One more question, on a point I came across - is their a specific reason on not having a update_attribute implementation. One o fthe gems I was using relied on that, when using devise_couch.

Thanks,
Sam.

Samuel Lown

unread,
Nov 3, 2011, 10:31:21 AM11/3/11
to couc...@googlegroups.com
Hi,

One more question, on a point I came across - is their a specific reason on not having a update_attribute implementation. One o fthe gems I was using relied on that, when using devise_couch.

`update_attribute` is one of those methods that makes sense for a RDMS, but obviously doesn't in CouchDB when you have to update the entire document every time; its a bit misleading IMHO.

If you really need it, I'd suggest adding your own hack in initializers:

    CouchRest::Model::Base.class_eval do
       def update_attribute(attr, value)
         send("#{attr}=", value)
         save
       end
    end

Failing that, you might want to update the gem or send us a patch for couchrest_model (with tests ;-).

Cheers,
sam
Reply all
Reply to author
Forward
0 new messages