Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6581019
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T16:06:00+00:00 2026-05-25T16:06:00+00:00

I’m literately going crazy with this one. I have been searching the answer and

  • 0

I’m literately going crazy with this one. I have been searching the answer and trying everything I find, including related questions & answers here on stackoverflow and still can’t make it work.

I’m working with a nested resource and I can’t make the form work. I always get errors, such as No route matches [PUT] “/galleries/1/photos”

The form is here: /galleries/1/photos/1/edit

routes.rb

resources :galleries do
  resources :photos
end
resources :galleries
resources :photos

photos_controller.rb

def new
  @gallery = Gallery.find(params[:gallery_id])
  @photo = @gallery.photos.build

  respond_to do |format|
    format.html
  end
 end

def edit
  @gallery = Gallery.find(params[:gallery_id])
  @photo = Photo.find(params[:id])
end

def create
  @gallery = Gallery.find(params[:gallery_id])
  @photo = @gallery.photos.build(params[:photo])

  respond_to do |format|
    if @photo.save
      format.html { redirect_to @photo, notice: 'Photo was successfully created.' }
    else
      format.html { render action: "new" }
    end
  end
end

def update
  @gallery = Gallery.find(params[:gallery_id])
  @photo = Photo.find(params[:id])

  respond_to do |format|
    if @photo.update_attributes(params[:photo])
      format.html { redirect_to @photo, notice: 'Photo was successfully updated.' }
      format.json { head :ok }
    else
      format.html { render action: "edit" }
      format.json { render json: @photo.errors, status: :unprocessable_entity }
    end
  end
end

_form.html.erb

<%= form_for([@gallery, @photo], :url => gallery_photos_path(params[:gallery_id]), :html => {:multipart => true}) do |f| %>
  <div class="field">
  <%= f.label :title %><br />
  <%= f.text_field :title %>
</div>
<div class="field">
  <%= f.file_field :image %>
</div>
<div class="actions">
  <%= f.submit %>
</div>
<% end %>

I have also tried form_for([@gallery, @photo], :html => {:multipart => true}) and form_for(@photo, :url => gallery_photos_path(@gallery), :html => {:multipart => true})

UPDATE

Here is a portion of rake routes.

gallery_photos GET    /galleries/:gallery_id/photos(.:format)          {:action=>"index", :controller=>"photos"}
    POST   /galleries/:gallery_id/photos(.:format)          {:action=>"create", :controller=>"photos"}
new_gallery_photo GET    /galleries/:gallery_id/photos/new(.:format)      {:action=>"new", :controller=>"photos"}
edit_gallery_photo GET    /galleries/:gallery_id/photos/:id/edit(.:format) {:action=>"edit", :controller=>"photos"}
gallery_photo GET    /galleries/:gallery_id/photos/:id(.:format)      {:action=>"show", :controller=>"photos"}
    PUT    /galleries/:gallery_id/photos/:id(.:format)      {:action=>"update", :controller=>"photos"}
    DELETE /galleries/:gallery_id/photos/:id(.:format)      {:action=>"destroy", :controller=>"photos"}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T16:06:02+00:00Added an answer on May 25, 2026 at 4:06 pm

    You don’t need to specify the URL, which was wrong for the update anyway. Try

    <%= form_for([@gallery, @photo], :html => {:multipart => true}) do |f| %>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I am trying to loop through a bunch of documents I have to put
I have some data like this: 1 2 3 4 5 9 2 6
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.