rubyonrails-c4f1mTqwXZkdnm+yROfE0A@public.gmane.org
2004-Nov-01 06:19 UTC
Is #link_to broken?
Hi I setup a simple rails app (following along with the demo) and was trying to setup a link with #link_to. However, if I tried to do link_to "Edit", :action => "edit", :id => post.id for example, the URL was coming out /myapp/1 instead of /myapp/edit/1 I thought it was me at first then I started over and just did the scaffolding code. All the links were missing the action path in their URL. For example, I had the following /myapp/1 # for Show /myapp/1 # for edit /myapp # for add new The versions I am running are: % gem list *** LOCAL GEMS *** actionmailer (0.3.0) Service layer for easy email delivery and testing. actionpack (0.9.0, 0.8.5, 0.8.0) Web-flow and rendering framework putting the VC in MVC. activerecord (1.0.0, 0.9.5, 0.9.4) Implements the ActiveRecord pattern for ORM. dnssd (0.6.0) DNS Service Discovery (aka Rendezvous) API for Ruby rails (0.8.0, 0.7.0, 0.6.5) Web-application framework with template engine, control-flow layer, and ORM. rake (0.4.9, 0.4.8, 0.4.4) Ruby based make-like utility. sources (0.0.1) This package provides download sources for remote gem installation Can someone help with this? Thanks -- Jim Freeze
rubyonrails-c4f1mTqwXZkdnm+yROfE0A@public.gmane.org wrote:> I thought it was me at first then I started over and just > did the scaffolding code. All the links were missing the action > path in their URL.I noticed this too the other day. -- Marten Veldthuis
I experienced similar behavior, and I believe that it was caused when the controller part of the link did not have a trailing slash (e.g., myapp/controller instead of myapp/controller/). The links I was creating were then exactly like you describe. Adding the trailing slash fixed it for me. On Mon, 01 Nov 2004 11:17:56 +0100, Marten Veldthuis <marten-bhBtkFhEHeMTIWBel16Y73nhMCiq3JZZ@public.gmane.org> wrote:> rubyonrails-c4f1mTqwXZkdnm+yROfE0A@public.gmane.org wrote: > > I thought it was me at first then I started over and just > > did the scaffolding code. All the links were missing the action > > path in their URL. > > I noticed this too the other day. > > -- > Marten Veldthuis > > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
rubyonrails-c4f1mTqwXZkdnm+yROfE0A@public.gmane.org
2004-Nov-01 13:56 UTC
Re: Is #link_to broken?
* Patrick Spence <patrick.spence-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> [2004-11-01 08:07:17 -0500]:> I experienced similar behavior, and I believe that it was caused when > the controller part of the link did not have a trailing slash (e.g., > myapp/controller instead of myapp/controller/). The links I was > creating were then exactly like you describe. Adding the trailing > slash fixed it for me.Ugh, I see the problem. Is this going to be fixed. I don''t think I can expect my users to always remember the slash. -- Jim Freeze
rubyonrails-c4f1mTqwXZkdnm+yROfE0A@public.gmane.org wrote:> Ugh, I see the problem. Is this going to be fixed. I don''t think > I can expect my users to always remember the slash.Try this Apache mod_rewrite rule to slashify your URLs: RewriteRule ^/myapp/([-_a-zA-Z0-9]+)$ /myapp/$1/ [R] The behavior should be fixed, but maintaining your URL convention is worthwhile regardless. jeremy
rubyonrails-c4f1mTqwXZkdnm+yROfE0A@public.gmane.org
2004-Nov-02 03:03 UTC
Re: Is #link_to broken?
* Jeremy Kemper <jeremy-w7CzD/W5Ocjk1uMJSBkQmQ@public.gmane.org> [2004-11-01 10:57:37 -0800]:> rubyonrails-c4f1mTqwXZkdnm+yROfE0A@public.gmane.org wrote: > >Ugh, I see the problem. Is this going to be fixed. I don''t think > >I can expect my users to always remember the slash. > > Try this Apache mod_rewrite rule to slashify your URLs: > RewriteRule ^/myapp/([-_a-zA-Z0-9]+)$ /myapp/$1/ [R]What do I do if I am using webrick? -- Jim Freeze
rubyonrails-c4f1mTqwXZkdnm+yROfE0A@public.gmane.org wrote:> * Jeremy Kemper <jeremy-w7CzD/W5Ocjk1uMJSBkQmQ@public.gmane.org> [2004-11-01 10:57:37 -0800]: > > Try this Apache mod_rewrite rule to slashify your URLs: > > RewriteRule ^/myapp/([-_a-zA-Z0-9]+)$ /myapp/$1/ [R] > > What do I do if I am using webrick?I opened a ticket; try the patch against Action Pack CVS. http://dev.rubyonrails.org/trac.cgi/ticket/159 micro-HOWTO: cvs -d:pserver:anonymous-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org:/var/cvs/actionpack login cvs -d:pserver:anonymous-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org:/var/cvs/actionpack co actionpack cd actionpack curl http://dev.rubyonrails.org/trac.cgi/attachment/ticket/159/AP-0.9-rewrite-slashless-index.diff?format=raw | patch -p0 rake test Best, jeremy