Jeremy Knees
Jeremy Knees

Reputation: 662

Console to experiment with RoR helpers

Is there an environment where I can experiment with Rails helpers to create tags? I tried in the rails console but the functions seem not to be defined there. What I want is type this and get the output this would generate in a kind of REPL.

<%= form_tag(search_path, :method => "get") do %>
  <%= label_tag(:q, "Search for:") %>
  <%= text_field_tag(:q) %>
  <%= submit_tag("Search") %>
<% end %>

Upvotes: 0

Views: 73

Answers (1)

techMonster
techMonster

Reputation: 226

This should work:

helper.form_tag("/hello", :method => "get") do
    helper.label_tag(:q, "Search for:")
    helper.text_field_tag(:q)
    helper.submit_tag("Search")
end

You can try this out in rails console.

Upvotes: 2

Related Questions