У меня есть форма с жемчужиной simple_form. если я цифра URL-адрес в браузере с тэгом якорной он работает:рельсы визуализации действия с якорем
localhost:3000/contacts/#new_contact #show me the correct form in the page
это мой контроллер:
class ContactsController < ApplicationController
def index
@message = Contact.new()
end
def create
@message = Contact.new(msg_params)
@message.request = request
if @message.deliver
redirect_to contacts_path , flash: { success: 'Ok' }
else
render action: :index #how can i render the new_contact anchor??
end
rescue ScriptError
redirect_to contacts_path , flash: { error: 'spam' }
end
private
def msg_params
params.require(:contact).permit(:name,:email,:message,:spam)
end
end
это моя форма:
<%= simple_form_for @message, defaults: { label: false} do |f| %>
<%= f.input :name %>
<%= f.input :email %>
<%= f.input :message, :as => :text,input_html: { rows: 7 } %>
<div class="hidden">
<%= f.input :spam, :hint => 'Leave this field blank!' %>
</div>
<%= f.button :submit, 'Send', class: 'btn-block btn-success btn-lg' %>
<% end %>
как я могу показать привязка new_contact с методом рендеринга?
Вы можете уточнить вопрос? Причина, по которой работает ссылка 'localhost: 3000/contacts/# new_contact', состоит в том, что вы указали маршрут для отображения формы. Эта ссылка, 'localhost: 3000/contacts/# blurp' также будет работать. Можете ли вы уточнить, что вы ищете, с вашим вопросом? –