Answer the question
In order to leave comments, you need to log in
Rails form_for how to make form generate path without module?
Hello
Model:
class Core::Contractor < ActiveRecord::Base
end
scope module: :core do
resources :contractors
end
= form_for @contractor, :html => { :class => "form-horizontal" } do |f|
.form-group
= f.label t(:name), :class => 'control-label col-md-2'
.col-sm-3
= f.text_field :name, :class => 'text_field form-control'
.form-group
.col-md-offset-2.col-sm-3
=' f.button t(:save), :class =>'btn btn-primary', :disable_with => t(:please_wait)
= link_to t(:cancel), contractors_path, :class => 'btn btn-default'
undefined method `core_contractors_path' for #<#<Class:0xaa56f54>:0xafc7b00>
= form_for @contractor, url: contractors_path, :html => { :class => "form-horizontal" } do |f|
Answer the question
In order to leave comments, you need to log in
If variations with
do not help,
then I would do this:
url: (@ contractor.persisted? ? contractor_path(@ contractor) : contractors_path, method: (@ contractor.persisted? ? :put : :post)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question