That points to this action in my “post_controller.rb”
def search @post = Post.find_all_by_title(params[:title])
end
Which I think is assigning the @post variable with the results. But how
exactly can I get them to display? I made a dummy action in the
post_contoller.rb called “show_search” and a view called
“show_search.rhtml” what’s the last step to get the results to display?
That makes perfect sense. But, I just get a blank page when it comes to
the ruby code. Example:
did this display?
<% for post in @posts do %> Post Title:<%= post.title %> Created At: <%= post.date_created %>
<% end %>
That’s in the show_search.rhtml The “did this display?” part shows up,
but nothing below it. I double checked to make sure the form action tag
is now set to show_search, and it is. Any ideas?
That makes perfect sense. But, I just get a blank page when it comes to
the ruby code. Example:
did this display?
<% for post in @posts do %> Post Title:<%= post.title %> Created At: <%= post.date_created %>
<% end %>
That’s in the show_search.rhtml The “did this display?” part shows up,
but nothing below it. I double checked to make sure the form action tag
is now set to show_search, and it is. Any ideas?
Check you log files in the /log folder. See if it has anything useful.
That’s in the show_search.rhtml The “did this display?” part shows up,
but nothing below it. I double checked to make sure the form action tag
is now set to show_search, and it is. Any ideas?
def search @post = Post.find_all_by_title(params[:title])
end
<% for post in @posts do %> Post Title:<%= post.title %> Created At: <%= post.date_created %>
<% end %>
Notice the inconsistency? I would imagine you need to change @post to @posts in your controller method. I would think you’d be getting an
error message though… :: shrug ::
Eureka! I figured out from the log that it was trying to do an exact
match. When i searched for the whole title it worked! Now i just have to
figure out how to do partial matches. Any ideas? I’m also going to start
a new thread for this because I think this thread has gotten a bit too
long. Thanks guys.
Jasbur, you are into debugging technique now. You might want to toss a
breakpoint call into your controller and then take a look at @posts to
see if anything gets assigned.
cheers,
phil
Jasbur [email protected] wrote: I made the changes so they are all
listed as “@posts” still nothing
being returned.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.