ruby-on-rails – form_for action在编辑操作期间将.id附加到URL
发布时间:2020-12-17 01:59:11 所属栏目:百科 来源:网络整理
导读:我有一个表单,当我在编辑操作期间提交时,如果不应该将.id附加到post操作.表单在创建期间正常工作但不更新. 这是编辑期间的URL发布操作. http://localhost:3000/members/1/profile.1 这是我的形式 %= form_for([@member,@profile]) do |f| %%= f.label :first
我有一个表单,当我在编辑操作期间提交时,如果不应该将.id附加到post操作.表单在创建期间正常工作但不更新.
这是编辑期间的URL发布操作. http://localhost:3000/members/1/profile.1 这是我的形式 <%= form_for([@member,@profile]) do |f| %> <%= f.label :first_name %><br /> <%= f.text_field :first_name,{:class => "txt-field-short"} %><br /><br /> <%= f.label :last_name %><br /> <%= f.text_field :last_name,{:class => "txt-field-short"} %><br /><br /> <p><%= submit_tag "Create Profile" %></p> <% end %> 这是我这个协会的路线. resources :members do resource :profile resources :orders end 这是我的配置文件控制器中的创建,编辑和更新操作 def create @member = current_member @profile = @member.build_profile(params[:profile]) respond_to do |format| if @profile.save format.html { redirect_to(member_profile_path,:notice => 'Profile was successfully created.') } else format.html { render :action => "new" } end end end def edit @member = current_member @profile = @member.profile end def update @member = current_member @profile = @member.profile respond_to do |format| if @profile.update_attributes(params[:profile]) format.html { redirect_to(member_profile_path(@profile),:notice => 'Your profile was successfully updated.') } else format.html { render :action => "edit" } end end end 什么将profile.id添加到帖子中? 解决方法
我相信这有时会发生嵌套的奇异资源.尝试使用不同的form_for格式:
form_for @profile,:url => member_profile_path(@member) do |f| (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |