routes

Rails namespaced routes work in development but not production

大城市里の小女人 提交于 2019-12-05 09:02:15
I'm trying to nest some routes under the namespace, account. I want user management under account like /account/users and /account/users/5/edit In routes.rb: namespace :account do resources :users do member do put 'generate_api_key' end collection do post 'api_key' end end end My controllers are not namespaced or put them in any different directory. /app /controllers accounts_controller.rb users_controller.rb In my development environment this is working fine, but in production I get 404 responses to any of the /account/users... paths (which, by the way, are all still generated correctly: new

Task async controller method does not hit

痴心易碎 提交于 2019-12-05 08:36:45
So, we've got an MVC project that has been upgraded through the different versions of MVC from 1 through to 4. Now we have a controller method: public async Task<ActionResult> IndexAsync() so if we go to http://somedomain.xyz/WhicheverController or http://somedomain.xyz/WhicheverController/Index , we are greeted with a 404. http://somedomain.xyz/WhicheverController/IndexAsync routes to the method just fine. What's gone wrong with our routing? I believe that your example will work if you derive your Controller from AsyncController instead. public class MyController:AsyncController { public

MVC with Areas — Html.ActionLink returning wrong URL/Route?

醉酒当歌 提交于 2019-12-05 08:22:23
I am using MVC3 and have Areas in my application. In general, everything works fine, I can navigate to my area (e.g. Admin=Area, Controller=Department) like this: <%: Html.ActionLink("Departments", "DepartmentIndex", "Department", new { area = "Admin"}, null )%> However, what I noticed is that if I don't specify the area in my ActionLink, e.g. <%: Html.ActionLink("Test", "Index", "Home")%> This will stop working if I have navigated to the "Admin" area. i.e. my url is now http://localhost/myproj/Admin/Home/Index instead of http://localhost/myproj/Home/Index Any ideas on what is going on here?

Avoiding “Request matched multiple actions resulting in ambiguity” error in ASP.Net Core

a 夏天 提交于 2019-12-05 08:05:12
I am trying to do something simple and trivial - or at least I thought. I am trying to write a base class that can be inherited by each micro-service project I spin up. The point of this base class is to test connectivity from HTTP all the way through to SQL. It is NOT enabled in PROD. This is one of the (simpler) base classes: public class DevTestControllerBase: ApiControllerBase { public DevTestControllerBase(IHostingEnvironment env, IConfiguration configuration = null, IMediator mediator = null) : base(env, configuration, mediator) { } [HttpGet] public IActionResult Get() { var response =

python/Flask: Route with dynamic first component

六眼飞鱼酱① 提交于 2019-12-05 08:03:26
问题 I am writing a Flask site for which I would like to have routes like this: @app.route('/') @app.route('/<page_id>') @app.route('/<page_id>/<subpage_id>') def page(page_id=None, subpage_id=None): ... While it seems like this should work in theory, it looks like this actually breaks static resources located in the root static/ directory. I assume the reason for this is that my dynamic route actually matches 'static/style.css' and thus overrides the normal handler for static files. Is there any

disabling character escaping in Flask's url_for function

吃可爱长大的小学妹 提交于 2019-12-05 07:48:39
Does Flask's url_for method have an option to disable autoescaping? So if I have an endpoint called getUser with a route like this: /user/<userID> , I want to call url_for('getUser', userID='%') and have it return /user/% . Currently it will escape the % symobl and give out /user/%25 . I want to do that because url_for has to run at template compile-time, but the final URL is composed when a javscript script runs. I will be using a javascript string substitution method to convert /user/% into /user/abcd , but the substitution script I'm using requires you to use a % symbol as the placeholder.

ruby on rails routes

喜欢而已 提交于 2019-12-05 06:50:42
问题 I am having a hard time understanding routes in rails 3. I created two scaffolds: Users and magazines. The users are able to login, but I am unable to link to the magazine page. I know it has to do with creating a route. If I navigate via the URL to localhost:3000/magazines, I can see the multiple magazines I created and each user associated with each magazine. I just can't seem to connect the dots. I want to create a link from the user page to the magazine page. I know this is basic, but all

Resource interpreted as Stylesheet but transferred with MIME type text/html in AngularJS

只愿长相守 提交于 2019-12-05 06:32:27
问题 Have an angular application: This is part of my index.html page: <!DOCTYPE html> <html lang="en" ng-app="ReApp"> <head> <meta charset="UTF-8"> <title>REApp</title> <link rel="stylesheet" href="./lib/bootstrap/dist/css/bootstrap.min.css"> <script src="./lib/angular/angular.min.js"></script> </head> <body></body> </html> This is part of my server.js(start point): var express = require('express'); var app = express(); app.use(express.static(__dirname + '/public')); app.use('/api', api); app.get(

Rails routes redirection for subdomains

。_饼干妹妹 提交于 2019-12-05 05:56:08
We can't change the server configuration files, so we need to do our redirections at the rails level. I have no problem with path redirections to external sites, like: match "/meow" => redirect("http://meow.com/") The issue is with the subdomains. I need to redirect for example: http://my.example.com => http://example.com How can this be done using routes.rb? Stefan Huska According to @cfernandezlinux's amazing answer , here's the same in Rails 4/Ruby 2 syntax: constraints subdomain: "meow" do get "/" => redirect { |params| "http://www.externalurl.com" } end match in routes.rb is not allowed

how to route your sub-folder in views Ruby on Rails?

有些话、适合烂在心里 提交于 2019-12-05 05:46:17
Can anyone please shed some light on how to route your sub-folder's .html.erb files?? which is placed like this: view/pages/en/index.html.erb and to route this i am doing following things on route.rb match ':lang/index', :to => 'pages/en#index' and for a link code, I have this on the header <%= link_to "Home", index_path %> The error i am getting is Routing Error uninitialized constant Pages routes: AFAIK, There is no way to route to a view. You can route an URL to a controller's action. That action is responsible for rendering the views. you can use namespaced routing to put the resources in