routes

Understand Laravel route with optional parameter

淺唱寂寞╮ 提交于 2019-12-13 07:39:11
问题 I'm trying to create a route with one optional parameter with Laravel 5.4. Route : Route::get('/run/{zone?}/id/{id}', 'RunController@show'); Controller : class RunController extends Controller { public function show() { $route = \Route::current(); $zone = $route->parameter('zone') ?: 'default'; $id = $route->parameter('id'); Run::setZone($zone); $run = Run::findOrFail($id); return view('run.show')->with(['run' => $run]); } } The url run/test/id/42 works like expected. But with run/id/42 I got

When my SEO text slug in the URL ends with a dot symbol, I get a 404 error

℡╲_俬逩灬. 提交于 2019-12-13 07:26:09
问题 Quite strange! Here is the custom route: routes.MapRoute( "Dota2-News-Details", // Route name "dota2-news/{id}/{slug}", // URL with parameters new { controller = "Dota2News", action = "Detail", slug = "", id = UrlParameter.Optional } // Parameter defaults ); Working links: http://localhost:20099/dota2-news/3/Some-random-post http://localhost:20099/dota2-news/5/Another-random-post http://localhost:20099/dota2-news/14/New-delicious-items Non-working links: http://localhost:20099/dota2-news/4

Why does Rails not recognise project_path

回眸只為那壹抹淺笑 提交于 2019-12-13 07:23:35
问题 I wonder if anyone can help with this...its driving me crazy. Firstly I'm still pretty new to all of this. So apologies if I get some terminology wrong. I have completed some tutorials and am now working on my first app without any guided walkthroughs... its slow going :) I have two groups of pages, one group where I should show a sidebar and one group that does not need it. Below are my routes... Rails.application.routes.draw do #----Pages---- root 'pages#home' get '/home', to: 'pages#home'

Cakephp Routes And General Routing

最后都变了- 提交于 2019-12-13 07:17:10
问题 I have a controller with an action and a variable like this: class AccountsController extends AppController { function profile($username = null) { } } The url for this page is: [domain]/accounts/profile/[username] How do I make it: [domain]/[username] ? 回答1: Try: //in your routes.php file Router::connect('/:username', array('controller' => 'accounts', 'action' => 'profile'), array( 'pass' => array('username') ) ); Hope it helps 来源: https://stackoverflow.com/questions/8753671/cakephp-routes

CodeIgniter - Routing issues (four segments)

荒凉一梦 提交于 2019-12-13 07:16:12
问题 Following what I thought was an issue with $this->uri->segment(), I figured out that it is actually a routing issue. Problem is that I can't really figure out what is wrong, as it looks exactly like another route I am using, which works fine, except this one has two variable segments, rather than one (for the route that is working). The file I am trying to show is located in: [main folder]/application/views/tasks/calendar/calendar.php And I can load it with the command: $route['tasks/calendar

Laravel 5.3 Auth:attempt is not working

谁都会走 提交于 2019-12-13 06:46:11
问题 Dont matter if i insert valid or invalid credentials, the user is always redirect to the route defined in RedirectIfAuthenticated middleware. My question: How can i redirect authenticated users to different route than non authenticated user? RedirectIfAuthenticated (Middleware): public function handle($request, Closure $next, $guard = null) { if (Auth::guard($guard)->check()) { return redirect('/'); } return $next($request); This is my LoginController: public function __construct() { $this-

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

二次信任 提交于 2019-12-13 05:36:07
问题 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 does EmberJS select template for a Route?

☆樱花仙子☆ 提交于 2019-12-13 05:23:09
问题 I have these routes defined: this.resource('projects', function() { this.resource('project', { path: ':project_id'}, function() { this.route('details'); this.route('members'); }); }); What I thought was that by convention project.details route would look for "project/details" template. It does but strangely it does not get the correct model. See http://jsbin.com/ELaxigE/19/edit Now instead of providing "project/details" template if I create "project" template then it works. See http://jsbin

Kohana 3.2 Route - controllers in subdirectories

霸气de小男生 提交于 2019-12-13 05:21:07
问题 I need to create next structure: +controller ++admin +++catalog ++++category.php ++++product.php +++users and I need to open them by url /admin/catalog/category/action/param I tried to create route: Route::set('admin', '(<directory>(/<controller>(/<action>(/<custom_param>))))',array( 'directory' => '(admin/.*)' )) ->defaults(array( 'controller' => 'dashboard', 'action' => 'index' )); 回答1: Not tested: Route::set('admin', 'admin/<directory>/(<controller>(/<action>(/<custom_param>)))', array(

link_to Base URL Randomly Changed

这一生的挚爱 提交于 2019-12-13 04:56:53
问题 I'm using link_to to create a custom link. For some reason, my url always is wrong and randomly adds blog to the URL. I can't figure out why. It only does this while within the partial that I am rendering (3 times on the page). I can share any code necessary, but where the hell would it randomly grab the blog URL? The browser renders: <a href="/blog?controller=quote">Select Rate</a> My view (using slim ) is: - for rate in loantek_rates - loantek_closing_costs = LoantekClosingCosts.new(rate) =