Ruby on Rails
Saturday, May 2, 2015
Working with Rails 3.0
From numerous controllers with associated views, I need to display images.
In the views to retrieve an images I have:
<img src="<%= get_image_path(@object.image_file_name) %> />
get_image_path is defined in the Application helper:
module ApplicationHelper
def get_image_path(sought_image_file_name)
return_string = ''
unless (sought_image_file_name.blank? ## although I do testing for blank? image_file_name in the erb view
return_string = "#{Rails.application.root}/public/images/item_images/" + sought_image_file_name
### Have tried return_string "../public and "./public and these have not worked
end
return return_string
end
...
But I keep getting the error:
Started GET "/home/echomarket/echomarket.org/public/images/item_images/zv37bNYgL25LisYvnGfGkKMndfm7ZD_Chrysanthemum.jpg" for ...
ActionController::RoutingError (No route matches "/home/echomarket/echomarket.org/public/images/item_images/zv37bNYgL25LisYvnGfGkKMndfm7ZD_Chrysanthemum.jpg"):
The file definitely exists in that path, per FIleZilla and Putty
I do not understand the tie between routes.rb and multiple controllers....
Thanks,
Liz
-- From numerous controllers with associated views, I need to display images.
In the views to retrieve an images I have:
<img src="<%= get_image_path(@object.image_file_name) %> />
get_image_path is defined in the Application helper:
module ApplicationHelper
def get_image_path(sought_image_file_name)
return_string = ''
unless (sought_image_file_name.blank? ## although I do testing for blank? image_file_name in the erb view
return_string = "#{Rails.application.root}/public/images/item_images/" + sought_image_file_name
### Have tried return_string "../public and "./public and these have not worked
end
return return_string
end
...
But I keep getting the error:
Started GET "/home/echomarket/echomarket.org/public/images/item_images/zv37bNYgL25LisYvnGfGkKMndfm7ZD_Chrysanthemum.jpg" for ...
ActionController::RoutingError (No route matches "/home/echomarket/echomarket.org/public/images/item_images/zv37bNYgL25LisYvnGfGkKMndfm7ZD_Chrysanthemum.jpg"):
The file definitely exists in that path, per FIleZilla and Putty
I do not understand the tie between routes.rb and multiple controllers....
Thanks,
Liz
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/798b9826-240d-4134-a87b-7d146f081b7e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment