I have a form where, when I submit during the editing action, the .id is added to the postulate when it shouldn't. The form works correctly during creation, but is not updated.
Here's the action of the url while editing.
http: // localhost: 3000 / members / 1 / profile.1
Here is my form
<%= 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 %>
This is my route for this association.
resources :members do
resource :profile
resources :orders
end
Here are my steps for creating, editing and updating in the profile controller
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
What adds profile.id to the post action?
source
share