Developing a social networking site; acts_as_votable (aka acts_as_likeable)

66 views
Skip to first unread message

fugee ohu

unread,
Feb 3, 2016, 3:35:46 AM2/3/16
to Ruby on Rails: Talk
 i'm trying to follow this tutorial https://medium.com/rails-ember-beyond/how-to-build-a-social-network-using-rails-eb31da569233#.cdojrtwvg but on line 1 of _form.html.erb for likes the author says <% if current_user.liked? likeable %> When i ran the app it raised the error undefined method likeable

Colin Law

unread,
Feb 3, 2016, 5:05:25 AM2/3/16
to Ruby on Rails: Talk
Undefined method likeable for what object? As I suspect I have
pointed out previously it is always best to copy/paste the complete
error message.

I cannot see where the liked? method is defined. Do you know where it
comes from?

Colin

fugee ohu

unread,
Feb 3, 2016, 1:11:48 PM2/3/16
to Ruby on Rails: Talk
from the acts_as_followable gem, i was hoping someone would look at the page and tell me their interpretation but I guess that's not what this group is for

nanaya

unread,
Feb 3, 2016, 1:58:35 PM2/3/16
to rubyonra...@googlegroups.com
Hi,
The tutorial seems to be skipping a lot of things. Check out repository
of the finished app, and in your case, specifically how to partial is
included (where `likeable` is defined):

https://github.com/sudharti/socify/blob/master/app/views/shared/_actions.html.erb

fugee ohu

unread,
Feb 3, 2016, 2:53:30 PM2/3/16
to Ruby on Rails: Talk

Yikes, what does this mean? <%= render 'likes/form', likeable: resource %>

nanaya

unread,
Feb 3, 2016, 11:42:08 PM2/3/16
to rubyonra...@googlegroups.com
Hi,

On Thu, Feb 4, 2016, at 04:53, fugee ohu wrote:
> >
> > https://github.com/sudharti/socify/blob/master/app/views/shared/_actions.html.erb
> >
>
> Yikes, what does this mean? <%= render 'likes/form', likeable: resource
> %>
>


it means you need to read documentation:

http://api.rubyonrails.org/classes/ActionView/PartialRenderer.html

fugee ohu

unread,
Feb 4, 2016, 6:11:15 PM2/4/16
to Ruby on Rails: Talk

there's a "respond to js" at the top of the likes_controller  how's that supposed to work? in your view is it acceptable to redirect to request.referrer or do i wanna modify the dom with javascript to change between like and unlike being displayed

fugee ohu

unread,
Feb 5, 2016, 12:49:34 AM2/5/16
to Ruby on Rails: Talk


On Wednesday, February 3, 2016 at 11:42:08 PM UTC-5, nanaya wrote:

 The controller https://github.com/sudharti/socify/blob/master/app/controllers/likes_controller.rb doesn't respond with any rendering I don't wanna redirect I just wanna change the like button to the  unlike button so how would i do that

nanaya

unread,
Feb 5, 2016, 1:33:56 AM2/5/16
to rubyonra...@googlegroups.com
Hi,

On Fri, Feb 5, 2016, at 14:49, fugee ohu wrote:
>
> The controller
> https://github.com/sudharti/socify/blob/master/app/controllers/likes_controller.rb
> doesn't respond with any rendering I don't wanna redirect I just wanna
> change the like button to the unlike button so how would i do that
>

It's already doing exactly that. Check the respond_to[1] line at the top
of the controller and the corresponding views[2].

[1]
http://api.rubyonrails.org/classes/ActionController/MimeResponds.html#method-i-respond_to

[2] https://github.com/sudharti/socify/blob/master/app/views/likes/

nanaya

unread,
Feb 5, 2016, 1:42:27 AM2/5/16
to rubyonra...@googlegroups.com
Sorry, wrong link.

On Fri, Feb 5, 2016, at 15:33, nanaya wrote:
> It's already doing exactly that. Check the respond_to[1] line at the top
> of the controller and the corresponding views[2].
>
> [1]
> http://api.rubyonrails.org/classes/ActionController/MimeResponds.html#method-i-respond_to
>

Should be
http://api.rubyonrails.org/v4.1.6/classes/ActionController/MimeResponds/ClassMethods.html#method-i-respond_to


> [2] https://github.com/sudharti/socify/blob/master/app/views/likes/
>

fugee ohu

unread,
Feb 5, 2016, 9:12:08 PM2/5/16
to Ruby on Rails: Talk

 thanks, will read
Reply all
Reply to author
Forward
0 new messages