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!

On Jun 1, 2011, at 10:13 AM, Vincius R. wrote:

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


You received this message because you are subscribed to the Google G. “Ruby
on Rails: Talk” group.
To view this discussion on the web visit
https://groups.google.com/d/msg/rubyonrails-talk/-/aFVOeUZzVUlsUUFK.
To post to this group, send email to [email protected].
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.

Cordialmente,

Fbio Rodriguez (Brajola)
Analista de Sistemas / Systems Analyst

[email protected]
[email protected]

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
notfind
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’

On Jun 1, 2011, at 10:30 AM, Vincius R. wrote:

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 G. “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 [email protected].
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.

Cordialmente,

Fbio Rodriguez (Brajola)
Analista de Sistemas / Systems Analyst

[email protected]
[email protected]

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

On Jun 1, 2011, at 10:50 AM, Vincius R. wrote:

root :to => ‘home#index’

This is right?


You received this message because you are subscribed to the Google G. “Ruby
on Rails: Talk” group.
To view this discussion on the web visit
https://groups.google.com/d/msg/rubyonrails-talk/-/QXd5dGZNMVlEelVK.
To post to this group, send email to [email protected].
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.

Cordialmente,

Fbio Rodriguez (Brajola)
Analista de Sistemas / Systems Analyst

[email protected]
[email protected]

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

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 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!

On Jun 1, 2011, at 11:19 AM, Vincius R. wrote:

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

Fbio Rodriguez (Brajola)
Analista de Sistemas / Systems Analyst

[email protected]
[email protected]

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!

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,
Getting Started with Rails — Ruby on Rails Guides.

2011/6/1 Vincius R. [email protected]

To post to this group, send email to [email protected].
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.


S.