Topic: Need Help with Site Design

I'm planning my rails app right now, and since this is my first project, I'm trying to figure out a couple things. In books I've read, they stick to a very clearly defined URL routing syntax.

:controller/:action(/:id)

For the actions, they always use new, view, update and destroy. However, if I'm building a mail application, I may want to use inbox, read/:id (instead of "view/:id"), create (instead of "new"), sent, drafts, etc. I realize I could do this, but are there any advantages to following the normal route naming conventions?

Also, I don't always want to use the :controller/:action routing syntax. Can I write routes like I do in .htaccess files (e.g. so /register would be rewritten to /user/new)?

Thanks for your help in advance!

Re: Need Help with Site Design

Aha, I figured the rewrite part out:

match 'register' => 'user#new' 

Re: Need Help with Site Design

controller :user do
    get 'register' => :new
    post 'register' => :create
end

If you use rails 3 try this. its look more well-organized

Re: Need Help with Site Design

why using get on :new and post on :create

Re: Need Help with Site Design

why using get on :new and post on :create

I assume because GET would be the initial page request and POST would be the registration form submission.
_________________

Thanks for the tip, by the way dimak. I'm still trying to get more familiar with Rails 3, and the more I do, the sweeter it gets!

Re: Need Help with Site Design

jtomasrl wrote:

why using get on :new and post on :create

In general you can route all requests (get/post/put/delete) into one controllers method, but its not good idea  write php programs on ruby %)

Re: Need Help with Site Design

Snowball wrote:

why using get on :new and post on :create

I assume because GET would be the initial page request and POST would be the registration form submission.
_________________

Thanks for the tip, by the way dimak. I'm still trying to get more familiar with Rails 3, and the more I do, the sweeter it gets!


I agree with you



-------------------
embrace my fun factory FLASH