On Nov 4, 8:08 am, Vahagn Hayrapetyan <[EMAIL PROTECTED]
s.net> wrote:
> Issue solved!
>
> users.resource:houses, :controller => 'user_house'
>
> instead of:
>
> users.resource:house, :controller => 'user_house'
> end
>
> Apparently the resources are always plural, regardless that a user only
> has one house.
>
> /V.

Hi Vahagn. Resources don't have to be plural. For example, one of my
apps has users, and when they login, they access their account at this
path:
  /account/
To do this, I added the following to routes.rb:
  map.resource :account
You just need to make sure that all of your files and classes have
proper pluralisation. Thus, I have AccountsController.

For your question, I would think that you'd need:
  # config/routes.rb
  map.resources :users do |users|
    users.resource :house, :controller => 'user_house'
  end

  # app/controllers/houses_controller.rb
  class HousesController < ApplicationController

In other words, make sure it's "HousesController" and
"houses_controller.rb" (plural), not "HouseController" or
"house_controller.rb" (singular).

Once you have that working properly, you can generate URLs and paths
to a user's house like this:
  user_house_path
  user_house_url

I hope that helps,
Nick
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to