I want to set my tag with acts-as-tagable-on

Asked 2 years ago, Updated 2 years ago, 48 views

I would like to set my tag in acts-as-tagable-on and display the posts tagged with it, but if I set more than one, it will no longer be displayed.What should I do to be able to handle multiple settings?If you know anything, please reply or commentm(__)m

#my tag settings are now available on the edit account page of the device.

<%=form_for(resource, as:resource_name, url:registration_path(resource_name), html:{method::put})do|f|%>
  <%=render "device/shared/error_messages", resource:resource%>

omission

  <%=text_field_tag'user[tag_list]', resource.tag_list.join(", "), placeholder: "You can enter multiple tags separated by tags "",""%>

  <div class="actions-edit">
    <%=f.submit "Edit Complete"%>
  </div>
<%end%>

  <%=link_to "back", :back, class: "linkto-edit"%>
@questions=Question.tagged_with("#{current_man.tag_list}").page(params[:page])
#displaying
    <%@questions.each do | q | %>
        <hr>
        <div class="data">    
            <h3><%=q.title%>/h3>
    <%end%>

<div class="bootstrap">
     <%=paginate@questions%>
</div>

ruby-on-rails ruby

2022-09-30 19:21

1 Answers

tagged_with("#{current_man.tag_list}") is trying to find a tag that exactly matches the entire tag_list string, so you need to pass it in an array like tagged_with(current_man.tag_list).

tagged_with (current_man.tag_list, match_all:true) or tagged_(curred)tagged_(curred) as described in https://github.com/mbleigh/acts-as-taggable-on#finding-tagged-objects and tagged_(curred, true)orturred_(curred_(curue)turtain_Try specifying an option such as de>.


2022-09-30 19:21

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.