routes

Playframework route file: Separate Production routes from Dev routes

折月煮酒 提交于 2019-12-03 18:35:34
问题 Is there a way in Play to annotate routes to inform that a certain section/group routes is only available in dev or prod mode 回答1: Well, this is not documented, so I am not sure if this is intentionally possible or not, but I have found a way to make this work. Please note however, as this is an undocumented feature, may mean it is unintended, and therefore may break in future versions of play. You are able to achieve what you want using the following line in your routes file. %{ if (play

AngularJs - best way to limit access to 'logged in' users

有些话、适合烂在心里 提交于 2019-12-03 18:26:36
问题 I'm struggling with setting up a login system for an app i'm creating. I'm able to set cookies for when the user is logged in or out. I don't think that testing every view if the user is logged in is a very elegant solution, and i'm afraid a page here and there may fall through the cracks (it's a rather large app). I'm thinking the best way would be to intercept route changes somehow and check if the user is logged in, otherwise send them to a login/create user page. I've found a few methods,

Programmatically create new routes in Ember

心已入冬 提交于 2019-12-03 17:49:44
问题 I am using a json file pulled from the server to configure my website, and to tell each page what it's title is. The json file looks like this: [{"route": "student", "title": "Student Info Page"}, {"route": "payments", "title": "Payments and Pricing"}, {"route": "policy", "title": "Mine"}, {"route": "biography", "title": "About Me"}] which is used to create a navigation bar with this code: App.MenuController = Ember.ArrayController.create(); $.get('config.json', function(data) { App

Overriding a resource route to / (root) in Rails3: not changing the path helper?

我们两清 提交于 2019-12-03 17:39:12
问题 I am quite new to Rails3, I basically created a subscribers scaffolding, I only want my app to respond to new and create actions. So in config/routes.rb I defined: resources :subscribers, :only => [:new, :create] Which works this way GET /subscribers => subscribers#new POST /subscribers => subscribers#create Now I want my app to exhibit the subscribers resources at / (root) instead of /subscribers , so here is what I did: match '/' => "subscribers#new" match '/' => "subscribers#create" match

Angularjs ngResource '@id'

左心房为你撑大大i 提交于 2019-12-03 16:44:29
I have a quick question. In angular js where (like which object) does the '@id' come from in the following piece of code from a rails app? var User = $resource("/users/:id", {id: '@id'}); I know it sets the default id. Thanks From the AngularJs documentation : "If the parameter value is prefixed with @ then the value of that parameter is extracted from the data object (useful for non-GET operations)." This means that when calling a non-GET operation, like POST, you can pass the id as one of the fields of the data object you include in the call. 来源: https://stackoverflow.com/questions/15059764

Matching and Routes in Rails

ε祈祈猫儿з 提交于 2019-12-03 16:39:06
问题 I generated a controller and changed the routes but opening the links yields errors on my local server. Generating controller and routes rails generate controller StaticPages home about team contact Change routes.rb MyApp::Application.routes.draw do root to: 'static_pages#home' match '/about', to: 'static_pages#about' match '/team', to: 'static_pages#team' match '/contact', to: 'static_pages#contact' end The root path work but none of the 'about, 'team', or 'contact' links work. This is the

Rails 3.1 force .html instead of no extension

二次信任 提交于 2019-12-03 16:23:12
One of my clients wants his new Rails application to look more like his traditional web site. He wants to know if I can force urls to have a file extension, preferably .html . I don't want to hard-code the extension in routes.rb as match ':controller/:action/:id.html' (or similar) because the client also wants to have a respond_to -style JSON API which requires the use of .:format . Can this be done? Just as Mattias Wadman suggested, in config/application.rb add: AppName::Application.default_url_options = { :format => "html" } But also change config/routes.rb to: root :to => 'pages#home',

yii: internationalization (i18n) and dynamic url manager

谁说我不能喝 提交于 2019-12-03 16:20:56
I would like to know a better way to implement "internationalization (i18n)" and "dynamic URL management" in Yii framework. A (difficult to maintain) temporary solution: // protected/config/main.php 'language' => 'es', ... 'urlManager'=>array( 'urlFormat'=>'path', 'showScriptName' => false, 'rules'=>array( // pages 'es/turismo/<slug:>' => array('visit/page', 'defaultParams' => array('lang' => 'es'), 'urlSuffix' => '.html'), 'it/visita/<slug:>' => array('visit/page', 'defaultParams' => array('lang' => 'it'), 'urlSuffix' => '.html'), 'en/travel/<slug:>' => array('visit/page', 'defaultParams' =>

Symfony2 dynamic routing - caching issue

谁都会走 提交于 2019-12-03 16:18:57
问题 I'm trying to create dynamic routes as I have created a CMS where each page created can be associated to a route. I'm using the example from this link - http://php-and-symfony.matthiasnoback.nl/2012/01/symfony2-dynamically-add-routes/ and all works fine, however the routing is cached, therefore one route will work but then the next won't unless I clear the cache. Is it possible to remove just the routing cache at this stage or is there another alternative? I don't want to remove the whole

Angular 2 Get current route

大憨熊 提交于 2019-12-03 16:05:05
问题 So I need somehow check if I am on home page and do something and in other pages don't do that. Also that component imported on all of pages. How can I detect on that component if I'm on home page??? Thanks 回答1: Try this, import { Router } from '@angular/router'; export class MyComponent implements OnInit { constructor(private router:Router) { ... } ngOnInit() { let currentUrl = this.router.url; /// this will give you current url // your logic to know if its my home page. } } 回答2: Try it