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

  • Home
  • SEARCH
  • 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 8369945
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T13:47:17+00:00 2026-06-09T13:47:17+00:00

I seem to have two problems 1) While trying to update my singular nested

  • 0

I seem to have two problems

1) While trying to update my singular nested resource

Restaurant has_one Hour

and

Hour belongs_to Restaurant

resources :restaurants do
  resource :hour
end

with an edit link on my restaurant show page called:

<%= link_to 'Set Hour', edit_restaurant_hour_path([@restaurant, @restaurant.hour]) %>

and the edit page has a partial render that looks like:

<%= render :partial => 'restaurants/hours', :locals => { :hour => 'hour' } %>

which loads a partial named _hours.html.erb:

<%= form_for hour do |f| %>
<div class="row-fluid">
<div class="span1 hours_input">
  <h3>Monday</h1>
  From
  <%= f.text_field :from_monday, :class => 'span20 hour_field'  %>
  To
  <%= f.text_field :to_monday, :class => 'span20 hour_field'  %>
</div>
<div class="span1 hours_input">
  <h3>Tuesday</h3>
  From
  <%= f.text_field :from_tuesday, :class => 'span20 hour_field' %>
  To
  <%= f.text_field :to_tuesday, :class => 'span20 hour_field'  %>
</div>
<div class="span1">
  <%= f.submit 'Set Hours' %>
</div>
</div>

but once I press the submit button it gives me the error:

No route matches [POST] "/restaurants/34/hour/edit"

I tried setting it as:

<%= form_for hour, :method => put, :html => { :action => 'update' } do |f| %>

but with no luck.
Any help would be greatly appreciated!
I’m using rails 3.2.3

2) My second problem is rather mysterious.

Once I press on the button

<%= link_to 'Set Hour', edit_restaurant_hour_path([@restaurant, @restaurant.hour]) %>

on the restaurant show page, it’ll give the url:

http://localhost:3000/restaurants/34//hour/edit

with the double slash before //hour. I suspect this will break in production but doesn’t seem to affect me in development.

Again, thanks for reading and have a good one!

Edit: Here’s the rake routes–

  restaurant_hour POST   /restaurants/:restaurant_id/hour(.:format)      hours#create

 new_restaurant_hour GET    /restaurants/:restaurant_id/hour/new(.:format)       hours#new

  edit_restaurant_hour GET    /restaurants/:restaurant_id/hour/edit(.:format)  hours#edit

  GET    /restaurants/:restaurant_id/hour(.:format)               hours#show

  PUT    /restaurants/:restaurant_id/hour(.:format)               hours#update

  DELETE /restaurants/:restaurant_id/hour(.:format)               hours#destroy

  restaurants GET    /restaurants(.:format)                       restaurants#index

  POST   /restaurants(.:format)                                   restaurants#create

  new_restaurant GET    /restaurants/new(.:format)                restaurants#new

  edit_restaurant GET    /restaurants/:id/edit(.:format)          restaurants#edit

  restaurant GET    /restaurants/:id(.:format)                    restaurants#show

  PUT    /restaurants/:id(.:format)                               restaurants#update

  DELETE /restaurants/:id(.:format)                               restaurants#destroy

  hour GET    /:restaurant/hour(.:format)                         hours#show

  POST   /:restaurant/hour(.:format)                              hours#create

  hour_add GET    /:restaurant/hour/add(.:format)                 hours#new

  hour_edit GET    /:restaurant/hour/edit(.:format)                         hours#edit
  • 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-06-09T13:47:18+00:00Added an answer on June 9, 2026 at 1:47 pm

    I figured it out, but it’s apparently not the RESTful way to do it.

    I just had to add:

    <%= form_for hour, :url => { :action => "update" }, :html => { :method => 'put' } do |f| %>
    

    and specify the action/method for the update to work.

    Another post suggested that just using:

    <%= form_for @hour do |f| %>
    

    would have worked, too, but I wasn’t having any luck with that for some reason.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two instances of a model and find that they seem to share
I have two variables in my WHERE statement. I cant seem to separate them
Simple question which I can't seem to find an answer of: I have two
What's the difference between the two? They seem to have the same functionality at
I seem to have hit a snag while building my project using Ant. The
I just started using gApps scripts and I have run into two problems with
I have two Haskell functions, both of which seem very similar to me. But
I seem to have a problem passing some strings on from one form to
I seem to have found a bug in jQuery UI that duplicates dragged elements
i seem to have some trouble installing autopy.h https://github.com/msanders/autopy/#introduction i already tried the installation

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.