routing

how to create a global route prefix in sails?

旧巷老猫 提交于 2019-11-30 02:58:41
问题 I just recently started using sails and nodejs. I was wondering, is there an easy way to create a global prefix using the configuration available in Sails? Or would I need to bring in another library? I found the blueprint prefix configuration in config/controller.js. It seems there ought to be an easy way to do this since the application already partially supports it... I'm trying to get something like /api/v1 in front of all routes I have for my application. Thanks. 回答1: You can set the

How to write controller tests when you override devise registration controller?

雨燕双飞 提交于 2019-11-30 01:55:57
I wish to override the Devise::RegistrationsController to implement some custom functionalality. To do this, I've created a new RegistrationsController like so: # /app/controllers/registrations_controller.rb class RegistrationsController < Devise::RegistrationsController def new super end end and set up my routes like this: devise_for :users, :controllers => { :registrations => "registrations" } and tried to test it like this: describe RegistrationsController do describe "GET 'new'" do it "should be successful" do get :new response.should be_success end end end but that gives me an error: 1)

Rails 3 resource routing without an id

坚强是说给别人听的谎言 提交于 2019-11-30 01:54:16
I am creating a blog application on Rails 3, and I want to override the default show route generated for a post by doing resources :posts, :except => :show Which generates, for the show route (had I not excluded it), /post/:id I want my route to look like this instead, where url_title is a string generated by my model on before_save, where it removes non alphanumeric characters and replaces spaces with hyphens. /:year/:month/:day/:url_title I'm trying to accomplish this with this bit of code: match "/:year/:month/:day/:url_title", :to => "posts#show", :as => :post In theory this should allow

Passing data through Angular2 router

本小妞迷上赌 提交于 2019-11-30 01:53:52
I have a component where I select a set of image objects. I want to pass these selected images to my new route, CreateAlbum. The data it nested and wouldn't be suitable to pass as URL parameters. Is there any easy way to achieve this? Here's my code to navigate to the route public gotoCreateAlbum(): void { this.router.navigate([('/create-album')]) } My selected data sits in this variable @Input() selectedPhotos: IPhoto[]; and this is my routing module const routes: Routes = [ { path: 'photos', component: PhotosComponent}, { path: 'photos/:filter', component: PhotosComponent}, { path: 'create

AngularJs Routing with parameters

我的梦境 提交于 2019-11-30 01:43:43
问题 Can someone explain how I can route to a Url using parameters? E.g. id like to click on a product and open more info of the product by Id. My Routing so far ... angular.module('shop', ["customFilters", "cart", "ngRoute"]) .config(function ($routeProvider){ $routeProvider.when("/complete", { templateUrl: "../app/views/orderComplete.html" }); $routeProvider.when("/placeorder", { templateUrl: "../app/views/placeOrder.html" }); $routeProvider.when("/checkout", { templateUrl: "../app/views

Redirecting from port 80 to different ports based on URL

强颜欢笑 提交于 2019-11-30 01:27:58
I have two applications, (Atlassian JIRA and Confluence,) listening on ports 8080 and 8090, accessible through example.com:8080/jira and example.com:8090/confluence. I would like to set up a redirection on port 80 such that I can access the services through example.com/jira and example.com/confluence. Is there a simple way to achieve this? There are 2 ways of solving this. Redirect Method You seem pretty savvy setting up servers. You will need a web Server running on port 80. (Apache: Windows/*nix; IIS: Windows) Set up a virtual site / folder if you just want example.com/jira and example.com

Routing with an optional parameter

霸气de小男生 提交于 2019-11-30 01:09:26
I added in the route file: map.show_book "/show_book/:name/year/:year", :controller => "book", :action => "show_version" I also added: map.show_book "/show_book/:name", :controller => "book", :action => "show_version" to show the latest book without specifying the year. But it doesn't work, it cannot find the route in "show_book/NAME" if I don't pass the year. Do you have some ideas why it doesn't work ? THANKS ! PS. I know that I can use year as parameter with "?year=XXXX", but I want to use the year as a part of the URL Benoit Garret Put the optional parts between parenthesis : map.show_book

Can I group multiple domains in a routing group in Laravel?

a 夏天 提交于 2019-11-30 00:05:06
Let's say I have the following: Route::group(array('domain' => array('admin.example.com')), function() { ... }); Route::group(array('domain' => array('app.example.com')), function() { ... }); Route::group(array('domain' => array('dev.app.example.com')), function() { ... }); Is there any way to have multiple domains share a routing group? Something like: Route::group(array('domain' => array('dev.app.example.com','app.example.com')), function() { ... }); Laravel does not seem to support this. I'm not sure why I didn't think of this sooner, but I guess one solution would be to just declare the

Using Linux, how to specify which ethernet interface data is transmitted on

房东的猫 提交于 2019-11-29 23:14:54
I'm working on a Linux based server system in which there are two network interfaces, both on the same subnet (for now, lets just say they are 172.17.32.10 & 172.17.32.11 ). When I send data to a host on the network, I would like to specify which interface on my server the data is transmitted on. I need to be able to switch from one interface to the other (or maybe even transmit on both) in software (static routing rules won't work for this application). I found a related question in StackOverflow that suggested using the netlink library to modify routes on the fly. This intuitively seems like

Asp.Net MVC: How do I get virtual url for the current controller/view?

梦想与她 提交于 2019-11-29 23:07:07
Is it possible to get the route/virtual url associated with a controller action or on a view? I saw that Preview 4 added LinkBuilder.BuildUrlFromExpression helper, but it's not very useful if you want to use it on the master, since the controller type can be different. Any thoughts are appreciated. I always try to implement the simplest solution that meets the project requirements. As Enstein said, "Make things as simple as possible, but not simpler." Try this. <%: Request.Path %> This worked for me: <%= this.Url.RouteUrl(this.ViewContext.RouteData.Values) %> It returns the current Url as such