I am new in Ruby on Rails and I want to pass variable from index.html.erb to search.html.erb file and use the variable in ruby code.
In other words, I have text and submit button in index.html.erb. If I type in text and press the button it will pass what in the text to search.html.erb and use that text in ruby code
index.html.erb
<h1>Twitter</h1>
<html>
<form>
<input type = 'search' name = 'search' /></br>
<a href=/home/search><button type="button">Search</button></a>
</form>
</html>
search.html.erb
<h1>Twitter</h1>
<html>
<%=
require 'twitter'
client = Twitter::REST::Client.new do |config|
config.consumer_key = "xxxxxxxxxxxxxxxxxx"
config.consumer_secret = "xxxxxxxxxxxxxxxxxx"
config.access_token = "xxxxxxxxxxxxxxxxxx"
config.access_token_secret = "xxxxxxxxxxxxxxxxxx"
end %>
<ul>
<%=client.search("**I want variable here**", result_type: "recent").take(5).collect do |tweet| %>
<li><%= "#{tweet.user.screen_name}: #{tweet.text}" %> </li>
<% end %>
</ul>
</html>
Thank you
@client.