routes

Laravel multi auth protecting route multple middleware not working

无人久伴 提交于 2019-12-13 03:34:38
问题 I have created an extra middleware admin and I want to protect my routes. Adding one single middleware 'auth' or 'auth:admin' is working. Route::get('/calendar', function () { return view('app', ['data' => []); })->middleware('auth'); But I want that as an admin you can also access the user routes but this is not working. If I try the following, and I log in as an admin I get redirected to the login page all the time. Route::get('/information', ['middleware' => ['auth', 'auth:admin'],

Append Selected Drop Down Value with Option in Laravel Blade with Jquery

只谈情不闲聊 提交于 2019-12-13 03:23:43
问题 I want to show the models by changing the Drop Down value....I know how to get the value of drop down with change function but my problem is that i want to send that value in route to filter the models.....Please tell me how can i send the changed value id with route from blade.. This is my Drop Down <select class="form-control" id="category" placeholder="Select category"> <option>All</option> @foreach($categories as $category) <option value="{{route('contributors.index')}}?category={{

For routes with identical URI patterns, which is matched first?

白昼怎懂夜的黑 提交于 2019-12-13 03:19:43
问题 Assume a Rails application draws the following routes (i.e. this is what rake routes would show): Verb URI Pattern Controller#Action GET / one#show GET / two#show GET / three#show What is the matching order for these routes when requesting the root path (i.e. / )? What factors detemine which route is matched first? Background : I’m faced with a Rails application (Discourse) for which I’m writing a plugin. The Rails application sets up a bunch of root routes via root to: in its routes.rb file.

Why MVC keeps route values in URL without passing them directly

孤人 提交于 2019-12-13 02:26:41
问题 I have a question. Let's say I have this routes: /Guest/{var1}/{var2} /Guest/{var1}/{var2}/edit When I'm on the /Guest/123/321 page, I have a link to /Guest/123/321/edit?id=1 . There is a form on the page /Guest/123/321/edit?id=1 , which posts itself on the same address. Let's say that my Actions looks like: public ActionResult Index(int var1, int var2) { /* here is some a business logic */ return View(model); } [HttpGet] public ActionResult Edit(int id) { /* here is some a business logic */

how to pass params using a route in Zend Framework 2?

谁说胖子不能爱 提交于 2019-12-13 02:13:25
问题 i have a router test/view and i would like to pass some params like test/view/id/123 . Im not sure how to add those params in the zf2 router. 'router' => array( 'routes' => array( 'test' => array( 'type' => 'Literal', 'options' => array( 'route' => '/test', 'defaults' => array( '__NAMESPACE__' => 'test\Controller', 'controller' => 'Index', 'action' => 'index', ), ), 'may_terminate' => true, 'child_routes' => array( 'view' => array( 'type' => 'Literal', 'options' => array( 'route' => '/view',

Rspec make sure we ended up at correct path

南笙酒味 提交于 2019-12-13 00:54:13
问题 Is there a way we can test that we ended up at the expected path with rspec? Something like: it "should be the forgot password path" do response.should redirect_to(new_user_password_path) end This gives me an error: Failure/Error: response.should redirect_to(new_user_password_path) ArgumentError: @request must be an ActionDispatch::Request 回答1: I had this problem once, and it was because the capybara visit method doesn't set the @requests variable, the one that rails use to do the redirection

MVC Attribute Routes & Route Inheritance

和自甴很熟 提交于 2019-12-13 00:49:39
问题 I am trying to get attribute routing in MVC5 to let me inherit the routes from a base controller. Example: public abstract class BaseController: Controller { [Route("")] public virtual ActionResult Index() [Route("edit/{id}")] public virtual ActionResult Edit(TKey id) //etc } [RoutePrefix("people")] public class PersonController : BaseController { //etc } Then obviously I should have /people for the Index page, /people/edit/1 for the Edit page etc. However, it seems like this is not supported

Redirecting subdomain to folder in Rails 3

拟墨画扇 提交于 2019-12-13 00:13:03
问题 I need to redirect help.mydomain.com/a-page to /pages/a-page without using Nginx or Apache redirects and only through Rails 3 routes. The key here is the help subdomain determining that /pages/ should be dropped from the route although the view is under the /views/pages/ Any help is appreciated. 回答1: Try this: match "/:page_name" => redirect("/pages/%{page_name}"), :constraints => { :subdomain => /help/ } 来源: https://stackoverflow.com/questions/8088174/redirecting-subdomain-to-folder-in-rails

Rails 3 routes and modules

拥有回忆 提交于 2019-12-12 21:07:42
问题 I have a AR model inside a module class Long::Module::Path::Model < ActiveRecord::Base end and want to use following routes (without the module names, because it's easier to write and remember) resources :models buts Rails 3 always wants to use a URL like long_module_path_model_url Is there are way to change this behavior? Hope anyone out there can help me? Mario 回答1: I'm a little curious why you're referencing a model when talking about routing which only handles the controller level; but

How do I change the Refinery CMS admin path?

99封情书 提交于 2019-12-12 18:23:57
问题 I have done this: MyApp::Application.routes.draw do get 'admin', :to => redirect('/refinery') mount Refinery::Core::Engine, :at => '/' end It allows me to give to my users a friendlier URL, one that makes sense to them, but the path still changes to localhost:3000/refinery . So, how do I do this? Without redirection perhaps? 回答1: EDIT, sorry you actually can use the file at config/initializers/refinery/core.rb just add this line config.backend_route= "admin" 来源: https://stackoverflow.com