public
Created

Routing Problem in RailwayJS

  • Download Gist
gistfile1.txt
1 2 3 4 5 6 7 8 9 10 11
$ 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
login_layout.ejs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
<!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>
routes.js
JavaScript
1 2 3 4 5 6 7 8 9
exports.routes = function (map) {
map.resources('users');
 
//custom routes here
 
map.get('login', 'users#login');
map.post('login', 'users#authenticate');
 
};
users_controller.js
JavaScript
1 2 3 4 5 6 7 8 9 10 11 12
//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");
});

Could you please show your config/environment.js

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.