routes

Why does RouteLink generate friendly URL while ActionLink does not?

Hi there. I have a question regarding RouteLink vs. ActionLink. Consider the following route routes.MapRoute("Routename1", "{someEnum}/SpecificAction/{id}/{stringId}", new { controller = "MyController", id = (int?)null, stringId= (string)null, action = "SpecificAction" }, new { someEnum= "(EnumVal1|EnumVal2)" } ); The we...

Rails route globbing vs. escaping?

Hi. I'm trying do something like this: map.goto '/g/*extra', :controller => 'goto', :action => :show Where extra is a path component, e.g.: redirect_to goto_url( employee_path(employee) ) What I get is: http:://www.example.com/g/%2Femployee%2F123 What I want is: http:://www.example.com/g/employee/123 So my question is: altho...

Rendering Partial from outside main/index.rhtml...Ruby on Rails

Ok I have posted a couple of things that had to do with my problem but I think I have it narrowed down. Here is where I am at: I have my index.rhtml page inside of /views/main and the main_controller is set up correctly. I am attempting to make this page a dashboard of sorts so it needs to reference multiple other views to display their...

routes.rb explicitly choose template

I would like to create one .erb file to be the output for a number of tiny actions that are just returning JSON. So with routes similar to: map.json 'contacts_json', :controller => 'contacts', :action => 'get_json' map.json 'cal_json', :controller => 'calendar', :action => 'get_json' ... but this requires I create a contacts erb, and...

Want any alphanumeric and underscore, dash and period to pass

In my controller, I current set a constraint that has the following regex: @"\w+" I want to also allow for underscore,dash and period. THe more effecient the better since this is called allot. any tips? ...

using a wildcard route, what to check for page number at the end

I have a wild card route, but at the same time I want to check for the existance of a page number at the end of the url. so my url might look like: www.example.com/category/parentcat/childcat/234 where 234 is the page number. the route currently looks like: new Route("category/{*category} Since its a wild card route, I can't put ...

ruby-on-rails: passing params through a route & link_to

I have a name route: map.up_vote 'up_vote', :controller => 'rep', :action => 'up_vote But up_vote requires two arguments to be passed in, postID and posterID and I can't seem to figure how to do that in a partial, but in an integration test I have no issues. Partial: link_to 'Up Vote', up_vote_path, {:postID => session[:user_post_i...

Is it possible to get the controller, action and routeValues from a URL (based on the Global.asax routes)?

I have a URL. Is it possible to somehow get the controller- and action-name and the routevalues? (which would normally be generated by the .NET MVC framework based on the definition in global.asax) ...

MVC Route Constraint for bool

What would be a valid regex for a MVC route constraint passing a bool? For example, I have the below route: routes.MapRoute("MenuRouteWithExtension", "Menu.mvc/{action}/{projectId}/{dealerId}/{isGroup}", new { controller = "Menu", action = "RedirectUrl", projectId = "", dealerId = "", isGroup = "" }, new { projectId = @"\d+", dealerId ...

Redirect asp.net mvc page from business logic class

I am calling a static method within my business logic layer that, for purposes I won't mention here, needs to do the redirecting itself rather returning information back to the controller to do the redirect. I figure I need to use the HttpContext object but am struggling with creating the route. I can't simply do context.Response.Redir...

Redirect root url to somewhere else in Rails application

I have routes like this: map.namespace 'prepayments', :path_prefix => '/:locale/prepayments' do |prepayment| prepayment.root :controller => 'login', :namespace => 'prepayments' ... end map.redirect '/', :controller => 'prepayments/login' # this is not working # I tried also map.root :controller => 'prepayments/login' What I wou...

Rails Polymorphic Associations plus Routes

I have a model, Report, that is polymorphic. So many itens in my site may have many of it. And i would like to have a generic controller for posting it. Its a very simple model, has only a text message and the association. in my routes, im doing something like map.resources :users, :has_many => [ :reports ] map.resources :posts, :has_...

Permalinks with Ruby on Rails (dynamic routes)

I am currently developing a blogging system with Ruby on Rails and want the user to define his "permalinks" for static pages or blog posts, meaning: the user should be able to set the page name, eg. "test-article" (that should be available via /posts/test-article) - how would I realize this in the rails applications and the routing file...

How to define this route in ASP.NET MVC ?

Hi, I have a controller named Movie, with an action named ByYear, which takes the year as a parameter : public ActionResult ByYear(int year) { ViewData["Title"] = string.Format("Movies released in {0}", year); var repository = MvcApplication.GetRepository(); var movies = repository.Medias ...

Multiple Origins - Multiple Destinations

I either have a blonde moment or am attempting something a bit out of my league, but here it goes ;) I have an optimization question. It is only somewhat traveling-salesman-ish. Lets say I have a set of destinations and another corresponding set of origins. I need to link each destination with one origin so that the variation between...

CodeIgniter Custom Admin URI Routes

UPDATE: SOLVED! For the broken pages I simply made an admin controller. That has a function for each model now :) Happy days! Trying to house my admin function in the same controller as my front-end code. To do this I am setting up some custom routes so that admin can be accessed via: /admin/controller/id // instead of /controller/admi...

My routes seem setup correctly, but are generating incompatible urls

My "link_to" and "url_for" etc. methods are generating paths in the pattern of ":controller/:id/:action", instead of ":controller/:action:/:id" - in other words my "action" and "id" fields in the url are getting swapped. I've narrowed it down to these generated links through doing some route debugging, however, I don't quite understand ...

? in routes.rb with map.with_options ruby

Hi guys, I'm using named routes in my ruby code. I come from the phpworld where you'll pass information using $_GET and $_POST. I was wondering if there's a way to put this into the routes.rb like this: map.with_options :controller => 'test' do |m| m.someurl 'someurl?search=someterm', :action => 'index' end Currently it's returni...

Nested named routes in rails?

Lets say you have a two models with blog posts and comments set up like this: class post has_many :comments and the routing was set up pretty much the same way: map.resources :posts, :has_many => :comments When I go to make a new comment it shows up as localhost::3000/postname/comments/new What should you do in order to make the ...

how will you do this in MVC custom route?

www.yoursite.com/image/http://images.google.com.ph/images/nav_logo7.png What I need to know here is the Controller Action, and the Global.asax routes ...