ruby - Rails 4 Search Engine: Multiple Params -
i'm new rails , @ moment coding first app.
created search usernames of users, since i've added tagging system (using 'acts_as_taggable_on' gem), want implement in search functionality.
i've tried several times now, got argument error (either 0 1 or 2 1).
that how target user objects tag params:
# find users of specified tags: user.tagged_with(["awesome", "cool"], :any => true, :wild => true)
user model
acts_as_ordered_taggable # search def self.search(search) if search where(["username ?", "%#{search}%"]) else end end # search tags def self.searchtags(searchtags) if searchtags tagged_with(["#{searchtags}"], :any => true, :wild => true) else none end end
users controller
def index @users = user.search(params[:search]) @tagged_users = user.searchtags(params[:searchtags] end
user index view
= form_tag users_path, :method => 'get' = text_field_tag :search, params[:search] = submit_tag "search" = form_tag users_path, :method => 'get' = text_field_tag :searchtags, params[:searchtags] = submit_tag "search tags" - @users.each |user| = image_tag gravatar_for user if user.use_gravatar == true = image_tag user.avatar_filename.url if user.use_gravatar == false %h2= link_to user.username, user %p= link_to "favorite", userfavorite_user_path(user, type: "favorite"), method: :get %p= link_to "unfavorite", userfavorite_user_path(user, type: "unfavorite"), method: :get %p= user.tag_list - @tagged_users.each |user| = image_tag gravatar_for user if user.use_gravatar == true = image_tag user.avatar_filename.url if user.use_gravatar == false %h2= link_to user.username, user %p= link_to "favorite", userfavorite_user_path(user, type: "favorite"), method: :get %p= link_to "unfavorite", userfavorite_user_path(user, type: "unfavorite"), method: :get %p= user.tag_list
hope can me finding solution, thanks.
i not quite sure, i've seen same problems here before. reason incomatiability of versions of 'acts_as_taggable_on' gem rails version. wanted add comment post, unfortunately, still not permitted account. may find solutions here agged_with(params[:skill]) argumenterror: wrong number of arguments (given 2, expected 1)
Comments
Post a Comment