Posts

Showing posts from December 14, 2018

Module route in Rails with form_for(@object)

Image
up vote 2 down vote favorite I have namespaced Controller Entities::Customers class Entities::CustomersController < ApplicationController ... end and namespaced ActiveRecord model: class Entities::Customer < Entities::User end in my routes.rb file i have: resources :customers, module: :entities The module :entities is there because i don't want to have routes such as: /entities/customers but only: /customers . The problem starts when i'm rendering my form: <%= simple_form_for(@customer) do |f| %> <%= f.input :email %> <%= f.input :password %> <%= f.input :name %> <%= f.button :submit %> <% end %> This throws error: undefined method `entities_customer_path' for Class.. So the error is that rails think that the correct path is with prefix entities. Rake routes give me: Prefix Verb URI Pattern Controller#Action customers GET /customers(.:format) entities/customers#index POST /customers(.:format) entities/customers#