routes

Using form_for tag with get method

跟風遠走 提交于 2019-12-01 02:58:41
I am trying to Submit a form using get method. Earlier I was trying a similar thing with form_tag and it was working but now when I changed to a form_for tag, this doesn't seem to work. <%- filter_path = params[:action] == "index" ? posts_path : sneak_peek_posts_path %> <%= form_for(@post_filter, :url=> filter_path, :method => :get) do |f| %> I get a no routes error. You can pass the raw HTML attributes using :html if you need to. For Rails 3: <%= form_for(@post_filter, :url=> filter_path, :html => { :method => 'GET' }) do |f| %> Update and in Rails 4, per @andre.orvalho's suggestion below,

Unable to register routes in SignalR 2.0.0

泄露秘密 提交于 2019-12-01 02:28:31
问题 I decided to move to the latest version of signalr but i facing a few issues. First of all the way to register routes has entirely changed; so i tried to do it the way that this link http://www.asp.net/vnext/overview/latest/release-notes#TOC13 suggests. The problem is that although i add <appSettings> <add key="owin:AppStartup" value="xxx.Startup, App_Code"/> </appSettings> to the web.config the Configuration is not invoked at all. Does anyone know what i'm doing wrong? 回答1: Solution !

link_to update (without form)

自古美人都是妖i 提交于 2019-12-01 02:14:19
I want a link to update a resource, without using an HTML form. Routes : resources :users do resource :profile, :controller=>"profiles" resources :friends end Rake routes: user_friend GET /users/:user_id/friends/:id(.:format){:action=>"show", :controller=>"friends"} PUT /users/:user_id/friends/:id(.:format){:action=>"update", :controller=>"friends"} I want to use the put to update a friend by a simple link, something like this: <%=link_to "Add as friend", user_friend_path(current_user, :method=>'put')%> But as Rails meet that link he tries to go into the show action. The question is: what is

Rails routes matching query parameters

房东的猫 提交于 2019-12-01 02:13:25
问题 Rails routes are great for matching RESTful style '/' separated bits of a URL, but can I match query parameters in a map.connect config. I want different controllers/actions to be invoked depending on the presence of a parameter after the '?' . I was trying something like this... map.connect "api/my/path?apple=:applecode", :controller => 'apples_controller', :action => 'my_action' map.connect "api/my/path?banana=:bananacode", :controller => 'bananas_controller', :action => 'my_action' For

Reload a page after res.redirect('back') in route

你说的曾经没有我的故事 提交于 2019-12-01 02:01:12
I'm working on an application which allows you to upload images, and create albums. Everything works fine accept that after an album is created the new album isn't shown in the client until the page is reloaded, and I can't figure out how to solve this. Below is the route for creating an album. Is it somehow possible to use something else than res.redirect('back') in this case so that the page is reloaded after the route has finished? Of course I could copy/paste the code from the route for loading the page in the first place, but that would be to much DRY. Maybe I can call the other route

In Express or connect with Node.js, is there a way to call another route internally?

雨燕双飞 提交于 2019-12-01 01:58:50
问题 So, I have the setup like this (in Express): app.get('/mycall1', function(req,res) { res.send('Good'); }); app.get('/mycall2', function(req,res) { res.send('Good2'); }); What if I want make an aggregate function to call /mycall1 and /mycall2 without rewriting code and reusing code for /mycall1 and /mycall2 ? For example: app.get('/myAggregate', function (req, res) { // call /mycall1 // call /mycall2 }); 回答1: No, this is not possible without rewriting or refactoring your code. The reason is

How to remove “public” from url using routeing in zend framework

我的未来我决定 提交于 2019-12-01 01:08:18
An one issue in my zend, i write rule in .htaccess to remove "public" from url as following, ------------------------------------------------------------------------ RewriteEngine On RewriteCond %{HTTP_HOST} ^domain-name.com/$ [OR]<br/> ReWriteCond %{REQUEST_URI} !public/<br/> ReWriteRule ^(.*)$ public/$1 [L]<br/> ------------------------------------------------------------------------ but there is ROUTE method in zend, i have use it for multiple language to set language code in url LIKE www.domain-name.com/en/ , using zend_controller_router_route_chain , before this method implemented, my url

Using variables across Flask routes [duplicate]

假如想象 提交于 2019-12-01 00:57:59
This question already has an answer here: Are global variables thread safe in flask? How do I share data between requests? 2 answers I am learning Flask and have a question regarding use of variables in the context of routes.For Example, my app.py: from flask import Flask, render_template app = Flask(__name__) @app.route("/index") def index(): a=3 b=4 c=a+b return render_template('index.html',c=c) @app.route("/dif") def dif(): d=c+a return render_template('dif.html',d=d) if __name__ == "__main__": app.run() Under the route /dif the variable d is calculated by taking the values of already

Routing in Rails. Dots in URL [duplicate]

拜拜、爱过 提交于 2019-12-01 00:25:52
问题 This question already has answers here : Why do routes with a dot in a parameter fail to match? (3 answers) Closed 4 years ago . I have overwritten to_param method in my Category model def to_param name end And routes.rb get '/:id' => 'categories#show', :as => :category When name parameter doesn't contain any dots ( foobar ), all works right, but when it does ( f.o.o.b.a.r ) I get an error No route matches [GET] . So my question is: is it possible to use dots in routing like a part of name of

Angular 2 implementing RouteReuseStrategy

送分小仙女□ 提交于 2019-11-30 23:55:21
I implemented RouteReuseStrategy suggested here and also updated a bit, because on shouldAttach the routeConfig.path was empty, and the handler was not cached. I have @angular/router: 3.4.7 . import {RouteReuseStrategy, DetachedRouteHandle, ActivatedRouteSnapshot} from "@angular/router" export class CustomReuseStrategy implements RouteReuseStrategy { handlers: {[key: string]: DetachedRouteHandle} = {}; currentPath: string = ''; shouldDetach(route: ActivatedRouteSnapshot): boolean { return true } store(route: ActivatedRouteSnapshot, handle: DetachedRouteHandle): void { this.handlers[route