I have footers in which the form from contacts_controller rendered,

_runew.html.erb

 <footer> <div class="container"> <div class="col-md-6 col-md-push-0 col-sm-6 col-sm-push-0 col-xs-10 col-xs-push-1"> <div class="footer_contacts"> <h3>Свяжитесь с </br> нами</h3> <address>Адрес: проспект Павла Тичини, 1в</address> <address>Тел.: <a href="tel:+7777777777">+7777777777</a></address> <address>E-mail: <a href="mailto:info@ipass.com.ua">info@ipass.com.ua</a></address> <div class="social_icons"> <a href="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a> <a href="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a> <a href="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a> <a href="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a> </div> </div> </div> <div class="col-md-6 col-sm-6 col-xs-12"> <div class="message_form"> <div class="input_group"> <%= simple_form_for @contact, url: contacts_path, :method => :post do |f| %> <%= f.input :nickname, placeholder: 'Имя', :error => false, :label => false %> <%= f.input :mail, placeholder: 'Почта', :error => false, :label => false %> <%= f.input :theme, placeholder: 'Тема', :error => false, :label => false %> </div> <%= f.input :text, placeholder: 'Текст сообщения', :error => false, :label => false, as: :text %> <%= f.button :submit, 'Отправить' %> <% end %> <div class="clear"></div> </div> </div> </div> </footer> 

Here is the controller for this footer:

contacts_controller.rb

 class ContactsController < ApplicationController def index @contacts = Contact.all end def new @contact = Contact.new end def show @contact = Contact.find(params[:id]) end def create @contact = Contact.new(contact_params) if @contact.save redirect_to :root ContactsMailer.sample_email(@contact).deliver_now end end private def contact_params params.require(:contact).permit(:nickname, :mail, :theme, :text) end end 

I have this footer rendered, for example here: view / ru / index.html.slim, and this controller:

  class RuController < ApplicationController def index @contact = Contact.new if @contact.save redirect_to :root ContactsMailer.sample_email(@contact).deliver_now end end def solution @contact = Contact.new if @contact.save redirect_to :root ContactsMailer.sample_email(@contact).deliver_now end end def rates @rurates = RuRate.all @contact = Contact.new if @contact.save redirect_to :root ContactsMailer.sample_email(@contact).deliver_now end end def contact @contact = Contact.new if @contact.save redirect_to :root ContactsMailer.sample_email(@contact).deliver_now end end end 

The problem is that I cannot make a private method to check the parameters in another controller, and if the form is unsuccessful, it redirects to /contact with an error, but it is necessary to redirect to :root , but if I write like this, it turns out to be an infinite loop ...

  • I can not make a private method to check the parameters in another controller - this is already a strange desire. For what? - D-side

0