routes

Zend\Mvc\Router\Http\Method and child routes

泪湿孤枕 提交于 2019-12-13 17:21:19
问题 i have defined two routes, /shoppingcart/ and a child route /shoppingcart/add/ which should only be available for POST requests. 'routes' => array( 'shoppingcart' => array( 'type' => 'literal', 'options' => array( 'route' => '/shoppingcart/', 'defaults' => array( 'controller' => 'ShoppingcartController', 'action' => 'shoppingcart', ), ), 'may_terminate' => true, 'child_routes' => array ( 'add-product' => array( 'type' => 'method', 'options' => array( 'verb' => 'post', 'route' => 'add/',

Replacing :id from routes without breaking the convention

我怕爱的太早我们不能终老 提交于 2019-12-13 16:44:58
问题 I just replaced the :id on the resource routes in rails 3 for a hash generated. I'm annoyed by the fact that I'm writing less conventional code (e.g. a link_to edit_user_path(@user) is now written as link_to '/users/#{@user.user_hash}'). So I'm wondering, is therea smarter way to do this? 回答1: class User < ActiveRecord::Base def to_param user_hash end end and edit_user_path(@user) will work properly for you 来源: https://stackoverflow.com/questions/5146286/replacing-id-from-routes-without

ngrok - Get all routes to localhost server

廉价感情. 提交于 2019-12-13 16:27:51
问题 I'm using ngrok (free account) in my localhost for my coded web server written in Go In Ubuntu, after starting my server (which listens on port 3000), I run this command to start ngrok: ./ngrok http 3000 Then other PC can get access to my demo web by path provided by ngrok, for instance, http://6fed323a.ngrok.io But when they do something on it (for example, click on a button that redirects), the host of URL becomes localhost again There isn't any functions of ngrok that allows access to all

How to pass model in Nested routes - emberjs

﹥>﹥吖頭↗ 提交于 2019-12-13 16:00:40
问题 I have some nested routes. App.Router.map(function() { this.route("dashboard", { path: "/dashboard" }); this.resource("customers", { path: "/customers" },function(){ this.resource("customer",{ path: "/:customer_id" },function(){ this.resource("customer.contact",{path:'/contact'}); }); }); }); TEMPLATES customers/index <script type="text/x-handlebars" data-template-name="customers/index"> <h3>Customers</h3> <table> {{#each item in model}} <tr> <td>{{item.name}}</td> {{#link-to "customer" item

Allow empty parameter in MVC route

断了今生、忘了曾经 提交于 2019-12-13 15:59:55
问题 I've got a route that should only ever called by an automated process: routes.MapRoute( "Automated file processing", "Process/{change}/{file}/{type}", new { controller = "C", action = "Process" } ); Where both the file and type are optional parameters. Ideally, I'd like to be able to call /Process/Created/Filename/Text (with file and type) /Process/DirectoryListing//Text (with type only) /Process/Created/Filename/ (with file only) How would you acheive that optional parameter in the middle?

Redirect and raise flash message when catch-all in routes

强颜欢笑 提交于 2019-12-13 14:22:56
问题 I am able to redirect all (invalid) urls using this line at the end of the routes file: match '*a' => redirect('/') I'd like to do the redirect and pass on an alert message in routes.rb . Something like (the syntax is wrong here): match '*a' => redirect('/'), :alert => "aaargh, you don't want to go to #{params[:a]}" Is it possible to do this? If I were doing this in a view/controller, I could use redirect_to and pass on a flash message on the redirected page (see examples in redirecting in

Rails mountable engine under a dynamic scope

三世轮回 提交于 2019-12-13 11:35:18
问题 say that I have these routes: scope '(:locale)', :locale => /en|de/ do mount Users::Engine => "users", as: 'users_engine' end and in engine's view: <%= link_to 'new user', action: :new, controller: :users, locale: :de %> I get /en/users/users/new?locale=de instead of /de/users/users/new I have already included in application controller: def set_locale if params.include?('locale') I18n.locale = params[:locale] Rails.application.routes.default_url_options[:locale] = I18n.locale end end and it

No route matches {:action=>“show”, :controller=>“restaurants”}

随声附和 提交于 2019-12-13 08:36:10
问题 If I want to go with my home page clicking on the map localhost:3000/maps gets out this error No route matches {:action=>"show", :controller=>"restaurants"} controllers/maps_controller.rb def index @maps = Map.all @json = Map.all.to_gmaps4rails do |map, marker| marker.infowindow info_for_restaurant(map.restaurant) end respond_to do |format| format.html # index.html.erb format.json { render json: @maps } end end def show @map = Map.find(params[:id]) respond_to do |format| format.html # show

How to get the given route's method in laravel 5.8

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-13 08:01:13
问题 I have a route that is named editUser when I try the following code: return route('putUser'); It returns me the url of the given route now I want to check what method is used for that route, for example, It's a GET method or POST or anything else what should I do? 回答1: You can get the methods defined on a named route by accessing the RouteCollection $route = Route::getRoutes()->getByName('putUser'); $methods = $route->methods(); 来源: https://stackoverflow.com/questions/58356764/how-to-get-the

CodeIgniter won't run in a subdirectory

我只是一个虾纸丫 提交于 2019-12-13 07:39:14
问题 I have a CodeIgniter install running in our root web directory that I copied into a subdirectory called /dev... I edited the config/config.php file to reflect the change so it is now like this: $config['base_url'] = 'http://mysite.com/dev'; $config['sbase_url'] = 'https://mysite.com/dev'; $config['default_email'] = 'noreply@mysite.com'; $config['site_url'] = 'http://mysite.com/dev'; This is my .htaccess file: <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f