ruby - Rails 5 - Simple Form - namespaced resources -
i trying learn how use namespacing in rails 5 app.
i have resource called randd_fields.
the table in database called:
randd_fields
i have model.rb files with:
randd.rb
module randd def self.table_name_prefix 'randd_' end end class randd::field < applicationrecord end
the controller called:
the views organised in files views/rannd/fields
in _form.html.erb, i'm trying find way form render.
i have tried each of these.
<%= simple_form_for(@field), multipart: true |f| %> <%= simple_form_for(@randd, @field), multipart: true |f| %> <%= simple_form_for([:randd, @field]), multipart: true |f| %>
each of them gives error:
the first, gives error says: undefined method `model_name' nil:nilclass
the second 2 give error says:
syntax error, unexpected tlabel ...r([:randd, @field]), multipart: true |f| @output_buffer.s...
how can use new path namespaced resource?
my routes show:
rake routes | grep field import_randd_fields post /randd/fields/import(.:format) randd/fields#import randd_fields /randd/fields(.:format) randd/fields#index post /randd/fields(.:format) randd/fields#create new_randd_field /randd/fields/new(.:format) randd/fields#new edit_randd_field /randd/fields/:id/edit(.:format) randd/fields#edit randd_field /randd/fields/:id(.:format) randd/fields#show patch /randd/fields/:id(.:format) randd/fields#update put /randd/fields/:id(.:format) randd/fields#update delete /randd/fields/:id(.:format) randd/fields#destroy
i can't find way form render create new randd_field instance.
try following
<%= simple_form_for @field, multipart: true |f| %>
Comments
Post a Comment