routes

users_path(user) returns /users.id instead of /users/id when using devise

此生再无相见时 提交于 2019-12-11 02:13:15
问题 I find that when I use users_path(user) it returns /users.id where id is the id of the user but I want it to return /users/id . My config routes.rb looks like the following. # config/routes.rb Test::Application.routes.draw do root to: "static_pages#home" resources :users, only: [:index, :show] devise_for :users end 回答1: Use this for a path to a singular user: user_path(user) Use this for a path to all the users, or the index page: users_path # no arguments 来源: https://stackoverflow.com

Is it possible in laravel 5 to show a pretty url to the user, and a practical url to the app?

女生的网名这么多〃 提交于 2019-12-11 02:12:26
问题 I have this url: mywebsite.com/user/1/edit I want my users to see this: mywebsite.com/edit-your-profile/ Is this possible when using Route::resource('user', 'UserController'); ? If yes, how do I do it :) ? I still want my app to be able to see user/1/edit as I use it in my middleware to prevent unauthorized access: if ( \Auth::user()->id != $request->segment(2) ) { return redirect()->back(); } So, one pretty url for my user, a practical one for my app. 回答1: Based on your explanation, I take

How to accept hash parameters in routes

拥有回忆 提交于 2019-12-11 02:10:52
问题 Query: I have a link like <%= link_to "link_name", :controller => "some_controller", :action => "some_action", :id => "some_id", :first_param => {:second_param => "some value"} %> and in my routes.rb map.connect '/some_name/:id' :controller => "some_controller", :action => "some_action" Above code is giving me a URL like http://localhost:3000/some_name/some_id my requirement is to construct the URL as: http://localhost:3000/some_name/some_id/value_inside_params[:first_param][:second_param]

Hide Codeigniter controller name from URL with same routes

冷暖自知 提交于 2019-12-11 02:06:17
问题 i'm just getting started at codeigniter, i want to hide controller name from URL with same routes setup. i have 3 controllers which are students, staff, teachers having same function called home, this won't work obviously $route['home'] = 'students/home'; $route['home'] = 'staff/home'; is there any way to accomplish this? i have session data using codeigniter session class containing user type so i tried something like this session_start() $route['home'] = $_SESSION['user_type'].'/home'; but

Override nested named route parameters

寵の児 提交于 2019-12-11 01:56:41
问题 Coming from the Rails docs, one can simply do this: resources :videos, param: :identifier But, what if I have nested resources? Here are the routes: resources :videos resources :images end The above generate routes like: video_images GET /videos/:video_id/images(.:format) images#index How can I override :video_id from the route? I can't seem to be able to use param in this case. 回答1: If you want :identifier instead of :video_id you will have to code the routes manually. Which is a pain, so

laravel use $app inside routes error Undefined variable: app

自古美人都是妖i 提交于 2019-12-11 01:42:06
问题 laravel 5.2 documentation has used $app->get(..) in routing section. i cant use $app inside routes , it throw below exception: ErrorException in routes.php line 15: Undefined variable: app 回答1: There is no such global variable as $app in Laravel. You are probably referring to Lumen. Laravel framework at www.laravel.com is different from Lumen framework at www.lumen.laravel.com Lumen is 'slim down' version of Laravel If you are trying to register a route in Laravel this will do. Route::get('/'

Module route in Rails with form_for(@object)

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-11 00:58:41
问题 I have namespaced Controller Entities::Customers class Entities::CustomersController < ApplicationController ... end and namespaced ActiveRecord model: class Entities::Customer < Entities::User end in my routes.rb file i have: resources :customers, module: :entities The module :entities is there because i don't want to have routes such as: /entities/customers but only: /customers . The problem starts when i'm rendering my form: <%= simple_form_for(@customer) do |f| %> <%= f.input :email %> <%

wildcard subdomain is not working with static subdomain on live server

旧街凉风 提交于 2019-12-11 00:48:45
问题 I deployed my project on live server by creating subdomain app.example.net on cpanel. And put my project in app.example.net folder. In my project I have two route groups like below Routes.php <?php Route::group(['domain' => 'app.example.net'], function(){ Route::get('/', function () { if (auth()->check()) { return redirect('http://'.session('subdomain').'.example.net/home'); } return view('welcome'); })->name('homepage'); Route::get('/register', 'Auth\RegisterController@showRegistrationForm')

How to pass the React Router location prop to a component?

本秂侑毒 提交于 2019-12-11 00:36:37
问题 I'm trying to figure out how to pass React Router's location prop to a component. I have a route defined like so: <Route path="placeholder" render={(props) => <Navigation {...props} />} /> In my Navigation component I do console.log(this.props); in the render method only to get an empty object. What gives? Isn't the location prop supposed to be automatically supplied to any component inside a Route? By the way, I'm using react-router-dom version 4.2.2 . 回答1: You need to wrap your component

Android: can not get KML file to parse and then draw route on Map

早过忘川 提交于 2019-12-11 00:25:44
问题 I write an application that help people find appropriate places and show the direction to the target. Before, this functionality work well but now the draw route function does not work. The exception I got is that application can not download and then parse the kml corresponding to the route ( the code: xmlreader.parse(is); ), although the URL generated to get KML is correct (I test it in Browser) - for example: https://maps.google.com/maps?f=d&hl=en&saddr=21.04664,105.852203&daddr=21.040527