routes

Shorten Zend Framework Route Definitions

点点圈 提交于 2019-12-04 08:45:20
问题 How can I shorten the definition of my custom routes in Zend Framework? I currently have this as definition: $route = new Zend_Controller_Router_Route( ":module/:id", array( "controller" => "index", "action" => "index" ), array("id" => "\d+") ); self::$frontController->getRouter()->addRoute('shortcutOne', $route); $route = new Zend_Controller_Router_Route( ":module/:controller/:id", array("action" => "index"), array("id" => "\d+") ); self::$frontController->getRouter()->addRoute('shortcutTwo'

Ending a Rails 2 URL with an IP address causes routing error?

一个人想着一个人 提交于 2019-12-04 08:42:54
问题 I'm trying to construct URLs in the format http://servername/find/by/CRITERION/VALUE CRITERION is a finite set of strings, as is VALUE. Trouble is, VALUE needs to be an IP address in some situations, and it's causing me a routing error. Here's my route: map.find 'find/by/:criterion/:query', :controller => "find", :action => "by" And the error, from the Mongrel logs: Processing ApplicationController#index (for 127.0.0.1 at 2010-05-07 10:20:32) [GET] ActionController::RoutingError (No route

Rails routes with dates

≯℡__Kan透↙ 提交于 2019-12-04 08:37:07
So I have a weekly calendar view and I have a route set up to accept /:year/:month/:day for the start date. match "events/(:year/:month/:day)" => "events#index", :constraints => { :year => /\d{4}/, :month => /\d{2}/, :day => /\d{2}/ }, :as => "events_date" I have two questions regarding the use of this route. First, when parsing the params, this is what I'm doing: unless params[:year].nil? || params[:month].nil? || params[:day].nil? start_date = Date.new(params[:year].to_i, params[:month].to_i, params[:day].to_i) end start_date = start_date.nil? ? Date.today : start_date This strikes me as

How to override Rails app routes from an engine?

孤街醉人 提交于 2019-12-04 08:30:01
I have a Rails app that I am trying to integrate a Rails engine in to. The host app has some catch all routes: # magic urls match '/' => 'admin/rendering#show' match '*path/edit' => 'admin/rendering#show', :defaults => { :editing => true } match '*path' => 'admin/rendering#show' It looks like the engine routes are loaded after the application catches all routes. /sitemap.xml(.:format) {:format=>"xml", :controller=>"admin/sitemaps", :action=>"show"} /(.:format) {:controller=>"admin/rendering", :action=>"show"} /*path/edit(.:format) {:controller=>"admin/rendering", :action=>"show"} /*path {

Symfony2, Is it possible to have two route for one action in a controller?

梦想与她 提交于 2019-12-04 08:26:50
I have an action inside my controller class and I want two different routes like below: /** * Displays a form to create a new entity. * * @Route("/edit/choose/date", name="user_choose_date") * @Route("/supervisory/choose/date", name="sup_choose_date") * @Template() */ public function chooseDateAction() { return array( ); } The reason for that I would like to give the route access to some users but the user role are different. Let's say: User with supervisor role can access sup_choose_date User with user role can access user_choose_date The question is if it is possible to have two different

Routing concerns defining different param for resources

爱⌒轻易说出口 提交于 2019-12-04 07:47:01
Recently I got to know about rails concerns in routes from this discussion How to have one resource in routes for namespace and root path altogether - Rails 4 . Now in my application I have routes like this: namespace :admin do resources :photos resources :businesses resources :projects resources :quotes end resources :photos, param: 'slug' resources :businesses, param: 'slug' do resources :projects, param: 'slug' #As I need both the url one inside business and one outside end resources :projects, param: 'slug' resources :quotes, param: 'slug' And there are many more resources which are

How to remove route on overrided module?

做~自己de王妃 提交于 2019-12-04 07:02:52
问题 I added zfcUser module to my project via Composer and overrided it in the module ZfcUserOverride . I want trailing slash work, so I added route in overrided module. zfcUserOverride file module.config.php contents below: <?php $config = array( 'view_manager' => array( 'template_path_stack' => array( 'zfcuser' => __DIR__ . '/../view', ), ), 'controllers' => array( 'invokables' => array( 'zfcuser' => 'ZfcUserOverride\Controller\UserController', ), ) ); $config['router']['routes']['zfcuser'][

Rails pages_controller_spec.rb test shouldn't be failing but is, error?

陌路散爱 提交于 2019-12-04 06:54:18
问题 Have been following Rails Tutorial by Michael Hart rails version 3.0 on mac OS X 10.7 $ rspec spec/ ......FF Failures: 1) PagesController GET 'help' should be successful Failure/Error: get 'help' ActionController::RoutingError: No route matches {:controller=>"pages", :action=>"help"} # ./spec/controllers/pages_controller_spec.rb:45:in `block (3 levels) in <top (required)>' 2) PagesController GET 'help' should have the right title Failure/Error: get 'help' ActionController::RoutingError: No

How can I create the Route in Kohana 3.2 for this directory structure: /application/my_use_case/classes/

三世轮回 提交于 2019-12-04 06:43:47
问题 I'm using Kohana 3.2 and I need to create the directory structure below for my application. For that, I'm using the Route below, but I'm doing something wrong yet. "Settings" is my use case that I'm developing. <?php Route::set('global', '<directory>(/<controller>(/<action>))', array('directory' => 'settings')) ->defaults(array( 'directory' => 'settings', 'controller' => 'settings', 'action' => 'index', )); ?> So, this is my directory structure for "Settings" use case: - ..\application

polymorphic_path for custom collection route

て烟熏妆下的殇ゞ 提交于 2019-12-04 06:31:20
I have the following route definition: resources :documents do collection do post :filter end end and the following model structure: class Document < ActiveRecord::Base belongs_to :documentable, :polymorphic => true end class User < ActiveRecord::Base has_many :documents, :as => :documentable end and controller structure: class DocumentsController < ApplicationController def index # not important end def filter # not important end end I can easily in a view say: polymorphic_path([@user, Document]) to get the path /users/1/documents , but I want to be able to say: filter_polymorphic_path([@user