开发者

Chrome browser can't find partial

I use the following in my controller to add tasks to my project model using ajax.

def task_add
    project = Project.find(params[:project])
    @task = ProjectTask.new(:description => params[:description])
    project.project_ta开发者_如何学Pythonsks << @task
    render :partial => 'task'
end

and my ajax call:

$('#task-add').click(function(){
    var taskDesc = $('#task-description').val();

    $.ajax({
        type: "POST",
        url: "/project_task_add",
        data: ({project:<%= @project.id %>, description:taskDesc}),
        success: function(data){
            var data = $('<div/>').append(data);
            $('#tasks').append($('#new-task', data).html());
        }
    });         
});

It works fine in Firefox but Chrome gives the following error:

Failed to load resource: the server responded with a status of 500 (Internal Server Error)

Digging deeper in the chrome dev tools I find the following response:

<h1>Template is missing</h1>
<p>Missing partial projects/task with {:locale=&gt;[:en, :en], :formats=&gt;[:js,            :&quot;*/*&quot;], :handlers=&gt;[:erb, :rjs, :rhtml, :builder, :rxml]} in view paths &quot;/home/user/apps/my_app/app/views&quot;, &quot;/usr/lib/ruby/gems/1.8/gems/devise-1.1.5/app/views&quot;</p>

The _task.html.erb partial exists under /views/projects/ and Firefox renders it just fine. I don't understand what's different in Chrome... any ideas?


the method of the request is :js. I think rails is try to render _task.js.rjs not _task.html.erb . You could explicit It

render :partial => 'projects/task.html.erb'

but i think that you could change the view from wich request is generated so that they dont have params method js Or render an ajax response.

post your view if you want more help!


This is expecting your partial to be called app/views/projects/task.js.erb (as figured out by the formats part of your error, not app/views/projects/task.html.erb. You probably only have the html partial defined.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜