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

Posting from tag pages not tagging properly #6592

Closed
steviepubliclab opened this issue Nov 1, 2019 · 14 comments · Fixed by #7278
Closed

Posting from tag pages not tagging properly #6592

steviepubliclab opened this issue Nov 1, 2019 · 14 comments · Fixed by #7278
Labels
bug the issue is regarding one of our programs which faces problems when a certain task is executed fto-candidate issues which are meant to be solved by first timers but aren't well-formatted yet help wanted requires help by anyone willing to contribute

Comments

@steviepubliclab
Copy link
Contributor

Hello!
I was trying to post a new research note from a tag page (https://publiclab.org/tag/oil-and-gas-water-trio) using this button:
Screen Shot 2019-11-01 at 2 07 08 PM

But the note it created didn't have the tag for the page:
Screen Shot 2019-11-01 at 2 06 20 PM

Might be a bug?

@steviepubliclab steviepubliclab added the bug the issue is regarding one of our programs which faces problems when a certain task is executed label Nov 1, 2019
@nicoleiocana
Copy link
Contributor

Can you offer some insight as to how you replicated the error? When I go to the url you provided: https://publiclab.org/tag/oil-and-gas-water-trio my screen does how have the "New Post + " button. It shows this:

publiclab_url

@steviepubliclab
Copy link
Contributor Author

steviepubliclab commented Nov 4, 2019 via email

@nicoleiocana
Copy link
Contributor

nicoleiocana commented Nov 4, 2019 via email

@steviepubliclab
Copy link
Contributor Author

steviepubliclab commented Nov 4, 2019 via email

@jywarren
Copy link
Member

jywarren commented Nov 4, 2019 via email

@jywarren
Copy link
Member

jywarren commented Nov 4, 2019

This is suffering from the same problem as #6675! I've put a solution there, and this would make a great FTO!

Short version: we should replace tag.name with params[:id]!


This has been marked as a good candidate for becoming a first-timers-only issue like these, meaning that it's simple, self-contained, and with some extra formatting, could be a great entry point for a new contributor. If you're familiar enough with this code, please consider reformatting or reposting it as a first-timers-only issue, and then ping @publiclab/reviewers to get it labelled. Or, if this is not your first time, try to solve it yourself!

@jywarren jywarren added fto-candidate issues which are meant to be solved by first timers but aren't well-formatted yet help wanted requires help by anyone willing to contribute labels Nov 4, 2019
@nicoleiocana
Copy link
Contributor

Can this be assigned to me? I am currently working on the fix, except to simplify the code, I:

replaced tag.name with @title since it is referenced in the if-statement.

This fix passed my first test (the current issue #6592). I am now testing to see if my refactored code passes the following:

Since we didn't use tag.name and there are no references to the @tag instance variable in the show.html.erb file, I am certain that we do not need the @tag in the tag_controller.rb.

Let me know if you will allow me to go ahead with my fix (or have any criticism) please? Thanks in advance.

@jywarren
Copy link
Member

jywarren commented Nov 4, 2019 via email

@nicoleiocana
Copy link
Contributor

nicoleiocana commented Nov 4, 2019

Hello. The @title = params[:id] from the tag_controller.rb in the show method (sorry, I should've specified this) returns the exact tag name string, so it is the correct capitalization (or not depending on the tag name). Therefore, regarding only the show method, it would make sense to delete the @tag = Tag.find_by(name: params[:id]) in the tag_controller.rb because:

  1. It was returning nil; hence, why were seeing in this issue and
  2. because the @tag instance variable was nowhere in the show.html.erb file.

And yeah, in the #6675 issue, I will refactor the code and then test the file where @tag is deleted from only the show method. It already worked for this isssue (and I already submitted a PR), so I am confident it will work in the other issue.

@nicoleiocana
Copy link
Contributor

@jywarren
You were totally right. Deleting the @tag instance variable didn't pass the tests. I kept it, only added the @title in the show.html.erb file for the "New Post +" issue and submitted that PR. Thanks for the insight, I appreciate it.

I'll make a PR for #6675 and refactor the code; in particular, editing out all of the tag.name's and replacing them with @title's.

@jywarren
Copy link
Member

jywarren commented Nov 4, 2019 via email

@nicoleiocana
Copy link
Contributor

I completely agree with you on all points. Let me break down my logic to see if it is parallel with your notions:

The confusion occurs for @title when the original code for the show.html.erb in the tag folder utilizes here:
<h1 style="margin-top:6px;"><%= @title %></h1>
versus
<% if current_user && current_user.following(@title) %>
Like you mentioned, we should keep the logic of the header title different from the parameter passed in from the previous link. Therefore, all of the code referring to the parameter passed in with be changed to params[:id], all references to the tag name as the title in sections of the page will remain @title. This solution will be solved in a PR for issue #6675.

@jywarren
Copy link
Member

jywarren commented Nov 5, 2019

Yes, that's exactly right! Thank you so much for working through this! I also think this applies for #6677, what do you think?

@nicoleiocana
Copy link
Contributor

nicoleiocana commented Nov 5, 2019

Yes, you are right. Since I submitted a PR for the similar issue more recent than this one, my comment above applies as of now:

the code referring to the parameter passed in with be changed to params[:id], all references to the tag name as the title in sections of the page will remain @title.

In particular, the @title instance variable only refers to the HTML headers where applicable.

You are very much welcome. =)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug the issue is regarding one of our programs which faces problems when a certain task is executed fto-candidate issues which are meant to be solved by first timers but aren't well-formatted yet help wanted requires help by anyone willing to contribute
Projects
None yet
3 participants