Menu icon Foundation
Saving form fields from rails form

<!-- Heres Hello.html.erb -->
<html>
  <body>
        <nav class="top-bar" data-topbar>
            <ul class="title-area">
                <li class="name">
                    <h1><a href="#">Hello World!</a></h1>
                </li>
                <li class="toggle-topbar menu-icon"><a href="#"><span>Menu</span></a></li>
            </ul>
        <ul class="right">
            <li class="has-form">
                <div class="row collapse">
                    <div class="large-8 small-9 columns">
                        <input type="text" placeholder="Find Stuff" id=:Find_Stuff > 
                    </div>
                    <div class="large-4 small-3 columns">
                      <%= link_to "", :controller => 
            'salutation', :action =>'hello', 
             :class=>"alert button expand"  %>
                    <a href="#" class="alert button expand">Search</a>    
                    </div>
                </div>
            </li>
        </ul>
        </section>
        </nav>
    <p>
      <% if [email protected] %>
         <p>Nothing to Search</p>
         <p>heres test <%= @test %></p>
      <% else %>
        <p><%= @test %></p> 
     <% end %>
    </p>
    </body>
</html>
            
Controller follows

<Salutation COntroller follows 
class SalutationController < ApplicationController
  
  def new
    @test = ''
  end
  
  def hello
    @message = 'Hello World!'
    @test = params[:salutation][:Find_Stuff]
  end 
end

         

Searchform

Hi, all:

I was trying to read the input field in the search field of the form - code is straight from the search form code
in the foundation examples. The field I want to read is the input field - plcaeholder "Find Stuff". I tried to use
params but was unsuccessful. how does the foundation pass parameters from the input.html.erb from to the
controller? I tried outputting the form field Find_Stuff, but was unsuccessful. The code is as above. thanks for
cooperation

rails4Foundationinput field

<!-- Heres Hello.html.erb -->
<html>
  <body>
        <nav class="top-bar" data-topbar>
            <ul class="title-area">
                <li class="name">
                    <h1><a href="#">Hello World!</a></h1>
                </li>
                <li class="toggle-topbar menu-icon"><a href="#"><span>Menu</span></a></li>
            </ul>
        <ul class="right">
            <li class="has-form">
                <div class="row collapse">
                    <div class="large-8 small-9 columns">
                        <input type="text" placeholder="Find Stuff" id=:Find_Stuff > 
                    </div>
                    <div class="large-4 small-3 columns">
                      <%= link_to "", :controller => 
            'salutation', :action =>'hello', 
             :class=>"alert button expand"  %>
                    <a href="#" class="alert button expand">Search</a>    
                    </div>
                </div>
            </li>
        </ul>
        </section>
        </nav>
    <p>
      <% if [email protected] %>
         <p>Nothing to Search</p>
         <p>heres test <%= @test %></p>
      <% else %>
        <p><%= @test %></p> 
     <% end %>
    </p>
    </body>
</html>
            
Controller follows

<Salutation COntroller follows 
class SalutationController < ApplicationController
  
  def new
    @test = ''
  end
  
  def hello
    @message = 'Hello World!'
    @test = params[:salutation][:Find_Stuff]
  end 
end

         

Searchform

Hi, all:

I was trying to read the input field in the search field of the form - code is straight from the search form code
in the foundation examples. The field I want to read is the input field - plcaeholder "Find Stuff". I tried to use
params but was unsuccessful. how does the foundation pass parameters from the input.html.erb from to the
controller? I tried outputting the form field Find_Stuff, but was unsuccessful. The code is as above. thanks for
cooperation

Alexander Assimidis over 5 years ago

Are you able to get what was insert in your field?

render text: params[:post].inspect

If this answer was helpful pls click the button down.

Alexander Assimidis over 5 years ago

Then you have to redirect the entered search string like:

redirect_to @Find_Stuff and give it to your search engine

Ravi K over 5 years ago

Dear:

I pasted this line in the view, before the tag, and I got a nil, in the rendered view, when I
entered "test" in the search box, and pressed the search button,

thanks
this is the code fragment:

<% if [email protected]_Stuff %>
Nothing to Search
heres test <%= @Find_Stuff %>
<% else %>
<%= @Find_Stuff %>
<% end %>

<%= render text: params[:post].inspect %>
</p>
</body>

Ravi K over 5 years ago

Apologies for the third post:
I do not have a model with search string for this stub - and theres only a controller here that
has a view. So theres only a search field that I would like to view - and pass on to a search engine, I
don't want to save the search string.

thanks

Ravi K over 5 years ago

I modified the controller to have a new show method:
with the following code:

def search

redirect_to :back, alert: "Hello, World!"

end

this is just to test whether the alert shows or, no, I don't
get any alert message, and we return to the previous
screen, the code in the view is as follows:

<%= link_to "Search", :controller =>
'salutation', :action =>'search',
:class=>'alert button expand' %>

                </div>

This takes the viewer to search method in the salutation controller, of course, when I change
the redirect_to, in the controller to the following:

redirect_to :back, @Find_Stuff, as you recommended, theres nothing on the screen, and the
variable is not passed, and suggestions, thanks,