Condition based on matched text on the current page in RAILS -


hi possible have condition in rails check if particular html text exist?

approach (but in capybara):

find("a", :text => "matched text") 

i want not in testing.

for example have text "hello" in current page

<b>hello world</b> 

and want put condition this:

<% if current_page?(question_path) && request.path.include?('hello') %>    <b>got <b/>  <% else %>  <% end %> 

but code above doesn't work, checks whether hello inside path itself. satisfied if route http://localhost:3000/hello . want check not in path inside rendered page.

if understand correctly, assign random variable hello world string, compare elsewhere:

<% random_string = 'hello world' %> <b><%= random_string %> <% if current_page?(question_path) && random_string.include?('hello') %>   <b>got it<b/> <% else %>   ... <% end %> 

Comments

Popular posts from this blog

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

html - How to style widget with post count different than without post count -

url rewriting - How to redirect a http POST with urlrewritefilter -