Ruby on rails - using submit to get different page -
Ruby on rails - using submit to get different page -
i've little problem. i'm doing little project , i'm stuck on simple, can't past throug it. i've form, , after submiting it, redirects me view 'show', i've wanted alter redirected me 'show15'. i'm preety new rails, may little stupdi question, apreciate help. in advance.
that's form:
<%= form_for(@patient) |f| %> <% if @patient.errors.any? %> <div id="error_explanation"> <h2><%= pluralize(@patient.errors.count, "error") %> prohibited patient beingness saved:</h2> <ul> <% @patient.errors.full_messages.each |msg| %> <li><%= msg %></li> <% end %> </ul> </div> <% end %> <div class="field"> <%= f.label :imie %><br /> <%= f.text_field :imie %> </div> <div class="field"> <%= f.label :nazwisko %><br /> <%= f.text_field :nazwisko %> </div> <div class="field"> <%= f.label :adres %><br /> <%= f.text_field :adres %> </div> <div class="field"> <%= f.label :pesel %><br /> <%= f.text_field :pesel %> </div> <div class="field"> <%= f.label :telefon %><br /> <%= f.text_field :telefon %> </div> <div class="field"> <%= f.label :doktor %><br /> <%= collection_select(:imie, :imie, doctor.all, :id, :full_name) %> </div> <div class="actions"> <%= submit_tag "edytuj", class: "show15", value: 'edytuj' %> </div> <% end %>
assuming form take create action within patients controller. need redirect custom action within create action when patient saved within database.
def create @patient = patient.new patient_params if @patient.save redirect_to your_path_of_show15 else render new end end
i'm assuming within create action have redirect_to @patient rails takes show action of newly created patient. more info on how routes work in rails refer rail guides routing
ruby-on-rails
Comments
Post a Comment