开发者

Remote form submission not working with namespace on Rails3

I am working on a project which allow people to upload a personal profile, including projects and updates related to their project.

Everything is working fine except that I would like to submit my form using :remote =>开发者_StackOverflow社区 true but i have no way to get it to work. I could use classic jquery/ajax to submit the form, but the Rails3 UJS is great !

updates_controller.rb

def create
 @update =  Update.new(params[:update])
 @update.user_id = current_user.id
 @update.project_id = params[:project_id]    

if @update.save
  respond_to do |format|
    format.js { render :nothing => true } 
  end
 end
end

_form.html (views)

<%= form_for([@project, @update], :url => profile_project_updates_path, :remote => true) do |f| %>

I tried also

<%= form_for([:profile, @project, @update], :remote => true) do |f| %>

routes.rb

namespace :profile do
  resources :projects, :only => [:show, :index, :edit] do
    resources :updates
  end
end

If anyone has an idea how to get the :remote => true to work here , it will be great !!

Thanks to all the Stack Overflow community for all the precious resources I found here so far.

_Clement


Did you initialized @project in new action of controller?

Try to replace

<%= form_for([@project, @update], :url => profile_project_updates_path, :remote => true) do |f| %>

with

<%= form_for([@update.project_id, @update], :url => profile_project_updates_path, :remote => true) do |f| %>

What is the server response when you submit the form?

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜