routes

Laravel - Implicit route model binding with soft deleted data

怎甘沉沦 提交于 2020-01-04 04:34:06
问题 I am having a small issue. There are two user roles and one is a normal member and one is an admin. The member can delete a blog and they will not be able to see the blog after they delete (soft delete) it while the admin can still see the blog, even if it's soft deleted. Example code: // Route file Route::get('/blog/{blog}', 'BlogController@show'); // BlogController public function show(App\Blog $blog) { // It never gets to here if the blog has been soft deleted... // Automatically throws an

Rails routes and site performance

我的梦境 提交于 2020-01-04 04:03:40
问题 Is there a direct correlation on site speed with the number of namespaces / routes in the routes.rb file of a Rails Application? I am handling a fairly large application with more than 30 disparate models/entities and most of these resources have their own routes. 回答1: I don't have a citation† but DHH recently said that 37signals' Highrise application has thousands of routes, so it is possible to scale the routes if you have a big enough box to run your application on. † I think it may have

MVC routing not working

断了今生、忘了曾经 提交于 2020-01-04 03:24:26
问题 In my route config class, I created a custom routing configuration with a static prefix, public static void RegisterRoutes(RouteCollection routes) { routes.MapRoute("MyRoute", "{controller}/{action}", new { controller = "Home", action = "Index" }); routes.MapRoute("", "Public/{controller}/{action}", new { controller = "Home", action = "Index" }); } But the URL ...mysite/Public gives a page not found error. What is wrong here? 回答1: Change the order of two routes, public static void

Routing error with Rails 3 with members

主宰稳场 提交于 2020-01-04 02:49:27
问题 I have the following route in rails 3: resources :jobs do member do post :seller_job_submitted end end And the following form =form_for job, :url=>seller_job_submitted_job_path(job), :remote=>true do |f| I know it's not very restful, but it's kind of a stop gap for now. In any case, I keep getting this error when submitting the form Started POST "/jobs/74/seller_job_submitted" for 127.0.0.1 ActionController::RoutingError (No route matches "/jobs/74/seller_job_submitted"): but when I run rake

404 error laravel 4 routing

我与影子孤独终老i 提交于 2020-01-04 01:29:05
问题 I am having troubles getting laravel to find a page when I route to it. My route is setup and being recognized as when I create link using URL::route('account-create') laravel will successfully parse that into '/account/create' as to where I want the link to go to. But upon clicking it I get a 404 error. My route Route::get('/account/create', array( 'as' => 'account-create', 'uses' => 'AccountController@getCreate' )); My controller class AccountController extends BaseController { // view the

Symfony2 / routing / use parameters as Controller or Action name

帅比萌擦擦* 提交于 2020-01-03 19:09:13
问题 Is it possible to route to a controller/action using given parameters ? For example : my_custom_route: pattern: /{controller}/{action} defaults: { _controller: AcmeDemoBundle:[controller]:[action] } I would like [controller] and [action] to be replaced by given route's parameters values. I.E : http://www.somedomain.com/Content/add should call action " addAction " of controller " ContentController " in bundle "AcmeDemoBundle" 回答1: Yes you can do so however it is not recommended. What would you

Trouble with Codeigniter Routes involving a query

和自甴很熟 提交于 2020-01-03 05:27:25
问题 I'm having a little trouble with a CodeIgniter route when there is a query (stuff after the ?) in the URI. I know it is good practice to replace queries with routes in CI, but I'm importing in a premade messageboard that already does everything with queries. This is my route: $route['messageboard/:any'] = "messageboard/index"; Any in this case refers to a script name. So if it's messageboard/admin.php, I have it load a view that loads my premade messageboard's script "admin.php". It's working

Collecting first segments of all routes in rails 3

那年仲夏 提交于 2020-01-03 05:26:17
问题 I'm trying to implement routes where the first segment is the profile's alias or id: resources :profiles, :path => '' do ... end And I need to validate that alias is not already taken by first segments of other(higher) routes. What I have now is: validates :alias, :exclusion => {:in => Rails.application.routes.routes.map{|r| r.path.spec.to_s.split('(').first.split('/').second}.compact.uniq }, .... In development everything is ok. In production Rails.application.routes.routes.map... returns

How to split routes.rb into multiple files [duplicate]

|▌冷眼眸甩不掉的悲伤 提交于 2020-01-03 05:10:12
问题 This question already has answers here : Splitting Routes File Into Multiple Files (4 answers) Closed 6 years ago . I have huge routes.rb file and I want to split into multiple manageable files. As suggested in following article, I have created separated folder for routes and I have created multiple routes files in this folder Link: http://rails-bestpractices.com/posts/73-split-route-namespaces-into-different-files routes.rb routes/user.rb routes/manager.rb routes/admin.rb routes/anonymous.rb

CakePHP 2.x Custom Route with Arguments

一世执手 提交于 2020-01-03 04:17:05
问题 In my CakePHP App I'd like to pass arguments in a custom route. What works now (domain/controller/action/param) domain.com/dealers/view/1 What I'd like to do (domain/param/controller/action/param) domain.com/washington/dealers/view/1 This is my code in routes.php: Router::connect('/:city/dealers/view/:id', array('controller' => 'dealers', 'action' => 'view'), array( 'pass' => array('city', 'id') ), array('city' => '[a-z]+') ); This just redirects domain.com/washington/dealers/view/1 to domain