routing

ArgumentError: wrong number of arguments (1 for 2)

情到浓时终转凉″ 提交于 2020-01-11 04:46:09
问题 I'm very new to Rails, MVC, and CRUD, and I'm trying to use the update method to change the amount of votes on a post. I have the following code in my Posts Controller update method: def update @post = Post.find(params[:id]) if params[:vote] == 'up' @post.update_column(:ups => @post[:ups] + 1) elsif params[:vote] == 'down' @post.update_column(:downs => @post[:downs] + 1) end flash[:notice] = "Thanks for voting! This helps us determine important issues in our schools." redirect_to 'Posts#index

Rails 3 Routing Constraint and Regex

試著忘記壹切 提交于 2020-01-11 04:12:16
问题 I'm looking to match the pattern state/city in the path, unless the state variable equals "auth" match '/:state/:city' => 'cities#index', :as => :state_cities, :constraints => {:state => /(?!auth)/ } For example, mydomain.com/fl/miami is good. mydomain.com/auth/twitter is bad. I am using omniauth and it requires that you go to /auth/twitter for authentication, however it is nowhere to be found when I type rake routes . 回答1: Based on mu is too short's comments, here is the answer I've come up

AngularJS: route provider changes “/” into %2F [duplicate]

孤者浪人 提交于 2020-01-11 02:27:39
问题 This question already has answers here : AngularJS All slashes in URL changed to %2F (6 answers) Closed 2 years ago . I am building an AngularJS appplication and I have problems with the URL when building the second view: My appContact.js looks like this: (function () { "use strict"; var app = angular.module("appContacts", ["simpleControls", "ngRoute"]) .config(function ($routeProvider, $locationProvider) { $routeProvider.when("/", { controller: "contactsController", controllerAs: "vm",

rails 3.1 ActionController::RoutingError (No route matches [GET] “/assets/rails.png”):

▼魔方 西西 提交于 2020-01-10 12:04:34
问题 Standard new rails app has issue showing the rails.png ActionController::RoutingError (No route matches [GET] "/assets/rails.png"): I have tried moving the .png file around to various places in assets and assets/images and also the older place 'public' or 'public/images' and changing the page but nothing has helped. Please answer if you have seen and resolved this. I have tried about 20 different combo's myself. Version: 'rails', '3.1.0.rc4' 回答1: I just had a problem throwing a similar error.

rails 3.1 ActionController::RoutingError (No route matches [GET] “/assets/rails.png”):

蹲街弑〆低调 提交于 2020-01-10 12:03:07
问题 Standard new rails app has issue showing the rails.png ActionController::RoutingError (No route matches [GET] "/assets/rails.png"): I have tried moving the .png file around to various places in assets and assets/images and also the older place 'public' or 'public/images' and changing the page but nothing has helped. Please answer if you have seen and resolved this. I have tried about 20 different combo's myself. Version: 'rails', '3.1.0.rc4' 回答1: I just had a problem throwing a similar error.

Angular2 named routes

断了今生、忘了曾经 提交于 2020-01-10 11:46:34
问题 I use Angular2 Webpack Starter in this newest version and in file ./src/app/app.routes.ts I add 'my-new-route' and i want to name it as: "my.route" export const routes: RouterConfig = [ { path: '', component: Home }, { path: 'home', component: Home }, // make sure you match the component type string to the require in asyncRoutes { path: 'about', component: 'About' }, { path: 'my-new-route', component: 'Dashboard', name:"my.route" }, { path: '**', component: NoContent }, ]; but there is a

Symfony2: How to pass url querystring parameters to controllers?

為{幸葍}努か 提交于 2020-01-10 08:49:53
问题 Maybe I am missing something but there doesn't seem to be a way to define querystring parameters in routes in Symfony2 so that they can be passed into a controller. For instance, instead of generating a URI like /blog/my-blog-post (from Symfony2's routing documentation) and passing it to the following route: # app/config/routing.yml blog_show: pattern: /blog/{slug} defaults: { _controller: AcmeBlogBundle:Blog:show } I would prefer to generate a URI like /blog?slug=my-blog-post . The problem

Testing Angular 2 parent route

醉酒当歌 提交于 2020-01-10 05:42:05
问题 I have a component that accesses a parent route value like this: ngOnInit() { this.route.parent.parent.params.subscribe(params => { this.placeService.getPlace(params['id']).subscribe(place => this.place = place); }); } Here's the full file in case it helps. import { Component, OnInit } from '@angular/core'; import { ActivatedRoute } from '@angular/router'; import { PlaceService } from '../place.service'; import { Place } from '../place'; @Component({ selector: 'app-diner-review-list',

How can I pass data with URLs to ui-sref?

穿精又带淫゛_ 提交于 2020-01-10 04:42:05
问题 I ny view I have: <a ui-sref="app.file({path: file.path})">{{ file.path }}</a> file.path is html/hero-sidebar.html My state is defined as: .state('app.file', { url: '/file/*path' views: repositoryView: templateUrl: '/templates/app/_file.html' }) But when I click the link, it goes to http://localhost:9001/app/file/html%252Fhero-sidebar.html What I want is for it to go to http://localhost:9001/app/file/html/hero-sidebar.html Is this possible using ui-router with AngularJS? 回答1: There is already

How Can I Stop ASP.Net MVC Html.ActionLink From Using Existing Route Values?

夙愿已清 提交于 2020-01-09 13:05:28
问题 The website I'm working on has some fairly complicated routing structures and we're experiencing some difficulties working with the routing engine to build URLs the way we need them to be built. We have a search results page that uses RegEx based pattern matching to group several variables into a single route segment (i.e. "www.host.com/{structuralParameters}" can be the following: "www.host.com/variableA-variableB-variableC" - where variables A through C are all optional). This is working