routes

How do I validate restful parameters in rails at the routing level?

早过忘川 提交于 2019-12-12 12:12:15
问题 I currently have the following restful url: /questions/2011/05/ My route for questions is: match 'questions/:year/:month/' => 'Questions#month' How can I validate the above year and month parameters at the route level so that: year and month are integers min/max length of year = 4 min/max length of month = 2 In django, I can do the above with the following line: url(r'^questions/(?P<year>\d{4})/(?P<month>\d{2})/$', 'questions.views.month'), I'm looking through the rails guide and googling

Refresh / Reload ember route from a component

谁说我不能喝 提交于 2019-12-12 11:27:55
问题 I have a component, that's actually a modal dialog. When I am done with that dialog and press the "Ok" button, I want to stay on the stay page from where I opened that dialog. Which isn't difficult. But the problem is that the dialog changes the data (I am getting data through a REST call) so I need to refresh the route that I already am on to reflect the data changes. Since, I am calling it from a component, I don't have Route so can't call route.refresh() . I tried to get the router: this

Rails - superclass mismatch

非 Y 不嫁゛ 提交于 2019-12-12 11:07:20
问题 Playing with Rails and controller inheritance. I've created a controller called AdminController , with a child class called admin_user_controller placed in /app/controllers/admin/admin_user_controller.rb This is my routes.rb namespace :admin do resources :admin_user # Have the admin manage them here. end app/controllers/admin/admin_user_controller.rb class AdminUserController < AdminController def index @users = User.all end end app/controllers/admin_controller.rb class AdminController <

Adding security on routes in Rails

旧街凉风 提交于 2019-12-12 10:19:06
问题 In Rails 2, how can I prevent a user from just changing the id # and accessing other Objects? For example : website.com/users/1231/edit How do I prevent a user from changing the 1231 and accessing another account? 回答1: Use a before_filter in your controllers. class Users < ApplicationController before_filter :require_user, :only => [:show] private def require_user @user = User.find_by_id(params[:id]) redirect_to root_url if @user.nil? end end 回答2: @user = User.find params[:id] redirect_to

Dealing with Alias URLs in CakePHP

Deadly 提交于 2019-12-12 10:15:41
问题 I am rewriting our company website in cakephp, and need to find a way to do the following: A user enters our site by using one of the promotional alias URLS that has been pregenerated for a specific media advert ( magazine, web promotion etc ) The URL is checked against a database of alias URLs, and if an alias exists, then a specific tracking code is written into the session. I have considered several options, none of which seem suitable for this purpose. They are: Putting the lookup script

Can't find the error in my route in Laravel with Ajax

被刻印的时光 ゝ 提交于 2019-12-12 09:58:17
问题 I'm using Laravel 5.6, and I have an error : Whoops, looks like something went wrong. (1/1) MethodNotAllowedHttpException and the following is my view (leads/show.blade.php): <form method="post" id="student_form"> {{csrf_field()}} <span id="form_output"></span> <div class="form-group"> <label>Choose Group for Your Lead</label> <select name="group_id" id="group_id" class="form-control"> @foreach($groups as $group) <option value="{{$group->id}}"> {{$group->name}}</option> @endforeach </select>

How to change $routeParams parameters?

泄露秘密 提交于 2019-12-12 09:38:37
问题 Im accessing this url: http://bazarak.af/#!/annonser/page=1&... .when("/annonser/:query",{ templateUrl: '/views/search.php', controller: "Search" }) I would like to get the value of page and change it both in the url and in the routeParams. To get the page value I have tried var pageNumber = $routeParams.page; and to set it I have tried: $routeParams ==> {page:5} None of this works. And the documentation is not really helping me. How can I do this? 回答1: Use $location.path() to set new URL

Rails 2 Namespace and Shallow Routes Issue

浪子不回头ぞ 提交于 2019-12-12 09:27:53
问题 I've written the admin area of a particular rails app and now I'm ready to set it as own section within the website. Therefore, it will be /admin However, I didn't want to have it as /admin within the route itself I wanted to have something less common, so I added a couple of hyphens before and after it. So the route is /-admin-/ and the namespace is Admin. After setting this up using :path_prefix => "/-admin-", I have the following code block: map.namespace "/-admin-/", :name_prefix => "",

Does angular2 support nested states/routes?

此生再无相见时 提交于 2019-12-12 07:09:19
问题 Does angular2 support nested states/routes? for example in a view port there are 2 links and on clicking a specific link it will present a view which with further have more than one link but that are specific to earlier link. 回答1: Yes. I made some demo: http://plnkr.co/edit/IcnEzZ0WtiaY5Bpqrq2Y?p=preview import {Component, View, Input} from 'angular2/core'; import { RouteConfig, Router, RouteParams, ROUTER_DIRECTIVES } from 'angular2/router'; import {PersistentRouterOutlet} from './persistent

Codeigniter. How to pass parameters $ _GET in the route.php?

懵懂的女人 提交于 2019-12-12 07:00:31
问题 This code $route['basketball'] = "controller/product/?id=7" does not work. function product() { echo $_GET['id'] // no output } How to describe the rules in the route? 回答1: If possible use CodeIgniter's standard URL routes. In your case: $route['basketball'] = "controller/product/7"; function product() { } OR if $_GET['id'] needs to be dynamic $route['basketball/:num'] = "controller/product"; function product($id) { } Hope that helps. 回答2: Because you are in PHP , you can basically set $_GET