routes

ASP.NET MVC Pass mutiple params from getJson to controller

Hi, I am making a call to a controller action in javascript using the getJson method. I need to pass two parameters to my action method on the controller, but I am struggling to do so. I do not fully understand the routing tables and not sure if this is what I need to use to get this working. Please see example below of what I am tr...

Do MVC routes look at subdomains also?

Hi, Do/can routes in .net MVC look at subdomains? i.e. subdomain1.example.com ...

MVC - RouteLink and Image

I'd like this output: <a href="\Catalog\Flooring"> <img src="http://site.com/dot.jpg" width="100px" height="100px" alt="" /> <span>Some text here</span> </a> using a RouteLink similar to: <%= Html.RouteLink(myFPV.ProductTypeName, "CatalogType", new { controller = "Catalog", action = "Types", group = myFPV.ProductGroupName, ty...

Dynamically construct RESTful route using Rails

I'm trying to write a helper method that accepts the name of a plural resource and returns a corresponding link. The essence of the method is: def get_link(resource) link_to "#{resource.capitalize}", resource_path end Clearly the resource_path part above doesn't work. What I'd like is to be able to pass foos to get foos_path and bar...

Giving a nested route an alias in Rails

If I want to provide an alias for a controller, I can use map.resources :rants, :controller => 'blog_posts' yoursite.com/rants points to the blog_posts controller fine. How do I give an alias to a nested resource, for example yoursite.com/users/5/rants ? ...

Rails: Database records with custom route...?

I have a model, target, that holds a number of records that are timestamped. On the corresponding controller, I list the months of those records by doing the following: In models/target.rb def month self.recorded_on.strftime('%B') end In controllers/targets_controller.rb @records = Target.find :all In views/targets/index.html....

RoR: how do I create a "valid signup code" lookup?

Hi, I want to be able to give codes to potential users in the form of email links (e.g. mysite.com/signup?beta=rapunzel) When someone clicks on the link, it populates a hidden_field with the value (will just using :params[:beta] work?) Then before it creates the user it validates by checking against another table where I have differen...

Shorten Zend Framework Route Definitions

Hi! How can I shorten the definition of my custom routes in Zend Framework? I currently have this as definition: $route = new Zend_Controller_Router_Route( ":module/:id", array( "controller" => "index", "action" => "index" ), array("id" => "\d+") ); self::$frontController->getRouter()->addRoute('shortcutOne', $route); $route =...

asp.net mvc multi-parameter requests for dynamic images?

In webforms, we would do somthing like this to set up a hander to generate a dyanmic image: <img src="/barchart.aspx?width=1024&height=768&chartId=50" > Then of course we would write code on the .aspx page to render the image using the parameters and write it back into the response. I am honestly not sure how to set up/handle such a...

How do unit testing for IgnoreRoute in ASP.NET MVC

In ASP.NET MVC, I can get information on unit testing for routes and custom routes, but I can not figure out how to do unit testing for IgnoreRoute. routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); Practical code is much appreciated. ASP.NET MVC Framework (Part 2): URL Routing ASP.NET MVC Tip #13 – Unit Test Your Custom Routes A...

How to rename the default identifier param "id" in Rails' map.resources()?

I like all the default routes that are generated by Rail's map.resources. But, there are cases where I would like to use a non-numeric identifier in my routes. For example, If have a nested route consist of users and their articles, a standard route could be written as such: map.resources :users, :has_many => [:articles] # => e.g. '/us...

is there any way to see which route matched a request from the browser in Rails?

In my routes.rb file I have a number of routes. I would like to know which one got matched for any request a user may have made. For example, in routes.rb you have the following routes : map.connect ":controller/:action" map.connect ":controler/:action/:id" and if I have a controller named a and an action named first, when a user g...

How to turn route into URL in ASP.NET MVC Controller?

In a View, code like this will generate the right URL to jump to controller's action method based on the routes in your global.asax.cs file. <%= Html.ActionLink("text", "action", "controller") %> My question is how can I achieve a similar route-to-URL mapping outside a view, such as a Controller? There is no Html member on the Cont...

MVC Routing - Use route part to switch views...

I have a series of URLs that look like /Catalog/Ajax/Update/{ViewToUpdate}?var1=a&var2=b&var3=c Currently I've setup several routes - one for each {ViewToUpdate} and what I'd like to do is pass the {ViewToUpdate} to my Action handler so I can condense my code. Instead of: public ActionResult AjaxUpdateNavigation(string var1, string...

Rails using named routes within helper (but with class methods)

Trying to use this method (gist of which is use self.method_name in the FunnyHelper, then call it as FunnyHelper.method_name in the view). However this causes at least a couple of problems - view methods like h() and named routes get broken (they're ok with the module method def method_name but not within any class method def self.metho...

Zend Route Regex Reverse problem with forward slashes

Hi I have a problem with reverse for regex routes, my config file is below: routes.route1.type = "Zend_Controller_Router_Route_Regex" routes.route1.route = "([^\,]+)([^p]*)(?:\,page_[0-9]+)?\.html" routes.route1.defaults.controller = "index" routes.route1.defaults.action = "find" routes.route1.map.1 = "url_path" routes.route1.map.2 = "u...

Create a Route Constraint that only applies a route when the action has a particular action filter

I have a list of actions on various controllers that are 'Admin' functions (create, update, delete) but other actions on those same controllers that aren't admin actions. What I want to do is create a route that will prefix /Admin/ before all urls that call an action that have the Authorize filter attribute. Is this even possible to do...

Rails CRUD Parameters Issue

So my background is in Java web services, but I'm trying to make the move to ROR. I'm using FlexImage to handle image uploading and thumbnail generation. I followed the guide and CRUD behavior was working fine at one point. However, at some point, CRUD behavior for one of my models (Images) was broken. The error code I'm getting back...

How can I have lowercase routes in ASP.NET MVC?

How can I have lowercase, plus underscore if possible, routes in ASP.NET MVC? So that I would have /dinners/details/2 call DinnersController.Details(2) and, if possible, /dinners/more_details/2 call DinnersController.MoreDetails(2)? All this while still using patterns like "{controller}/{action}/{id}". ...

Can edit_order_path be wired to the "modify" action (not the "edit" action) of the Orders controller?

<%= link_to 'Edit', edit_order_path(@order) %> Is it possible to wire this link to the modify action of the Orders controller (instead of the edit action) without changing this syntax: edit_order_path(@order) ...