routing

button_to with GET method option in Rails

≯℡__Kan透↙ 提交于 2019-12-03 10:06:55
I have the following button, which I overwrited to generate a GET request: = button_to "Tutor", {:controller => "appointments", :action => "new", :listing_id => @listing.id} , :method => :get However, I still get a POST request with extra params :method: Processing by AppointmentsController#new as HTML Parameters: {"authenticity_token"=>"AWkL", "listing_id"=>"2", "method"=>"get"} I my routes file, I have: resources :appointments What did I do wrong? Thank you. Buttons aren't supposed to be sending GET requests. You should use a link_to instead. If you want it to look like a button, apply some

ASP.net MVC site : Redirect all “non WWW” request to WWW

99封情书 提交于 2019-12-03 10:03:48
问题 Recently I migrated an ASP.net site to ASP.net MVC site. Earlier there were two host headers one mydomain.com and another is www.mydomain.com. My SEO says you should use only one url "www.domain.com" for SEO advantage. I am looking for an option to do 301 permanent redirect all mydomain.com request to www.mydomain.com. The site is hosted in IIS6 and developed in ASP.net MVC 4. 回答1: Unfortunately, the URL rewrite module does not work with IIS6 (only IIS7 or greater). Have you considered

Routing in Silex/Symfony. Providing a default route

这一生的挚爱 提交于 2019-12-03 09:47:29
问题 I'm attempting to do something using Silex (which uses the Symfony routing component - so the answer may be applicable to Symfony as well) I am adding Silex to a legacy application to provide routing but I need to respect the existing applications default implementation for loading files (which is simply to load the file from the file system form the URL specified). edit: for clarification: Existing file is loaded from the file system, as an include within an parent template, after a series

Rails 3 : route a resource to another name

久未见 提交于 2019-12-03 09:41:10
I have a CRUD controller for a model. Doing resources :foo allows me to route on /foo/:id , etc. for calling actions. I want add a route for a translation of 'foo' in another language. Let's say 'toto'. So I want all the /toto/:id , etc., routes to act exactly like the /foo/:id , etc., routes. How may I achieve that? You can add a new resource and specify foo as the controller: resources :toto, :controller=>"foo" This will point all the actions to "foo", but there is a gotcha. I think you will run into problems with the links on the page, if you are using foo_url or something like that. So you

Recursive routes in Rails

青春壹個敷衍的年華 提交于 2019-12-03 09:25:15
问题 Is is possible to create a recursive route in Rails? I have an application, which allows a admin to create pages. The page model is a nested set and so each page has a parent_id hence the pages are structured in trees. The page model also uses the Friendly ID plugin to provide slugs for each page. When a user browses the site I would like them to see the nesting structure in the urls - its better for search engine purposes as well as any users who might like to browse the site by chopping the

Customize MapHttpAttributeRoutes for Web Api Versioning

与世无争的帅哥 提交于 2019-12-03 09:23:54
I am implementing Web API versioning as in Web API Versioning . My controllers are in 2 separate namespaces, and I've used a custom SelectController method to choose which version to use based on a a query parameter. e.g. http://myapi/api/values?version=1.0 This all works fine but some actions in the controllers use the Route attribute [Route("api/values/getNames")] public HttpResponseMessage Get() { ... } Which are mapped to the correct controller by default using config.MapHttpAttributeRoutes(); in WebApiConfig.cs This will not work if I have multiple versions of the API with the same route.

adding a Route to the a Router in Zend Framework

时光总嘲笑我的痴心妄想 提交于 2019-12-03 09:15:54
I am using the mod-rewrite router. I am trying to add a Route to the router that will convert the following url: baseurl/category/aaa/mycontroller/myaction/param/value to be: Controller=mycontroller action=myaction --parameters-- category=aaa param=value I am using the following (not working) in my bootstrap, _front is the frontController $Router=$this->_front->getRouter(); $CategoryRoute = new Zend_Controller_Router_Route('category/:category/:controller/:action/*'); $Router->addRoute('category', $CategoryRoute); The error I get is a thrown router exception when I am using the Zend_View::url()

Flask: serve assets without leading slash using url_for

江枫思渺然 提交于 2019-12-03 09:08:52
I'm working on a Flask app that uses url_for to specify the route to some static assets (js, css, etc). Here's an example from one of the templates: <script src='{{ url_for('static', filename='js/search.js') }}'></script> When this gets rendered into html, the path looks like this: <script src='/static/js/search.js'></script> Is it possible to modify this behavior such that the leading slash is dropped from the rendered script path? The goal is to render the following: <script src='static/js/search.js'></script> I'd be very grateful for any insights others can offer on this question! I was

ASP.NET MVC - Use Reflection to find if a Controller Exists

风流意气都作罢 提交于 2019-12-03 09:06:11
I'm having a heck of a time figuring out how to properly implement my 404 redirecting. If I use the following <HandleError()> _ Public Class BaseController : Inherits System.Web.Mvc.Controller ''# do stuff End Class Then any unhandled error on the page will load up the "Error" view which works great. http://example.com/user/999 (where 999 is an invalid User ID) will throw an error while maintaining the original URL (this is what I want) However. If someone enters http://example.com/asdfjkl into the url (where asdfjkl is an invalid controller), then IIS is throwing the generic 404 page. (this

MVC3 Routing Basics

会有一股神秘感。 提交于 2019-12-03 09:04:12
I am learning MVC routing. Hope my question doesn't look silly, and please help :) public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.MapRoute( "Default", // Route name "{controller}/{action}/{id}", // URL with parameters new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults ); Msdn reference says it takes a String, String, Object, so I try to make a small change (added a "my" in front of everything just to mod the names and see if it works): public static void RegisterRoutes