2009/8/29 Chris Hanks <[email protected]>: > > I've found naming a resource "Test" to be problematic, which is kind > of a drag in an educational application. >
For future reference a list of words to be avoided can be found at http://wiki.rubyonrails.org/rails/pages/ReservedWords. It would be useful if the generators showed a warning when any of these words is used. Colin > > > On Aug 28, 7:06 pm, carr <[email protected]> wrote: >> On Aug 28, 1:17 pm, Jarl Friis <[email protected]> wrote: >> >> >> >> >> >> > Hi. >> >> > I can't be the only one in the world having the wonderful idea to have >> > a resource named "image". >> >> > I have a controller named images_controller >> > I have a route named "image", and therefore a helper called >> > image_path(id). >> >> > But using image_path in an action view erb file gives problems, there >> > another helper named image_path[1] is defined, hence I can no longer >> > use the named route url helper image_path >> >> > For now I have changed my routes.rb from >> > map.resources :images >> > to >> > map.resources :images, :singular => "my_image", >> >> > Then I can use my_image_path in action views. >> >> > But... Isn't image such a common word for a resource that [1] should >> > have a different name, e.g. asset_path, image_asset_path, or something >> > else. There is already an alias path_to_image[1]. How about just stick to >> > that? >> >> > What do you say? >> >> > There are some others having this problem: [2] >> >> > Jarl >> >> > Footnotes: >> > [1] >> > http://api.rubyonrails.org/classes/ActionView/Helpers/AssetTagHelper.... >> >> > [2] http://forums.pragprog.com/forums/59/topics/2723 >> >> Not directly related to your problem but I had problems in the past >> with resources named >> - Type (this is very common in my opinion) >> - Controller >> >> Mostly it was that some part of scaffolding didn't work, because of >> the @controller variable already used in the controller. >> >> I don't have a real good solution for this, except maybe issue a >> warning to the user when he tries to scaffold from these specific >> resource names. Something like "you could have problems, choose a >> different name". This warning could also suggest an appropriate >> substitute name. >> >> This could also apply to your "Image" problem. The scaffold could >> suggest for you to rename it to something else, say "Picture". >> >> Tomislav > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
