Routes and Namespace

Could someone explain me how to work with routes and namespaces?
I need to understand it urgent to build an application.
Thanks!

http://guides.rubyonrails.org/routing.html

I did so:

match ‘home’ => ‘home#index’

namespace :payable do
resources :account

end

root :to => ‘home#index’

I can access the route home/index, but can not access the route payable/accounts/index, he finds Payable::AccountsController but says he does not find the :id => ‘index’

Could someone explain me?
Thanks!

Hi, try add the following:

match ‘:controller(/:action(/:id))’

match ‘home’ => ‘home#index’

namespace :payable do
resources :account

end

root :to => ‘home#index’

I did so:

match ‘home’ => ‘home#index’

namespace :payable do
resources :account

end

root :to => ‘home#index’

I can access the route home/index, but can not access the route payable/accounts/index, he finds Payable::AccountsController but says he does not find the :id => ‘index’

Could someone explain me?
Thanks!

You received this message because you are subscribed to the Google Groups “Ruby on Rails: Talk” group.

To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/QjJTNW90QWtYa3NK.

To post to this group, send email to rubyonrails-talk@googlegroups.com.

To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Cordialmente,

Fábio Rodriguez (Brajola)

Analista de Sistemas / Systems Analyst

brajola@brajola.com

brajola@gmail.com

Actually my last line reads:

Sisteger::Application.routes.draw do

match ‘home’ => ‘home#index’

namespace :payable do

resources :account

end

root :to => ‘home#index’

match ‘:controller(/:action(/:id(.:format)))’

end

I generated the model and controller as follows:

rails g model Payable/Account

rails g controller Payable/Accounts

This is right?

You don’t need to do rails g model Payable/Account just Account works

But I need two scenarios:
Accounts Payable (Payable::AccountsController)
Accounts Receivable (Receivable::AccountsController)
But I can not work! :frowning:

So you are using the wrong syntax. You should use rails g controller Accounts/Payable, etc.

Anyway, I think you are a bit confused and must organize your knowledge flow. Start reading the Getting Started from Guides, http://guides.rubyonrails.org/getting_started.html.

You can generate just one model and set a flag with the type of Account:

for MongoId:

field :account_type, :type => String, :default => ‘P’

And in the controllers you can search with @accounts = Account.where(:account_type => ‘P’)

This can solve your problem but it’s not the best way to do it.

I can’t imagine a better way to do it!

I see, I thought so too.
But do not think the best way
But it is a solution!
I’ll have to implement anyway!
Thanks!