This project is archived and is in readonly mode.
AbstractController#asset_path overrides routes helper
-
Michael Koziarski
- Milestone cleared.
- Importance changed from to High
-
rdavila
- Tag changed from actionpack rails3 to actionpack rails3, invalid
I can't reproduce this bug, I'm using the following:
- Rails Edge
- ruby 1.8.7 (2010-08-16 patchlevel 302) [i686-linux]
I had created an Asset scaffold and insert one record, next I had modified the index action to:
redirect_to asset_path(Asset.last)
And all it's ok, the action redirect to AssetsController#show.
-
Michael Schuerig
- Tag changed from actionpack rails3, invalid to actionpack rails3
I've tried this again in a fresh app on 3.0.0 and it still breaks. I can't test on Rails Edge, as apparently bundler can't resolve dependencies right now (something about activesupport ~> 3.0.0 and 3.1.0.beta).
Anyway, the relevant code hasn't changed in the meantime. Please have a look at abstract_controller/asset_paths.rb. There config_accessor defines a method #asset_path taking no arguments. AssetPaths is included in ActionController::Base which makes #asset_path (no-args variant) available in controllers.
I don't know why you don't get an exception where I do. Let's establish two things:
- The method #asset_path defined in AbstractController::AssetPaths is supposed to be available in controllers.
- If
resources :assetsis defined in routes.rb, #asset_path(asset) is supposed to be available in controllers (among other places). - These two methods are in conflict with each other.
Do you agree?
-
David Trasbo
- State changed from new to open
Michael,
Yes,
asset_pathis supposed to be accessible in both Action Mailer and Action Controller.I can see two ways around it. You could obviously rename it. Or: You could change the syntax of accessing
asset_hostandasset_pathto beassets.hostandassets.path.I might look into making a patch for solution #2 - though I suspect it could get a bit complicated.
-
Andrea Campi
I can confirm this issue on 3.0.0 with both Ruby 1.8.7 and 1.9.2; I could not reproduce it on Rails Edge.
However, the opposite is true: #asset_path would now be unaccessible in AssetsController and its views.
-
Andrea Campi
... and replying to myself: there's no point in calling AssetPaths#asset_path since it may well be a Proc.
-
Andrea Campi
I'm attaching two patches, on master and 3.0 respectively.
With this patch applied I cannot reproduce the issue on 3.0; on master the behavior is unchanged.That said, I don't like asset_base_path any better than the previous name (it used to be asset_path_template).
If you have a better idea, I can easily reroll the patches.(also, I've made sure tests pass with success)
-
Jeff Kreeftmeijer
- Tag changed from actionpack rails3 to 3.0, actionpack, patch
-
Ryan Bigg
- Tag changed from sheepskin boots, 3, actionpack, patch to 3.0 actionpack patch
Automatic cleanup of spam.
-
Andrea Campi
- Tag changed from 3.0 actionpack patch to 3.0, actionpack, patch
-
Samuel Kadolph
Quick fix to get 3-0-stable working correctly. Not sure about best solution for master. Probably best to separate out asset configuration from AC and AV and put it with the Application.
-
thoefer
Fix for 3.0.5.RC1 attached. It´s basically Samuel Kadolph´s patch, but without the RoutingError in 3.0.5.RC1. This error seems pretty easy to solve. But maybe I don´t see the big picture?! In this case: Any hints? Any comments?
