routes

Passing parameter to controller action through routes [duplicate]

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-22 03:46:59
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: Rails: How do I pass custom params to a controller method? I am wondering if it possible to pass parameter to controller action through routes. I have a one generic action method which I want to call for various routes. No, I can't use wildcard in my route. match '/about' => 'pages#show' match '/terms' => 'pages#show' match '/privacy' => 'pages#show' I am looking for something like: match '/about' => 'pages#show

Arrange routes with authentication middleware

倾然丶 夕夏残阳落幕 提交于 2019-12-21 23:50:53
问题 I have many routes. Most of them require authentication. One doesn't. Here they are: router.get('/secure1', function (req,res) {...}) router.get('/secure2', function (req,res) {...}) router.get('/secure3', function (req,res) {...}) router.get('/:id', function (req,res) {...}) 1. Let's imagine I didn't have the public route. At the top of the page I could just put a security check middleware, and all is well. It will only let through secure connections, and will redirect non secure. router.use

Devise registration controller conflict with my own “registrations” controller

女生的网名这么多〃 提交于 2019-12-21 23:33:49
问题 I'm in a bit of a pickle here as I have used Daniel Kehoe's excellent Rails Composer to build a small app. I'm also using Devise for authentication. I had the bright idea to create a "registrations" controller/model to enable my users to register to different classes they want to attend. Obviously, this is wrecking havoc in my app and I'd like to know what is the best way to get out of this said pickle :) I'm left with two choices and would like to have you Rails experts chime in: Rename my

How do I get Web API / Castle Windsor to recognize a Controller?

旧时模样 提交于 2019-12-21 23:00:21
问题 I found out why the placeholder "Home Controller" was getting called here I commented out the reference to HomeController in RouteConfig.cs and added a Controller that I want it to call instead: public class RouteConfig { public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); //If get 404 error re: favicon, see http://docs.castleproject.org/(X(1)S(vv4c5o450lhlzb45p5wzrq45))/Windsor.Windsor-tutorial-part-two-plugging-Windsor-in.ashx or

No route matches with Nested Resources

霸气de小男生 提交于 2019-12-21 21:33:10
问题 I have two associated tables. Venues and Specials . A venue can have many specials . Once a user has created a venue I wish to allow them to create a special on the venues#index page. By using nested resources I have achieved the desired URL: /venues/5/specials/new . However, my current code results with: No route matches {:controller=>"specials", :format=>nil} I'm guessing the error is with my SpecialsController and the def new and def create functions. I would like the URL to take me to a

how to make url shorter in web2py and google appengine

无人久伴 提交于 2019-12-21 21:33:05
问题 I've been trying to make URLs shorter. For example, change www.mydomainname.com/myapp/default/mypage to www.mydomainname.com/mypage I add the following code in routes.py under the web2py folder: routes_out=( ('.*:/sevenpeng/default(?P<any>.*)', '\g<any>'),) But this didn't work. The url still shows www.mydomain.com/default/mypage Am i missing something? Another problem, I deployed my website on google appengine, when I typed www.mydomainname.com, it directs to the right page, and the address

Creating a Catch-All Route

白昼怎懂夜的黑 提交于 2019-12-21 21:13:13
问题 I've found several examples online (especially on StackOverflow) for creating a catch-all route in ASP.NET MVC, but this doesn't appear to be working for me in MVC4: public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.IgnoreRoute("elfinder.connector"); routes.MapRoute( name: "Default", url: "{controller}/{action}/{id}", defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional } ); routes.MapRoute( name:

angular multiple routes sharing one controller

核能气质少年 提交于 2019-12-21 20:39:35
问题 I'm not sure if I'm approaching this correctly but I'm building an ecommerce site - part of the site has 6 different product grid pages, each of which can use the same view: <ul class="products row"> <li class="product thumbnail col-1 grid" ng-repeat="whisky in whiskies | orderBy: sort"> <p class="picture"> <a ng-href="#/json/{{whisky.id}}"><img ng-src="images/scotch/{{whisky.imageUrl}}" alt="{{whisky.name}}"/></a> </p> <div class="desc"> <h2>{{whisky.name}}</h2> <p class="price"><span>£{

Routing Zend Framework 2 Language in url

纵饮孤独 提交于 2019-12-21 17:23:42
问题 For my application translation I would like to use a language structure e.g.: site.com (english) site.com/de/ (german) site.com/fr/ (france) site.com/nl/ (dutch) etc.. I can do this easily with the router option in Literal as '[a-z]{2}' but I want to exclude languages I do not support, e.g. site.com/it/ if it is not supported I want a 404. I tried to fix this with regex (adding supported languages) but something (I do not know) went wrong. Thanks in advance! 'router' => array( 'routes' =>

Symfony2, Is it possible to have two route for one action in a controller?

二次信任 提交于 2019-12-21 17:14:48
问题 I have an action inside my controller class and I want two different routes like below: /** * Displays a form to create a new entity. * * @Route("/edit/choose/date", name="user_choose_date") * @Route("/supervisory/choose/date", name="sup_choose_date") * @Template() */ public function chooseDateAction() { return array( ); } The reason for that I would like to give the route access to some users but the user role are different. Let's say: User with supervisor role can access sup_choose_date