Hi, I''m 8+ hours reading and working through the book "Agile Web Development". My brain is now mush :) I have some php experience but that about the extent of my programming experience. Anyway, I do have a question - for those who know the book or those who don''t - The product table has a column for an image link ..i.e. /images/something.gif As part of the exercise validation was added in to the admin area for this field requiring a HTTP:// to precede the path to the actual graphic. For the life of me I can''t figure out what is the correct path. Depot is the project / head directory name. I have tried a variety of things including http://depot/public/images/x.gifnone of which seems to find the image. Can anyone give me a clue as to what the correct path would be within the rails file structure. Do I need to drop the http ? TIA Stuart -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060605/bac382c7/attachment.html
Stuart, You merely have to specify the image file name and extension in your "link_to". As long as the file is located in the "/depot/public/images/" folder the app will find and display it. Hope that helps. Nathan -----Original Message----- From: rails-bounces@lists.rubyonrails.org on behalf of Dark Ambient Sent: Mon 6/5/2006 2:38 PM To: rails@lists.rubyonrails.org Subject: [Rails] New to rails Hi, I''m 8+ hours reading and working through the book "Agile Web Development". My brain is now mush :) I have some php experience but that about the extent of my programming experience. Anyway, I do have a question - for those who know the book or those who don''t - The product table has a column for an image link ..i.e. /images/something.gif As part of the exercise validation was added in to the admin area for this field requiring a HTTP:// to precede the path to the actual graphic. For the life of me I can''t figure out what is the correct path. Depot is the project / head directory name. I have tried a variety of things including http://depot/public/images/x.gifnone of which seems to find the image. Can anyone give me a clue as to what the correct path would be within the rails file structure. Do I need to drop the http ? TIA Stuart -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/ms-tnef Size: 3125 bytes Desc: not available Url : http://wrath.rubyonrails.org/pipermail/rails/attachments/20060605/176da14f/attachment.bin
On Jun 5, 2006, at 03:38 PM, Dark Ambient wrote:> I''m 8+ hours reading and working through the book "Agile Web > Development". My brain is now mush :) > I have some php experience but that about the extent of my > programming experience.Welcome! I can somewhat empathize with your "mush" feeling. Rails is a whole lot to try and take in. :)> Anyway, I do have a question - for those who know the book or those > who don''t -Your question is actually relevant for far more than the depot application in the AWDR book.> The product table has a column for an image link ..i.e. /images/ > something.gif > As part of the exercise validation was added in to the admin area > for this field requiring a HTTP:// to precede the path to the > actual graphic. > For the life of me I can''t figure out what is the correct path. > Depot is the project / head directory name. > I have tried a variety of things including http://depot/public/ > images/x.gif none of which seems to find the image. > > Can anyone give me a clue as to what the correct path would be > within the rails file structure. Do I need to drop the http ?When building a URL reference to a static object in the Rails app''s public folder, you have to remember to drop the public/ from the path. Also, you would only add the depot/ to the path if you had specifically configured your Rails app to behave like a sub- directory. Otherwise, Rails apps always assume they are running at the top-level, with respect to the URL path. So, if you are running the depot app on your localhost at port 3000, the URL to the x.gif image would look like: http://localhost:3000/images/x.gif This is what you would use when running in development. If you plan to push this app into production, you''ll probably be using a different host name and port for your app... -Brian
Brian, Thanks for the help. Worked like a charm. Yes, Rails is a lot to take in. That book doesn''t take long and then it''s straight into a commerce / shopping cart project. I like that guerilla type of teaching. :) Stuart On 6/5/06, Brian Hughes <brianvh@alum.dartmouth.org> wrote:> > On Jun 5, 2006, at 03:38 PM, Dark Ambient wrote: > > I''m 8+ hours reading and working through the book "Agile Web > > Development". My brain is now mush :) > > I have some php experience but that about the extent of my > > programming experience. > > So, if you are running the depot app on your localhost at port 3000, > the URL to the x.gif image would look like: > > http://localhost:3000/images/x.gif > > This is what you would use when running in development. If you plan > to push this app into production, you''ll probably be using a > different host name and port for your app... > > -Brian > > _______________________________________________ > 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/20060605/4f23ee3d/attachment.html