views:

11

answers:

1

Hello,

Here's what I'm trying to do...

Controller

def create
.
.
 if @project.save
  format.js  {  @project }
 end

end

View

window.location = "<%= redirect_to(@project, :notice => 'Project was successfully created.') %>";

In Sum,using AJAX to create a project. When the create is done, I want to redirect the user to the project..

This isn't working... How can I pass the project from the controller to the View?

Thanks

A: 

Hi try

def create
 .
 .
 if @project.save
  format.js  {redirect_to(@project, :notice => 'Project was successfully created.'}
 end

end

or if you whant execute action inside create.js.erb

def create
 .
 .
 if @project.save
  format.js  
 end

end
Bohdan Pohorilets