Topic: Help Rail for Zombies

Hello,

1st of all I'm a noob in the web applications, I begin with RoR due to there are a lot of positive comments about it. Till now I'm just doing the Rails For Zombies tutorial to have an idea (of course i've done tryruby, too).

My question is about the exercise 3 from lab 4, I've passed it but noticed that the entry that I've created is repeated twice, am I doing something wrong?

Statement.
"Write a create action that will create a new Zombie and then redirect to the created zombie's show page"

Zombies
id    name    graveyard
1    Ash    Glen Haven Memorial Cemetary
2    Bob    Chapel Hill Cemetary
3    Jim    My Fathers Basement

params = { :zombie => {:name => 'Gregg', :graveyard => 'TBA'} }

/zombies/create.html.erb
<h1>ZOMBIE CREATED!</h1>

My Solution.

def create
   Zombie.create( params[:zombie] );
   redirect_to(zombies_path);
end

Result.

Redirected to: http://example.org/zombies

Zombies
id    name    graveyard
1    Ash    Glen Haven Memorial Cemetary
2    Bob    Chapel Hill Cemetary
3    Jim    My Fathers Basement
4    Gregg    TBA
5    Gregg    TBA

You see the Gregg zombie twice?

Thx in advance and regards,
Daniel.

Last edited by dbranco (2011-01-28 05:53:06)

Re: Help Rail for Zombies

It asks you to redirect to zombie's show page, then:

 
def create
  @zombie = Zombie.new(params[:zombie])
  
  if @zombie.save
    redirect_to zombie_path(@zombie)
  else
    render :new
  end
end

not zombies_path