routes

Accessing rails routes in javascript

有些话、适合烂在心里 提交于 2019-12-17 18:15:48
问题 Can anyone explain how i can access the rails routes/names routes in javascript ? The following are some of the things i tried http://github.com/jsierles/js_named_routes. but no luck. 回答1: I was researching this question for a while and didn't found any implementation compatible with Rails 3. So decided to write my own: https://github.com/railsware/js-routes 回答2: kishore I think this is the simpliest way, just call: Rails.application.routes.url_helpers.*_path So, if you have in your routes.rb

How to use router.navigateByUrl and router.navigate in Angular

倖福魔咒の 提交于 2019-12-17 18:15:10
问题 https://angular.io/api/router/RouterLink gives a good overview of how to create links that will take the user to a different route in Angular4, however I can't find how to do the same thing programmatically rather needing the user to click a link 回答1: navigateByUrl routerLink directive as used like this: <a [routerLink]="/inbox/33/messages/44">Open Message 44</a> is just a wrapper around imperative navigation using router and its navigateByUrl method: router.navigateByUrl('/inbox/33/messages

How does MVC routing work?

两盒软妹~` 提交于 2019-12-17 17:34:03
问题 So I've started studying MVC (real MVC, not framework MVC) a bit more in-depth, and I'm attempting to develop a small framework. I'm working by reading other frameworks such as Symphony and Zend, seeing how they do their job, and attempt to implement it myself. The place where I got stuck was the URL routing system: <?php namespace Application\Common; class RouteBuilder { public function create($name, $parameters) { $route = new Route($name); $route->resource = array_keys($parameters)[0];

AngularJS How to remove # symbol in IE9 by using route

∥☆過路亽.° 提交于 2019-12-17 16:58:06
问题 I can't remove the # symbol in IE9. I searched for an answer but didn't find a fix. This always redirects to http://myhost.com:8080/#/website/ and shows this description: The requested resource is not available. locationprovider.html5mode(true) is not working. The same route is working in FireFox and shows http://myhost.com:8080/website/ How can I rectify this? 回答1: IE9 does not have html5 history api support, that's why it's appending # to the url, removing # will not solve your problem 回答2:

Rails 3 route appends _index to route name

那年仲夏 提交于 2019-12-17 16:16:11
问题 I am migrating a Rails 2.3.8 version to Rails 3.0 and so ive rewritten my routes file. When i list the routes using rake routes , i see some route names have _index appended to them. I cant figure out why this is. Relevant routes: Rails 2.3.8: map.namespace "tracker", :path_prefix => "" do |planner| planner.resources :planner, :collection => {:step1 => :get, :add => :get, :unsubscribe => [:get, :post] } end Rails 3.0 route: namespace "tracker", :path => "" do resources :planner do collection

laravel Unable to prepare route … for serialization. Uses Closure

余生颓废 提交于 2019-12-17 15:47:25
问题 When I clear caches in my Laravel 5.2 project, I see this error message: [LogicException] Unable to prepare route [panel] for serialization. Uses Closure. I think that it's related with a route Route::get('/article/{slug}', 'Front@slug'); associated with a particular method in my controller: public function slug($slug) { $article = Article::where('slug',$slug)->first(); $id = $article ->id_article ; if ( ($article=== null) || (is_null($id)) ) return view('errors/Db'); else return view('detail

MVC 2 AreaRegistration Routes Order

社会主义新天地 提交于 2019-12-17 10:56:07
问题 I noticed that in MVC 2 Preview 2, AreaRegistration is loading the routes for each area in an arbitrary order. Is there a good way to get one before the other? For example, I have two areas - "Site" and "Admin". Both have a "Blog" controller. I would like the following: /admin/ --> go to Admin's Blog controller / --> go to Site's Blog controller. The problem is that it is loading the site's route first, so it is matching {controller}/{action}/{id} instead of admin/{controller}/{action}/{id}

How do I write a Rails 3.1 engine controller test in rspec?

房东的猫 提交于 2019-12-17 10:27:25
问题 I have written a Rails 3.1 engine with the namespace Posts. Hence, my controllers are found in app/controllers/posts/, my models in app/models/posts, etc. I can test the models just fine. The spec for one model looks like... module Posts describe Post do describe 'Associations' do it ... end ... and everything works fine. However, the specs for the controllers do not work. The Rails engine is mounted at /posts, yet the controller is Posts::PostController. Thus, the tests look for the

Rails Routes - Limiting the available formats for a resource

♀尐吖头ヾ 提交于 2019-12-17 07:30:53
问题 I have a series of resources that I want only available if accessed via the JS format. Rails' route resources gives me the formats plus the standard HTML. Is there a way to specify that only the JS format routes be created? 回答1: You just add constraints about format : resources :photos, :constraints => {:format => /(js|json)/} 回答2: You must wrap those routes in a scope. Constraints unfortunately don't work as expected in this case. This is an example of such a block... scope :format => true,

How can I have lowercase routes in ASP.NET MVC?

人盡茶涼 提交于 2019-12-17 04:37:19
问题 How can I have lowercase, plus underscore if possible, routes in ASP.NET MVC? So that I would have /dinners/details/2 call DinnersController.Details(2) and, if possible, /dinners/more_details/2 call DinnersController.MoreDetails(2) ? All this while still using patterns like {controller}/{action}/{id} . 回答1: With System.Web.Routing 4.5 you may implement this straightforward by setting LowercaseUrls property of RouteCollection: public static void RegisterRoutes(RouteCollection routes) { routes