so i've got a model class named Photoset and a controller named Sets. ive got resources :sets working for everything except when paths are generated off an instance of the model. for example if i use:
<%= form_for(@photoset) do |f| %>
i get the error:
no route matches {:controller=>"sets"}
ultimately i want all the uris to be .../sets/...(controller name) instead of .../photosets/...(model name)
is there any way to do this and still be able to use the helpers?
--EDIT-- heres my rake routes output:
sets GET /sets(.:format) {:controller=>"sets", :action=>"index"}
POST /sets(.:format) {:controller=>"sets", :action=>"create"}
new_set GET /sets/new(.:format) {:controller=>"sets", :action=>"new"}
edit_set GET /sets/:id/edit(.:format) {:controller=>"sets", :action=>"edit"}
set GET /sets/:id(.:format) {:controller=>"sets", :action=>"show"}
PUT /sets/:id(.:format) {:controller=>"sets", :action=>"update"}
DELETE /sets/:id(.:format) {:controller=>"sets", :action=>"destroy"}
that all works just dandy, the problem is when i try to build a form off an instance of the model. I understand that rails has no way of knowing that im trying to tie the Photoset model directly with the Set controller, but I don't know how to specify that.
You have a Photoset model, Sets controller and urls need to be in form /sets/1/edit
.
resources :sets, :as => "photosets"
Works with a simple form like this:
<%= form_for(@photoset) do |f| %>
<%= f.text_field :title %>
<%= f.submit "Save" %>
<% end %>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With