routes

Periods not allowed in CodeIgniter URI?

寵の児 提交于 2019-12-04 06:30:11
问题 So after reading this question on API versioning, I decided to prefix all my routes with a version number: http://localhost/api/1.0/user/login But when I throw an exception within Exceptions Core, it says that the route is: 10/UserControll... I've tried escaping the period, but this did not work. Can anyone replicate this problem and think of a possible solution for it? This is the route I am using for the above: $route['1.0/user/(:any)'] = '1.0/UserController/$1'; These are my permitted URI

Ruby On Rails Updating Heroku Dynamic Routes

别等时光非礼了梦想. 提交于 2019-12-04 06:25:19
问题 I've got an app which uses app-wide slugs (uses Slugalicious gem with Sluggable table), and have routed to these slugs by using this code: #Slugs begin Slug.all.each do |s| begin get "#{s.slug}" => "#{s.sluggable_type.downcase.pluralize}#show", :id => s.slug rescue end end rescue end I currently update the routes when I update the slugs model with this code: after_save :update_routes def update_routes Rails.application.reload_routes! end This works perfectly in dev: The problem I'm getting is

Rails: Wrong hostname for url helpers in rspec

时间秒杀一切 提交于 2019-12-04 06:25:18
Url helpers (e.g root_url) returns a different hostname in the app controllers vs rspec examples. I have successfully been able to set the domain for url helpers in my rails app like this: class ApplicationController < ActionController::Base def default_url_options {host: "foo.com", only_path: false} end end For example, root_url outputs "http://foo.com/" within the application but "http://example.com" in my request specs. What is the recommended way to apply those url options globally in rails 3.2 so that they affect my specs? The url options do not need to be dynamic. Amin Ariana In Feature

Laravel / Host Setup for Multi-TLD

馋奶兔 提交于 2019-12-04 05:44:52
问题 Basically Ive written out this about 5 times, still dont know how to properly ask, so here goes... I want two domains, say example.net and example.info which I have registered. I want them to point to the one application I'm building, then hopefully use Laravel to route the two different domains to there own pages... here is what I've tried and what problems I've ran into... ** #1 Domain Forward ** Uploaded my app to example.net and forwarded the .info domain to the .net domain. And then

Every link_to on my rails 4 application is being called twice

人盡茶涼 提交于 2019-12-04 05:44:44
I'm experiencing some unusual behaviour with my Rails 4 Application. Every single-time I click on a link_to inside my views, my controllers actions are being called twice. For example: In my root_url I have this standard call for users_profile : <%= link_to('User Profile', users_profile_path, :class => "logout-button") %> When I click this link, my console shows the following output: Started GET "/users/profile" for 127.0.0.1 at 2013-11-25 20:45:53 -0200 Processing by Users::SessionsController#profile as HTML User Load (0.7ms) SELECT "users".* FROM "users" WHERE "users"."id" = 45 ORDER BY

Should I Nest Routes to Resources in Laravel?

99封情书 提交于 2019-12-04 05:20:47
This may be a little subjective, but I feel that best-practice must exist (or even good design when it comes to Laravel apps). Googling results in lots of things that are not to do with the actual points in this question. Say I am building a web application that has teams, which may have projects, which may have documents. Should I design the routing so that documents are within the path of the projects they belong to, which are then within the path of the teams they belong to, or keep things at a top level? As far as I can tell, there are two ends to this spectrum that are worth discussing

codeigniter get all declared routes

自闭症网瘾萝莉.ら 提交于 2019-12-04 04:34:29
How to get all declared routes in codeigniter? like ex. print_r($route) Because this is the problem, if the customer registered his username as 'facebook' he will be routed to account/facebook_login and not to his profile, if i changed the order of routes, all links will be routed to customer/profile and this is a no no! So basically, instead of listing all the routes that i declare and put it into an another array or db table, i want to loop into route array and check if there is a word that has been declared already so that i can stop them to register that word as their username. this is my

Handling route errors in ASP.NET MVC

蓝咒 提交于 2019-12-04 04:25:58
I understand how to set up my own routes, but how does one handle routes that fall through the cracks of the routing table? I mean, I guess the default {controller}/{action}/{id} route could be a generic catchall, but I'm not sure if that's the way to go. I like letting my users know they've requested data/a 'page' that doesn't exist. Is this where the [HandleError] filter comes in? How does that work, exactly? If your route is not found, you want to handle it as a normal HTTP 404 error. If you only add the [HandleError] attribute to your class or action, MVC will look for an Error view in

Why dataTokens are in Route?

我只是一个虾纸丫 提交于 2019-12-04 03:12:29
问题 context.MapRoute("authorized-credit-card", "owners/{ownerKey}/authorizedcreditcard/{action}", new { controller = "authorizedcreditcard", action = "index" }, new { ownerKey = nameFormat }, dataTokens: new { scheme = Uri.UriSchemeHttps }); In my route file I am having above kind of Route. So, could any one tell me what is the meaning of dataTokens: new { scheme = Uri.UriSchemeHttps ? And usage of above dataTokens inside the controller's action method ? 回答1: According to the documentation: You

Create RouteValueDictionary with multivalued keys

允我心安 提交于 2019-12-04 03:01:54
问题 I'd like to return a RedirectToRouteResult that sends users to a URL like the following: /MyController/MyAction/id?newid=3&newid=5&newid=7 The newid parameter has several values. My call looks like: return RedirectToAction(string.Empty, routeValues); Here is what I have tried so far, and that do not work: // ...?newid%5B0%5D=3&newid%5B1%5D=5&newid%5B2%5D=7 var routeValues = new RouteValueDictionary { {"id", myid}, {"newid[0]", 3}, {"newid[1]", 5}, {"newid[2]", 7}, }; // ...?newid=System.Int32