Hash objects not display properly

Hello I m newbie in rails
i create simple application which take data from user search in DB and
show output but it not show properly it’s show what i want plus it show
whole hash elements which is i don’t want. i am attaching output screen
shot here

Here r my app files

============================
class SearchController < ApplicationController

def index
@q=params[:q]
end

def show
@q=params[:q]
@name = Frnd.find(:all, :conditions=>{:name=>@q})

puts "name is "[email protected]

end

end

index.html.erb

Search Here


<%= form_tag :action =>"show"%> <%= text_field_tag "q",""%> <%= submit_tag "Go...."%>
============================ show.html.erb ------------------

<%[email protected]%>



<%= @name.each do |h|%> <%=h.name%> <%=h.age%> <%=h.gender%>
<%end%>

<%= link_to "back", :action=>"index"%> ============================

On 25 February 2011 11:26, Vijay Ra [email protected] wrote:

end

show.html.erb

<%[email protected]%>



<%= @name.each do |h|%>

You don’t want <%= on the line above, that causes it to display the
return value from the call. You just want
<% @name.each do |h| %>
so that it will run the code but not display the result of this line.

Colin

On 25 February 2011 13:58, Vijay Ra [email protected] wrote:

Thanx u r god :wink:

I don’t think I would quite that far, but I am glad to be of help

Colin

<%[email protected]%>



<%= @name.each do |h|%>

You don’t want <%= on the line above, that causes it to display the
return value from the call. You just want
<% @name.each do |h| %>
so that it will run the code but not display the result of this line.

Colin

Thanx u r god :wink:

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs