Rendering partial problem

Can anyone help me?

I have a problem that when I click on the search button I get the
following error message:

ActionView::MissingTemplate in Searches#show

Showing C:/finalproject/app/views/searches/show.html.erb where line #3
raised:

Missing partial games/game with {:handlers=>[:erb, :builder, :coffee],
:formats=>[:html], :locale=>[:en, :en]}. Searched in:

  • “C:/finalproject/app/views”
  • “C:/Ruby/lib/ruby/gems/1.9.1/gems/kaminari-0.13.0/app/views”

I have the following in my show.html.erb:

Search

<%= render :partial => @search.games%>

Any ideas?

Thanks
R.Patrick

On Wed, Feb 22, 2012 at 2:02 PM, Roger P. [email protected]
wrote:

Missing partial games/game with {:handlers=>[:erb, :builder, :coffee],

Any ideas?

Thanks
R.Patrick

What do you have in your controller? Searches#show

Javier Q

Javier Q. wrote in post #1048286:

On Wed, Feb 22, 2012 at 2:02 PM, Roger P. [email protected]
wrote:

Missing partial games/game with {:handlers=>[:erb, :builder, :coffee],

Any ideas?

Thanks
R.Patrick

What do you have in your controller? Searches#show

Javier Q

class SearchesController < ApplicationController
def new
@search = Search.new
end

def create
@search = Search.new(params[:search])
if @search.save
redirect_to @search, :notice => “Successfully created search.”
else
render :action => ‘new’
end
end

def show
@search = Search.find(params[:id])
end
end

On Wed, Feb 22, 2012 at 2:15 PM, Roger P. [email protected]
wrote:

else
render :action => ‘new’
end
end

def show
@search = Search.find(params[:id])
end
end

If you see the log, the you’ll see a query ( the result of
Search.find(params[:id]),
after that you haven’t told rails what to do with it, so as you see on
you
create method
you’re being redirect to “@search” (that’s a sort of abreviation of what
you have on your routes.rb file)

You may want to do a respond_to block, try searching that on rails guide
or
try this tutorial
http://ruby.railstutorial.org/

Javier Q

Showing C:/finalproject/app/views/searches/show.html.erb where line #3
raised:

Missing partial games/game with {:handlers=>[:erb, :builder, :coffee],

What about Missing partial games/game (/views/games/_game.html.erb) ? :slight_smile:

Valery K. wrote in post #1048293:

Showing C:/finalproject/app/views/searches/show.html.erb where line #3
raised:

Missing partial games/game with {:handlers=>[:erb, :builder, :coffee],

What about Missing partial games/game (/views/games/_game.html.erb) ? :slight_smile:

in my games view folder I have the following:

index
new
show
edit
_form

I don’t really understand the missing partial part. I have already
uploaded my search_controller and show.html classes. I have below my
search.rb model file if it is of any use:

class Search < ActiveRecord::Base
attr_accessible :game_name, :console, :genre

def games
@games ||= find_games
end

private

def find_games
Game.find(:all, :conditions => conditions)
end

def name_conditions
[“games.game_name LIKE ?”, “%#{game_name}%”] unless game_name.blank?
end

def console_conditions
[“games.console LIKE ?”, “%#{console}”] unless console.blank?
end

def genre_conditions
[“games.genre LIKE ?”, “%#{genre}”] unless genre.blank?
end

def conditions
[conditions_clauses.join(’ AND '), *conditions_options]
end

def conditions_clauses
conditions_parts.map { |condition| condition.first }
end

def conditions_options
conditions_parts.map { |condition| condition[1…-1] }.flatten
end

def conditions_parts
private_methods(false).grep(/_conditions$/).map { |m| send(m)
}.compact
end

end

Hope this helps.

<%= render @search.games %>

means you have partial file:

---- /app/views/games/_game.erb.html

hello world!, i’m <%= game %> instance!


http://guides.rubyonrails.org/layouts_and_rendering.html

If you have an instance of a model to render into a partial, you can use
a shorthand syntax:

<%= render @customer %>
Assuming that the @customer instance variable contains an instance of
the Customer model, this will use _customer.html.erb to render it and
will pass the local variable customer into the partial which will refer
to the @customer instance variable in the parent view.

I literally just solved it before you posted this :slight_smile: thanks for all the
help, after reading a previous reply to my post it just clicked. Thanks
all.

On 23.02.2012, at 0:16, Roger P. wrote:

I don’t really understand the missing partial part. I have already
uploaded my search_controller and show.html classes. I have below my
search.rb model file if it is of any use:

<%= render @search.games %>

means you have partial file:

---- /app/views/games/_game.erb.html

hello world!, i’m <%= game %> instance!


http://guides.rubyonrails.org/layouts_and_rendering.html

If you have an instance of a model to render into a partial, you can use
a shorthand syntax:

<%= render @customer %>
Assuming that the @customer instance variable contains an instance of
the Customer model, this will use _customer.html.erb to render it and
will pass the local variable customer into the partial which will refer
to the @customer instance variable in the parent view.

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