routes

Angularjs: How to inject dependency from resolve routeProvider

六眼飞鱼酱① 提交于 2019-12-05 05:38:13
I have a problem injecting resolve parameters from the routing into the controller. I'm setting the resolve value to an object {name: 'Banner', slug: 'banner'} , but I get an error. App.js var app = angular.module('CMS', ['fields', 'ngRoute']); app.controller('ModuleController', ['$http', 'properties', function($http, properties) { var module = this; module.properties = properties; if (module.properties.slug.length) { $http.get(module.properties.slug + '.php').success(function(data) { module.list = data; }); } } ]); app.controller('HomeController', function() {}); app.config(function(

How to change will_paginate URLs?

一曲冷凌霜 提交于 2019-12-05 05:16:09
I'm trying to change the will_paginate links from the format of /list?page=1 to /list/page/1 . I have the routes setup right for this, but will_paginate is using the query string in links rather than my pretty URL style. How to tell it otherwise? I'm using will_paginate 2.3.16 and Rails 2.3.14 . will_paginate uses the url_for helper. If you define routes containing the parameters it uses, it should generate pretty urls. map.connect '/lists/page/:page', :controller => 'lists', :action => 'index' Please make sure, you define this route above any routes that could also match your controller

Creating a route with Sinatra to only accept a certain Content-type

孤者浪人 提交于 2019-12-05 04:48:20
I'm trying to create a route with Sinatra that only accepts POST with an Content-type: application/json without success. My approach is as follows: post '/dogs', :provides => :json do # returns here a json response end Testing with curl, I have seen that :provides => :json configures the route to respond with an Content-Type: application/json . That's right because I want also to respond with a JSON message to the POST request but I really need that this route only respond to POST requests with a Content-Type: application/json and not, for example, to others (e.g. Content-Type: application/xml

Rails 4 Method Not Allowed after Upgrading from Rails 3

不问归期 提交于 2019-12-05 04:16:47
I've got an existing codebase that I'm attempting to upgrade from Rails 3.2 to Rails 4.0 I have controller called assets_controller with a 'create' method and I have a an entry in my routes file: resources :assets Using jQuery for ajax on the front end, if I send a post request to '/assets' from a browser, I get 405 (Method Not Allowed): $.ajax({method: 'POST', data: asset, url: '/assets' }); This worked just fine in Rails 3, and I can't seem to figure out what the issue is. Updates: Heres a simplified version of my controller: class AssetsController < ApplicationController skip_before_filter

ExpressJS Route Parameter with Slash

半世苍凉 提交于 2019-12-05 04:01:03
问题 Im using ExpressJS. I want pass url as parameter. app.get('/s/:url', function(req, res) { console.log(req.params.url); }); /s/sg.com //sg.com /s/www.sg.com //www.sg.com /s/http://sg.com //http://sg.com /s/http://sg.com/folder //http://sg.com/folder How to correct the route such that everything afterr /s/ will be considered as paramenter including slashes. Thanks 回答1: Uh, if you want to stick a URL inside of another URL, you need to URLencode it. If you want to stick one in their raw and

Polymorphic controller and calling object

跟風遠走 提交于 2019-12-05 03:31:25
问题 I have a polymorphic relationship with address being able to both be owned by a member or a dependent. Everything looked great until I realized that I wouldn't know what type of object was creating it unless I'm missing something. Is there a way to tell the routing file to include the type of object? Models: class Member < ActiveRecord::Base has_one :address, as: :person, dependent: :destroy end class Dependent < ActiveRecord::Base has_one :address, as: :person, dependent: :destroy end class

Route to controller in subfolder not working in Laravel 4

被刻印的时光 ゝ 提交于 2019-12-05 03:28:04
I was updating my Laravel 3 app to Laravel 4 when I hit this problem... Routes I have tried: Route::get('backend/login', 'backend/UserController@login'); Route::get('backend/login', 'backend.UserController@login'); I had a similar issue just a few hours ago and had to play a little bit with it to have it working. Routes: Route::group(array('prefix' => 'admin'), function() { Route::resource('/', 'admin\DashboardController'); }); In "controllers/admin" i put the DashboardController: namespace admin; use Illuminate\Support\Facades\View; class DashboardController extends \BaseController { public

The parameters dictionary contains a null entry for parameter 'id' of non-nullable type

穿精又带淫゛_ 提交于 2019-12-05 03:00:15
问题 I'm trying to retrieve data from my db via the id parameter in my default route: routes.MapRoute( "Default", // Route name "{controller}/{action}/{id}", // URL with parameters new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults ); In this ActionResult I'm trying to render a custom user control, based on the route id parameter so that I retrieve the relevant data for the page that's requested public ActionResult InitPageNav(int id) { PageModel page =

Rails 3.1 - How do I organize multiple index actions for the same model?

。_饼干妹妹 提交于 2019-12-05 02:40:58
问题 I have a User model that has_many projects. The Project model belongs_to the User model. I am currently using the projects_controller.rb index action to display all of the projects that have been created across all users (Project.all). On a separate page, I would also like a way to display all of the projects that belong to a specific user (i.e. go to page and be able to see all of the projects that belong to a given user). I am having difficulty figuring out which controller/action/view to

Restricting resource routes and adding additional non-RESTful routes in Rails 3

不问归期 提交于 2019-12-05 02:40:33
I wasn't able to find anything here or elsewhere that covered both restricting a resource's routes and adding additional non-RESTful routes in Rails 3. It's probably very simple but every example or explanation I've come across addresses just one case not both at the same time. Here's an example of what I've been doing in Rails 2: map.resources :sessions, :only => [:new, :create, :destroy], :member => {:recovery => :get} Pretty straightforward, we only want 3 of the 7 RESTful routes because the others don't make any sense for this resource, but we also want to add another route which is used