routes

How to bind Double parameter with Play 2.0 routing

谁都会走 提交于 2019-11-29 08:55:33
问题 I'm learning myself Play 2.0 (Java API used) and would like to have a double/float parameter (for location coordinates), something like http://myfooapp.com/events/find?latitude=25.123456&longitude=60.251253. I can do this by getting the parameters as String and parsing them at controller etc but can I use automatic binding here? Now, I first tried simply having one double value: GET /events/foo controllers.Application.foo(doublevalue: Double) with public static Result foo(Double doublevalue)

CodeIgniter Routing Folder Error

偶尔善良 提交于 2019-11-29 08:01:22
I have the CodeIgniter controller file, placed in here controllers/public/Pubweb.php and I want to set that file as my default controller, but when I change the default controller route value, it will goes error. My route code : $route['default_controller'] = 'public/pubweb'; Can someone help me? On CodeIgniter 3 It does not allow you to have a sub folder on $route['default_controller'] you will instead need to create a MY_Router.php file like below. You will need to create a MY_Router.php in application > core > MY_Router.php Here is a MY_Router.php file that should allow you to use $route[

Trigger same location route

半城伤御伤魂 提交于 2019-11-29 07:38:41
问题 Is there a way to trigger same location route in backbone.js, for example when location is /My/App/#/About and user clicks again on anchor with the same route in order to refresh the page content. 回答1: Router.navigate('about', true); That way you can trigger a route manually. 回答2: Backbone.history.loadUrl(Backbone.history.fragment); The solution for your specific problem isn't really documented and it seems the suggested best practice is to just call the function that is declared in the route

Rails No route matches {:controller=>“devise/products”}

。_饼干妹妹 提交于 2019-11-29 07:14:22
I get the below error on my rails application when I try to login or register (I'm using the Devise GEM for logins). Routing Error No route matches {:controller=>"devise/products"} All the source code for the application can be found here: https://github.com/rossmc/topsnowboards I've tried changing the link_to in application.html.erb & product/index.html.erb from: <%= link_to 'sign in', new_user_session_path %> to: <%= link_to 'sign in', :controller => "/products", new_user_session_path %>. But this just throw up more errors. Interestingly the login features & routes were working fine before I

Url Form Action Without ViewContext

北城以北 提交于 2019-11-29 05:14:51
Is it possible to get a URL from an action without knowing ViewContext (e.g., in a controller)? Something like this: LinkBuilder.BuildUrlFromExpression(ViewContext context, Expression<Action<T>> action) ...but using Controller.RouteData instead of ViewContext. I seem to have metal block on this. Craig Stuntz Here's how I do it in a unit test: private string RouteValueDictionaryToUrl(RouteValueDictionary rvd) { var context = MvcMockHelpers.FakeHttpContext("~/"); // _routes is a RouteCollection var vpd = _routes.GetVirtualPath( new RequestContext(context, _ routes.GetRouteData(context)), rvd);

Drawing routes using user name in Rails 3 w/ devise

ⅰ亾dé卋堺 提交于 2019-11-29 05:10:14
Given a one to many relationship between a user managed with devise and a "thing", my goal is to draw restful routes like: http://host/username http://host/username/things http://host/username/things/1 ... I am aware of nested resources in Rails routes, but I can't figure out how to apply it to a generic User model created and managed via devise. You can use scope for this: scope ":username", :as => "user" do resources :things end Combine this with to_param on the user model: def to_param username end And you'll have routes such as /username/things . Be careful though, the username shouldn't

Nested resource route helper not working

风格不统一 提交于 2019-11-29 04:06:53
I have a nested route like so: resources :apps do resources :issues end the helper for seeing all issues related to an app is as follows: app_issues_url(app) but now I want to use a helper to point to a specific issue of a specific app like apps/1/issues/1 but i don't know how to use that helper. what is the helper for this url? you can pass both instances to url helper like app_issue_url(@app,@issue) you can also use app_issue_path(@app,@issue) or url_for([@app,@issue]) see rails doc for more info 来源: https://stackoverflow.com/questions/8207644/nested-resource-route-helper-not-working

How to create a catch-all route in Ruby on Rails?

蹲街弑〆低调 提交于 2019-11-29 04:01:26
I want to have all requests that satisfy a certain constraint to go to a specific controller. So I need a catch-all route. How do I specify that in Rails? Is it something like this? match '*', to: 'subdomain_controller#show', constraints: {subdomain: /.+\.users/} Will that really catch all possible routes? It's important that none slip through even if there are many nested directories. Using Ruby on Rails 3.2, but ready to upgrade to 4.0. UPDATE : '*path' seems to work. However, the issue I'm running into is whenever the file exists in my public directory, Rails renders that instead. I think

Symfony2 how to allow slug with dashes in routes regex?

别来无恙 提交于 2019-11-29 03:24:43
My route (slug contains dashes!): region: pattern: /regione/{slug}-{id} defaults: { _controller: SWAItaliaInCifreBundle:Default:region } In Twig template: {% for r in regions %} <a href='{{ path('region', { 'slug':r.slug, 'id':r.id }) }}'>{{ r.name }}</a> {% endfor %} I'm getting an error about regular expression matching. Question : why Symfony2 does not permit dashes in url? How can i specify that my route contains dashes (and it's perfectly fine)? An exception has been thrown during the rendering of a template ("Parameter "slug" for route "region" must match "[^/-]+?" ("valle-d-aosta-vallee

Getting gateway to use for a given ip in ANSI C

无人久伴 提交于 2019-11-29 03:19:43
I have looked around like crazy but don't get a real answer. I got one example, but that depended on the individuals own library so not much good. At first I wanted to get the default gateway of an interface, but since different IP's could be routed differently I quickly understood that what I want it get the gateway to use for a given destination IP by using an AF_ROUTE socket and the rtm_type RTM_GET . Does anyone have an example where I actually end up with a string containing the gateways IP (or mac address)? The gateway entry seem to be in hex but also encoded in /proc/net/route, where I