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
Post a Comment