routes

cannot generate routes

hello frens i have a problem as following. i have a resources setup in my routes.rb file as following resources :users do resources :sub_transactions end resources :sub_transactions do collection do get :income get :expenditure end end Now what is the correct route that i should write so that i can generat...

adding new routes and actions to restful resource in rails 3

Look at these stackoverflow urls. [1] http://stackoverflow.com/questions [2] http://stackoverflow.com/questions/tagged/ruby I need to achieve exactly this. I have a resource called questions with RESTful routes defined as follows. resources :questions do end I have a tagged action in my questions_controller which takes in a paramet...

Python routes - I'm trying to set the format extension but it's failing

I'm trying to setup my Routes and enable an optional 'format' extension to specify whether the page should load as a standard HTML page or within a lightbox. Following this http://routes.groovie.org/setting_up.html#format-extensions, I've come up with: map.connect('/info/test{.format:lightbox}', controller='front', action='test') clas...

Rails Restful Routing and Subdomains.

Hi I wondered if there were any plugins or methods which allow me to convert resource routes which allow me to place the controller name as a subdomain. Examples: map.resources :users map.resource :account map.resources :blog ... example.com/users/mark example.com/account example.com/blog/subject example.com/blog/subject/edit ... #b...

Searching ActiveRecord timestamps using a optionally specific date

Given the following route: match "/articles/(:year/(:month/(:day)))" => "articles#index", :constraints => { :year => /\d{4}/, :month => /\d{2}/, :day => /\d{2}/ } And the following set of URLs: /articles/2010 /articles/2010/09 /articles/2010/09/08 Does ActiveRecord offer any sort of built-in find method that would allow me to find ...

how get all routes in my rails application?

Sorry for my english. can I get all routes in my rails application? I need an output like rake routes and put the result in an array. Is it possible?, how? Thanks! ...

Rails Routes - Limiting the available formats for a resource

I have a series of resources that I want only available if accessed via the JS format. Rails' route resources gives me the formats plus the standard HTML. Is there a way to specify that only the JS format routes be created? ...

to_sym error when using sessions

I have a "cart" model, a users cart id is stored in their session. My routes look like this map.resources :carts map.cart "cart", :controller => "carts", :action => "show" in my show view, i displayed the contents of the cart, and everything was fine. Then i decided i wanted the user to be able to update the quantity of items from th...

Simple one model singular resource routing problem.

I have a stripped down shopping cart application, currently with one model "cart", the cart id is stored in a session. the cart controller has this method so we always have a cart def initialize_cart if session[:cart_id] @cart = Cart.find(session[:cart_id]) else @cart = Cart.create session[:cart_id] = @cart....

Install Mogli Gem on Rails 3

I am trying to install the mogli gem( http://github.com/mmangino/mogli ) on rails 3 and am running into problems with the configuration. I have NO prior experience with Rails 2. For Rails 2 Add config.gem "mogli" to environment.rb For Rails 3, I added the following to the gemfile. gem 'mogli' For Rails 2, routes map.resource :...

What is the preferred solution to dealing with dozens of route mappings in Global.asax

I was reading the following answer about regions on the topic of programming standards: http://programmers.stackexchange.com/questions/1338/worst-coding-standard-youve-ever-had-to-follow/1937#1937 I tend to agree with what @Cumbayah is saying, but I have to admit that there's one place where I'm relying on regions to keep the code tidy...

about rails' routes, adding collection routes to restful resources won't generate named route helpers ?

namespace :admin do resources :posts do collection do get 'whatever' end end end I was expect that will generate 'whatever_admin_posts_path' helper method, but it didn't. It's there something wrong with my codes? Or a bug in rails? ...

Extra params in Rails 3 routes and resources

The new rails routes are great in many aspects, but I am looking for the best way to achieve page caching with pages and formats like I had in rails 2.x and am coming up short I have many possible desired routes of the basic formulas: /(bazes/<baz id>/)(foos/<foo id>/)bars/page/<page num>/<format> Example routes: /bars/page/1/xml /f...

Rails 3: How to test router scope?

Hi, I'm using Rails 3.0 and I have the following in my routes.rb files: scope "/:location" do resources :agents end So I can do this: agents = Agent.where("location = ?", params[:location]) (There might be a better way to do this..? Mostly I want URLs like: myurl.com/london/agents) Anyway, my problem is with the tests (which I...

Server returning no response for certain URLs for Rails app on Apache2

I just implemented a new controller in Rails, and added routing info to routes.rb. Things work fine when I access the new URL on my local machine in dev mode. However, after pushing the changes onto my prod server and attempting to navigate to the URLs controlled by the new controller, I get no response from the server. I've tried restar...

Is it against the Restful Rails route default to submit page back to itself.

Here's the scenario of out of the box map.resources I'm on /users/new Submit -> /users/ rescue error render new URL: is /users/ If User.index never defined. I copy the URL to another tab, it'll have routing error. How can I have the URL showing /users/new while activerecord errors persists on the page? ...

ASP.NET MVC - Html.BeginForm(). Can I post back to a different route and keep existing querystring values?

I have a post-only action that has a different route. In my form, I need to post to it, but also keep the querystring values I currently have. Initial response: /my/first/path/?val1=hello Needs to post to: /my/other/path/?val1=hello It seems when I specify a route, it of course only returns the route and doesn't append the querystrin...

Managing routes/Global.asax maintainability

Is there any best practice for how to best define and organize routes in MVC? The company I work for runs a very extensive, complex ecommerce site with ~600K unique visitors/day. Here's the problem: in our Global.asax.cs, we've got this HUGE list of approximately 75 route definitions in our RegisterRoutes(): routes.MapRoute( "Defa...

rails routes confusing show action with named route

i have a problem implementing a list action with its own route. here is what i have (just important parts) routes.rb map.resources :posts map.login "login" ,:controller => "user_sessions" ,:action => "new" map.logout "logout" , :controller => "user_sessions" , :action => "destroy" map.sort "sort" , :controller => "pos...

Route question regarding Authlogic and Rails 3.0.0

I upgraded an app I am working on from Rails 3.0.0.beta4 to Rails 3.0.0 and hit an unexpected error. I'm using authlogic for authentication, and after the upgrade the route for new user session form started throwing this error. undefined method `user_sessions_path' Ok, I'm using a singular controller name. Not sure what is different be...