Ruby on Rails
Tuesday, February 4, 2020
So far, I don't get any results returned
user.rb:
searchkick word_middle: ['full_name', 'description', 'interests']
def full_name
[first_name, last_name].join(' ')
end
def search_data
{
full_name: full_name,
description: description,
interests: interests
}
end
def full_name
[first_name, last_name].join(' ')
end
def search_data
{
full_name: full_name,
description: description,
interests: interests
}
end
world_controller.rb
def search
@terms=params[:terms]
search = params[:terms].present? ? params[:terms] : nil
@users = if search
User.search(search)
end
end
@terms=params[:terms]
search = params[:terms].present? ? params[:terms] : nil
@users = if search
User.search(search)
end
end
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/ec49e885-5b99-41f0-ac42-fa820743064e%40googlegroups.com.
Ruby on Rails
Sunday, February 2, 2020
world_controller.rb
@users = User.search(params[:terms]).where("confirmed_at is not null")
search.html.erb
<h3><%= (t 'search_results_for') %> <%= @terms %></h3>
<ul>
<% @users.each do |u| %>
<li>
<%= link_to "#{u.first_name} #{u.middle_name} #{u.last_name}", page_path(name: u.name) %>
<% ua=u.addresses.where("current=?", true) %>
<% if ua.country=="US" %>
<%= ua.city %>, <%= ua.state %> <%= ISO3166::Country.find_country_by_alpha2(ua.country) %>
<% else %>
<%= ua.city %>, <%= ISO3166::Country.find_country_by_alpha2(ua.country) %>
<% end %>
</li>
<% end %>
</ul>
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/483fbefa-8bdc-41a4-b1d4-6573528a1e37%40googlegroups.com.
Ruby on Rails
I put a search form in my layout where the search field is named "terms" but then I get an unpermitted parameters for 'term' Do I need to declare term as an attr_accessor and use the :user in strong params in my world controller because I'm searching the User model
-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/8704a48b-9177-4a24-9b3b-c0073fa22168%40googlegroups.com.
Subscribe to:
Posts (Atom)