Hello, I have a nested model form for PhotoAlbums. The form works fine via the standard html. But what I need to do is render it as a partial in another page it's erroring: "No route matches {:action=>"create", :controller=>"photo_albums"}"
The models:
Projects has_many :photo_albums
PhotoAlbums belongs_to :project has_many :photos
Photos belongs_to :photo_album
Controller: def create @project = Project.find(params[:project_id]) @photoalbum = PhotoAlbum.create(params[:photo_album]) end
Here is the working form which loads and works find via HTML:
<% form_for [:project, @photoalbum], :html => { :multipart => true } do |f| %> <div class="field"> <%= f.label :title %><br /> <%= f.text_field :title %> </div>
<% f.fields_for :photos do |builder| %> <% if builder.object.new_record? %> <%= builder.label :photo, "photo File" %> <%= builder.file_field :photo %> <% end %> <% end %>
<% end %>
The issue I'm having, is that to render this form as a partial in a view in another page. I'm using the following:
<% @photoalbum = PhotoAlbum.new %> <%= render :partial => "photo_albums/form", :locals => {:photoalbum => @photoalbum} %>
I checked by Rake Routes, And I do have it there: project_photo_albums POST /projects/:project_id/ photo_albums(.:format) {:controller=>"photo_albums", :action=>"create"}
Thoughts? thank you