I created custom form builder for devise sign up form.
Form looks like this, and works fine:
<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name), builder: BootstrapFormBuilder) do |f|
<%= f.text_field :username, :autofocus => true %>
<%= f.email_field :email %>
<%= f.password_field :password %>
<%= f.password_field :password_confirmation %>
<%= f.submit "Sign up", class: "btn btn-default" %>
<% end %>
Now I want to create helper named bootstrap_form_for
. In application helper I wrote (just to test it):
module ApplicationHelper
def bootstrap_form_for(record, options = {}, &block)
form_for(record, options = {}, &block)
end
end
When instead of form_for
I insert bootstrap_form_for
I get error: undefined method 'users_path' for #<#<Class:0x007f9eb40bc728>:0x007f9eb40bb9b8>
in this bootstrap_form_for
line.
Error page title: NoMethodError in Devise::Registrations#new
Do you know why?
Problem was here:
module ApplicationHelper
def bootstrap_form_for(record, options = {}, &block)
form_for(record, options = {}, &block)
end
end
It should be:
module ApplicationHelper
def bootstrap_form_for(record, options = {}, &block)
form_for(record, options, &block)
end
end
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.