Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot GET /pages #156

Open
kazzkiq opened this issue Jul 18, 2014 · 3 comments
Open

Cannot GET /pages #156

kazzkiq opened this issue Jul 18, 2014 · 3 comments

Comments

@kazzkiq
Copy link

kazzkiq commented Jul 18, 2014

As playing for the first time with Locomotive.js I've found myself not managing to access other views/controllers via browser.

Basically What I do is create a new controller, a new view directory / view file, and when I try to access it via url it throws the title message.

Do I have to explicitly set each controller/view on routes so them can be accessed? Or this should work automatically?

@crispen-smith
Copy link

My experience with Locomotive has always been that writing routes is a best practice. I am not aware of any automatic interpretation of routes from controllers/actions.

I'm actually not aware of any server side MVC pattern that supports automatic route matching, and it's a role that really should belong to the developer.

@kazzkiq
Copy link
Author

kazzkiq commented Jul 19, 2014

I don't know, I've used other frameworks (not Node.js related) that have an approach that seems to help with the mainstream routing. Let me see what you think, here is a example:

//...
exampleController.indexAction = function()
{
    // the "Action" append in the object name automatically
    // triggers a view implicity, so the framework links the view
    // "views/example/index.html.ejs" with this action
}

exampleController.someFunc = function()
{
    // no "Action", no implicit search for a related view
}
  • If there is no View set for the indexAction, it just throw an 404 page.
  • The code on the controller always overwrite the View

This way you could easily create new Controllers / Views without the need to manually define a route every time you want a new page.

@crispen-smith
Copy link

But what about variable instantiation and naming?

For index actions this is probably fine, but as you get into item/foo type
actions there are more and more variable cases to consider.

In either case, I'm fairly sure in it's current form locomotive doesn't
support this behaviour, at least nothing I've seen in the docs seems to
speak to it.

On Sat, Jul 19, 2014 at 6:38 PM, Claudio Holanda Jr. <
[email protected]> wrote:

I don't know, I've used other frameworks (not Node.js related) that have
an approach that seems to help with the mainstream routing. Let me see what
you think, here is a example:

//...myController.indexAction = function(){
// the "Action" append in the object name automatically
// triggers a view implicity, so the framework assumes there is one}
myController.someFunc = function(){
// no "Action", no implicit search for a related view}

  • If there is no View set for the indexAction, it just throw an 404
    page.
  • The code on the controller always overwrite the View

This way you could easily create new Controllers / Views without the need
to manually define a route every time you want a new page.


Reply to this email directly or view it on GitHub
#156 (comment)
.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants