Ruby on Rails
Sunday, August 6, 2017
I'm using the regular _form.html.erb to create the record differently than the regular form In my edited _form.html.erb there's a ui which the controller in turn will use to populate the fields that normally would have appeared in the form I should have given it a custom name instead of just leaving it's name form, then i could have used it for editing With that form all changed up instead I wrote a dedicated edit form in which the user has access to the regular fields which would appear on the scaffold form that were poulated by the controller (repeating myself) Of course I should have left the original form alone and create a custom form instead of a custom edit form Even still I'm curious why this behaves the way it does
<%= form_for @press_release, :url => update_user_press_release_path(method: :patch, params[:artist_id]) do |f| %>
produces this html:
-- <%= form_for @press_release, :url => update_user_press_release_path(method: :patch, params[:artist_id]) do |f| %>
produces this html:
<form class="edit_press_release" id="edit_press_release_436" action="/user/press_releases/436/edit" accept-charset="UTF-8" method="post"><input name="utf8" type="hidden" value="✓" /><input type="hidden" name="_method" value="patch" /><input type="hidden" name="authenticity_token" value="..." />
the get that called the form was:
get: /user/press_releases/436/edit
and it's route is defined as:
get '/user/press_releases/:id/edit' => 'user_press_releases#edit', as: 'edit_user_press_release'
the custom patch route is:
patch '/user/press_releases/:id' => 'user_press_releases#update', as: 'update_user_press_release'
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/ea6a12c6-da50-4c20-afcd-14b4333a4e31%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment