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 "+@name.inspect
end
end
===========================index.html.erb
------------------
<CENTER><h1>Search Here</h1>
<br>
<%= form_tag :action =>"show"%>
<%= text_field_tag "q",""%>
<%= submit_tag "Go...."%>
<br>
</CENTER>
===========================show.html.erb
------------------
<h1><%=@q%></h1>
<br><br>
<%= @name.each do |h|%>
<%=h.name%>
<%=h.age%>
<%=h.gender%><br>
<%end%>
<br><br>
<%= link_to "back", :action=>"index"%>
===========================
Attachments:
http://www.ruby-forum.com/attachment/5965/search.jpg
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.
On 25 February 2011 11:26, Vijay Ra <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> 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 "+@name.inspect > end > > end > ===========================> index.html.erb > ------------------ > <CENTER><h1>Search Here</h1> > <br> > <%= form_tag :action =>"show"%> > <%= text_field_tag "q",""%> > <%= submit_tag "Go...."%> > <br> > </CENTER> > ===========================> show.html.erb > ------------------ > <h1><%=@q%></h1> > <br><br> > <%= @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> <%=h.name%> > <%=h.age%> > <%=h.gender%><br> > <%end%> > <br><br> > <%= link_to "back", :action=>"index"%> > ===========================> > Attachments: > http://www.ruby-forum.com/attachment/5965/search.jpg > > > -- > Posted via http://www.ruby-forum.com/. > > -- > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. > For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
>> <h1><%=@q%></h1> >> <br><br> >> <%= @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. > > ColinThanx u r god ;) -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 25 February 2011 13:58, Vijay Ra <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:>>> <h1><%=@q%></h1> >>> <br><br> >>> <%= @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 ;)I don''t think I would quite that far, but I am glad to be of help Colin -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.