Hi
I have routes defined like
map.resources :staff, :member => {:registration_completion => :put}
map.staff_registration ‘/staff_registration/:code’, :controller =>
‘staff’, :action => ‘registration’
And I have controller actions like
def registration
@user = User.find_by_perishable_token!(params[:code])
@staff = @user.staff
render :action => :registration, :layout => ‘registration’
end
And this render the file registration which is edit form The form is
<% form_for @user, :url => staff_registration_completion_url(@staff),
:html => {:method => :put} do |f| %>
<%end%>
And upon submission this goes to action
def registration_completion
@staff = Staff.find(params[:id])
@user = @staff.user
if @user.update_attributes(params[:user])
redirect_to login_url
else
flash.now[:error] = @user.errors.full_messages.join(“
”)
render :action => :registration,:layout =>
‘company_registration’
end
end
And my problem is before submitting the form the url is like
http://localhost:3000/registration/FFhJhsVz
But if in the registration_completion action if it capture any
error sure it will render else part That is registartyion action again
.Which is what I expect. But now the url is
http://localhost:3000/registration_completion/2/edit
My question is how can I make the url even if the update fails
to
http://localhost:3000/registration/FFhJhsVz .What changes should I
made to routes? Please help
Thanks
Tom