Skip to content

Instantly share code, notes, and snippets.

@whito
Created September 4, 2012 20:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save whito/3626125 to your computer and use it in GitHub Desktop.
Save whito/3626125 to your computer and use it in GitHub Desktop.
Routing Problem in RailwayJS
$ rw routes
users GET /users.:format? users#index
users POST /users.:format? users#create
new_user GET /users/new.:format? users#new
edit_user GET /users/:id/edit.:format? users#edit
user DELETE /users/:id.:format? users#destroy
user PUT /users/:id.:format? users#update
user GET /users/:id.:format? users#show
login GET /login users#login
login POST /login users#authenticate
<!DOCTYPE html>
<html lang="en">
<head>
<title><%= title %></title>
<%- stylesheet_link_tag( 'style') %>
</head>
<body>
<form action='/login' method='post' id='login'>
<img src='images/logo.png'>
<fieldset>
<label>Username</label>
<input type='text' name='login' id='username' required autofocus>
<label>Password</label>
<input type='password' name='password' id='password'>
</fieldset>
<fieldset>
<input type='submit' class='button' value='Login'>
</fieldset>
</form>
</body>
</html>
exports.routes = function (map) {
map.resources('users');
//custom routes here
map.get('login', 'users#login');
map.post('login', 'users#authenticate');
};
//users_controller.js (omitted out the CRUD actions)
action(function login() {
console.log("in login-------");
layout("login");
this.title= "Login Page";
render();
});
action(function authenticate() {
// this never shows up when the form is posted.
console.log("in authenticate");
});
@anatoliychakkaev
Copy link

Could you please show your config/environment.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment