So I'm trying to create a facebooky kinda of site to learn rails. And so
i have a User class and a micropost class. Those are simple and I know
how that all works. The micropost points to its user and all that fun
stuff. But then i have a feed controller where i want to display ALL the
microposts and then I want to click on them to view them. I set up the
feed controller to view them and all that works. But then I also want
for any person to be able to "like" or "dislike" a micropost. The
micropost class has a like and a dislike variable in them. So I defined
a like and dislike action in the feed controller and set that all up.
The way its looks is kinda like this.
def like
@post = Micropost.find(params[:id])
@user = User.find(@post.user_id)
respond_to do |format|
format.html
end
@user.increaseVariable(@user)
@post.like_action(@post)
@user.save
@post.save
end
The routes file looks like this
match "feed/:id/like" =>"feed#like"
match "feed/:id/dislike" =>"feed#dislike"
To me, this should all work correctly. And it did when I did the methods
in the console, so i'm not worried about that. The problem is that the
post will save, but the user will not. And i'm not sure why. Any
thoughts?
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.