routes

Rspec namespaced route specs failing even though route exists

筅森魡賤 提交于 2019-12-06 06:15:27
I'm using rspec-rails (2.8.1) and rails 3.1.3 . I'm trying to test routes for my Admin::ZonesController. I have verified the route exists in both the browser and by running rake routes . I am not using ActiveRecord (if that matters). When I run the routing spec, it tells me: ActionController::RoutingError: No route matches "/admin/zones/new" Here is the test (spec/routing/admin/zones_routing_spec.rb): require 'spec_helper' describe "routing to zones" do it "routes /admin/zones/new to admin/zones#new" do { :get => "/admin/zones/new" }.should route_to( :controller => "admin/zones", :action =>

Add Routes at Runtime (ExpressJs)

最后都变了- 提交于 2019-12-06 06:14:26
问题 I would like to add routes at run time. I read that its possible but I am not so sure how. Currently I using the following code: var app = express(); function CreateRoute(route){ app.use(route, require('./routes/customchat.js')); } And customchat looks like var express = require('express'); var router = express.Router(); router.route('/').get(function (req, res) { var url = req.baseUrl; var roomname = url.substring(url.lastIndexOf('_') + 1); res.render('chat', { name: roomname , year: new

How to optimize an Express.js route?

China☆狼群 提交于 2019-12-06 05:48:33
问题 I'm developing a reserved area that has the follow few pages: /dashboard /dashboard/profile /dashboard/user /dashboard/view that's a simple user control panel. At the moment i have four routes: app.all('/dashboard', function(req, res, next) { /* Code */ }); app.all('/dashboard/profile', function(req, res, next) { /* Code */ }); app.all('/dashboard/user', function(req, res, next) { /* Code */ }); app.all('/dashboard/view', function(req, res, next) { /* Code */ }); I would like to optimize it

Match route relative to path

大兔子大兔子 提交于 2019-12-06 05:26:22
I want any URL that ends with /templates/{filename} to map to a specific controller using either a route attribute i.e. something like: public class TemplateController : Controller { [Route("templates/{templateFilename}")] public ActionResult Index(string templateFilename) { .... } } which works, but the links referencing this route are relative so http://localhost/templates/t1 -- works http://localhost/foo/bar/templates/t2 -- breaks (404) I need something like: [Route("*/templates/{templateFilename}")] You cannot accomplish something like this with attribute routing. It is only possible to do

Implement your own object binder for Route parameter of some object type in Play scala

社会主义新天地 提交于 2019-12-06 04:53:11
问题 Well, I want to replace my String param from the following Play scala Route into my own object, say "MyObject" From GET /api/:id controllers.MyController.get(id: String) To GET /api/:id controllers.MyController.get(id: MyOwnObject) Any idea on how to do this would be appreciated. 回答1: Use PathBindable to bind parameters from path rather than from query. Sample implementation for binding ids from path separated by comma (no error handling): public class CommaSeparatedIds implements

How to deploy Angular 2 application as a standalone (using dist folder)

旧城冷巷雨未停 提交于 2019-12-06 04:17:46
I have finished a development of Angular 2 application and I need to deploy it. I need it to work standalone. So, I tried to move the content of dist folder inside a new apache website, but the routing mechanism doesn't work for some reason, I am getting 404 error when I try to go to /integrations route, for example. During the development, on angular 2 server, /integrations works and Angular 2 routing mechanism works and displays the component without problem. I need the standalone app to also be able to work with different URLs/paths. Any suggestions? Follow following steps : Step 1 : ng

rails, adding a parameter to new route

旧城冷巷雨未停 提交于 2019-12-06 03:48:17
The new action normally doesn't require parameters, since it creates a new resource from scratch. In my application whenever i create a certain type of resource say a book i need to provide a template, that is the id of another book . So my new route always has a parameter. I don't know how to represent this fact into routes.rb file. Since i don't even know whether it is feasible, just in the case it isn't, then i will create a new_wp, a "new with parameter" action. I tried to add it to my resources :books, :only => [:edit, :update, :show, :new] do member do get 'new_wp/:template_id', :action

Accepting an encoded URL in a Laravel 4 route

爱⌒轻易说出口 提交于 2019-12-06 02:55:25
I'm developing a website in Laravel 4 Beta 5 and I'm trying to pass on an encoded URL to the router. The problem is, an encoded URL has percentages etc. in it, so it is blocked by Laravel. The URL is encoded with the Javascript function encodeURIComponent() . Is there a way to override Laravel so I can use any character in my route? This is my current code: Route::get('add/{encoded_url}', function($encoded_url) { return 'The URL is: '.rawurldecode($encoded_url); }); I have tried to override Laravel by appending where('encoded_url', '*reg-ex*'); , but it didn't work (I'm not very good with reg

Configuring routes in devise when only using omniauth for authentication

萝らか妹 提交于 2019-12-06 02:54:06
问题 I have built an application which allows a user to authenticate against Active Directory using omniauth-ldap. If this is a new user, the successful authentication creates a user for them based on information returned from AD. If the user already exists, it just logs them in. Users do not register for the application, they just log in with AD credentials. And I never want the user to log in with database credentials. I can't figure out how to get rid of or change around some of the routes. For

Rails routes with dates

风格不统一 提交于 2019-12-06 02:43:02
问题 So I have a weekly calendar view and I have a route set up to accept /:year/:month/:day for the start date. match "events/(:year/:month/:day)" => "events#index", :constraints => { :year => /\d{4}/, :month => /\d{2}/, :day => /\d{2}/ }, :as => "events_date" I have two questions regarding the use of this route. First, when parsing the params, this is what I'm doing: unless params[:year].nil? || params[:month].nil? || params[:day].nil? start_date = Date.new(params[:year].to_i, params[:month].to