Philip Hallstrom
2006-Apr-27 04:38 UTC
[Rails] Possible to use dashes instead of underscores in rails?
Hi all - My boss is asking me if we can have dashes instead of underscores in the URL for SEO reasons. Apparently google prefers "foo-bar" to "foo_bar". The former will be found when searching for just "foo", but not the latter. So, I''m wondering if there is a way without changing any of my code if I can tell rails to use dashes instead of underscores? Any ideas?
Mohammad
2006-Apr-27 04:49 UTC
[Rails] Re: Possible to use dashes instead of underscores in rails?
Philip Hallstrom wrote:> Hi all - > > My boss is asking me if we can have dashes instead of underscores in the > URL for SEO reasons. Apparently google prefers "foo-bar" to "foo_bar". > The former will be found when searching for just "foo", but not the > latter. > > So, I''m wondering if there is a way without changing any of my code > if I can tell rails to use dashes instead of underscores? > > Any ideas?Im a n00b but, maybe look into mapping it like this: map.connect ''foo-bar'', :controller => "foo_bar" -- Posted via http://www.ruby-forum.com/.
Mohammad
2006-Apr-27 04:51 UTC
[Rails] Re: Possible to use dashes instead of underscores in rails?
edit Im a n00b but, maybe look into mapping it like this: map.connect ''/foo-bar'', :controller => "foo_bar" -- Posted via http://www.ruby-forum.com/.
Mohammad
2006-Apr-27 04:52 UTC
[Rails] Re: Possible to use dashes instead of underscores in rails?
edit Im a n00b but, maybe look into mapping it like this: map.connect ''/foo-bar/:action'', :controller => "foo_bar" -- Posted via http://www.ruby-forum.com/.
Liquid
2006-Apr-27 04:56 UTC
[Rails] Re: Possible to use dashes instead of underscores in rails?
How would this affect say a link_to call in a view... say link_to "some place", :controller => "does_this_need_underscores", :action => "act" Would this then be mapped to the dash route? On 4/27/06, Mohammad <name.goes.here44@gmail.com> wrote:> > edit > Im a n00b but, maybe look into mapping it like this: > map.connect ''/foo-bar/:action'', :controller => "foo_bar" > > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060427/fd75924c/attachment-0001.html
Mohammad
2006-Apr-27 05:16 UTC
[Rails] Re: Re: Possible to use dashes instead of underscores in rai
I think so but rendering I would test <a href="/contoller/action">Text</a> so map should fix. As for rendering that needs to be ran by a test -- Posted via http://www.ruby-forum.com/.
Alex Wayne
2006-Apr-27 06:19 UTC
[Rails] Re: Possible to use dashes instead of underscores in rails?
Philip Hallstrom wrote:> Hi all - > > My boss is asking me if we can have dashes instead of underscores in the > URL for SEO reasons. Apparently google prefers "foo-bar" to "foo_bar". > The former will be found when searching for just "foo", but not the > latter. > > So, I''m wondering if there is a way without changing any of my code > if I can tell rails to use dashes instead of underscores? > > Any ideas?map.connect ''foo-bar/:action/:id'', :controller => ''foo_bar'', :action => nil, :id => nil url_for :controller => ''foo_bar'' #=> /foo-bar url_for :controller => ''foo_bar'', :action => ''narf'' #=> /foo-bar/narf url_for :controller => ''foo_bar'', :action => ''show'', :id => @foo.id #=> /foo-bar/show/123 Setting the routing params to nil tell the router they are optional. -- Posted via http://www.ruby-forum.com/.