I am using Sunscot Solar in my rail app to conduct a search and I have to search through value One aspect is for the establishment between the middle. How do I create labels to use for row values in scenes? It suggests using conditional statement, but I'm not sure how I can do it.
For example:
0.0..75.0 75.0 Etc. 150.0..225.0 225.0..300.0
etc .. I want them to display them:
$ 0 - $ 75 $ 75 - $ 150 $ 150 - $ 225 $ 225 - $ 300
Can someone help me with this? Thank you.
/models/listing.rb
Searchable: auto_index = & gt; True,: auto_remove = & gt; True Text: Title, Promotion = & gt; 5 text: marker_list ,: boost = & gt; 2 strings: marker_list ,: multiple = & gt; True,: archived = & gt; True double: End of value
/ controllers / list_controllerRbb
DIF index @ listing = listing.order (' Created_at desc '). Page (param [: pg]). Per_page (60) @ Search = Listing. Solr_search Complete Text Parameters [: Listing] Aspect: Price, Category: & gt; 0..2000,: Category_Internval = & gt; 75 (with: value, range.new (* parameter [: value_range] .split (".."). Map (and: to_i)) if the query [: value_range]. Display? End @results = listing Where (id: @ search.results.map (& amp; id)) page (Param [: page]). Per_page (60) end
/ views / listings / Index.html.erb
& lt;% for @ search.facet ((value) .rows%> & lt; span class = "bprice" & Gt; & lt;% = link_to row.value ,: price_range = & gt; Row.value ,: search = & gt; consulting [: listings]%> & gt; & gt; & gt; & lt;% end % & Gt;
Is this the only regex replacement?
Try it:
new_string = old_string.gsub (/ \ 0. \ ./, "$ -") .gsub (/ \. /, "$") # Old_string = "0.0..75.0" #new_string = "0 $ - 75 $"
This means your code will be
< Code> & lt;% = link_to (line .value) .to_s.gsub (/ \ 0. \. \ ./, "$ -") .gsub (/ \. 0 /, "$") ,: price_range = & gt; Row.value ,: Search = & gt; Consultation [: listing]% & gt;
Comments
Post a Comment