Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Users can like posts feature (wip) #1

Merged
merged 10 commits into from Mar 4, 2024
Merged

Conversation

fedesapuppo
Copy link
Owner

@fedesapuppo fedesapuppo commented Mar 1, 2024

HOLA TUTEE!! :D here testing the pull request as you suggested (even though wip)

What I want as a the next feature of this toy app is for users to be able to like posts, we want each user to have_many posts and each post to have_many likes, but users should only be able to like the posts that they haven't already liked!! Otherwise I could upload a pic of my ugly face to a contest and like my post 30000 times and then win a fly-ticket to the french polynesia. I created partials in which I plan to insert the forms to create the likes. maybe something like:

<%= form_with model: like, url: post_like_path(post, like), method: :delete, class: 'like-form' do |f| %>
<%= f.submit 'Unlike', class: 'btn btn-danger unlike-button' %>
<% end %>

and

<%= form_with model: Like.new, url: post_likes_path(post), method: :post, class: 'like-form' do |f| %>
<%= f.hidden_field :post_id, value: post.id %>
<%= f.submit 'Like', class: 'btn btn-primary like-button' %>
<% end %>

But first I need to be able to access @post in the partial, which is still not working and didn't find out why yet

app/views/posts/index.html.erb Outdated Show resolved Hide resolved
app/views/posts/index.html.erb Outdated Show resolved Hide resolved
app/views/posts/index.html.erb Outdated Show resolved Hide resolved
app/views/posts/partials/_unlike_button.html.erb Outdated Show resolved Hide resolved
fedesapuppo and others added 3 commits March 4, 2024 14:18
Co-authored-by: Tute Costa <tutecosta@gmail.com>
Co-authored-by: Tute Costa <tutecosta@gmail.com>
Copy link
Collaborator

@tute tute left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good!

app/helpers/posts_helper.rb Outdated Show resolved Hide resolved
app/views/posts/index.html.erb Outdated Show resolved Hide resolved
fedesapuppo and others added 3 commits March 4, 2024 15:46
Co-authored-by: Tute Costa <tutecosta@gmail.com>
Co-authored-by: Tute Costa <tutecosta@gmail.com>
@fedesapuppo fedesapuppo merged commit 5d55494 into main Mar 4, 2024
<div class="alert alert-info mt-4" role="alert">
<%= flash[:alert] %>
<% flash.each do |flash_type, message| %>
<div class="alert alert-info mt-4">
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<div class="alert alert-info mt-4">
<div class="alert alert-info <%= flash_type %> mt-4">

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants