This worked fine because I have my WEBrick server
(http://localhost:3000)
and that image pointed to “/images/category.png”, which was equal to
“localhost:3000/images/category.png”.
However, I’ve just uploaded my application to a server, under a
directory called “ToDo” (yes, it’s the 4daysOnRails app :D).
Here the image does not work, cause is referring to
“mydomain.com/images/category.png”, and the image is really located at
“mydomain.com/ToDo/images/category.png” (under the specific “ToDo”
directory).
I’ve just changed that in the uploaded app (link_to_image
“/ToDo/public/images/category”) but, how can I put the link so it works
at both places?
Thanks a lot.
PT: I’ve seen the url_for stuff, but I don’t know how to use it with
this…
However, I’ve just uploaded my application to a server, under a
directory called “ToDo” (yes, it’s the 4daysOnRails app :D).
Here the image does not work, cause is referring to
“mydomain.com/images/category.png”, and the image is really located at
“mydomain.com/ToDo/images/category.png” (under the specific “ToDo”
directory).
I’ve just changed that in the uploaded app (link_to_image
“/ToDo/public/images/category”) but, how can I put the link so it works
at both places?
Thanks a lot.
PT: I’ve seen the url_for stuff, but I don’t know how to use it with
this…
Rails uses urls form the root of the domain frequently since the routes
create what look directory and confuse browsers using relative urls
looking for assets.
Try to install your on a subdomain rather than just a subfolder. Also
be very careful that your config/database.yml is not publically
accessible or you could find your entire database hacked one day.
I think whant you want to do is set the asset_host configuration
parameter for production mode to “/ToDo”
You might need to be wary of http://dev.rubyonrails.org/ticket/5406
I think whant you want to do is set the asset_host configuration
parameter for production mode to “/ToDo”
You might need to be wary of http://dev.rubyonrails.org/ticket/5406
Fred
I would try to change the production.rb to set the appropiate asset,
cause the server is not mine and I don’t think they give me a subdomain.
However, I don’t really know how Rails set the URL’s, cause:
1: controllers and actions in the controllers are set correctly:
/ToDo/items/…, not /items…
2: Style sheets are also in the public directory but Rails get them
correctly (/ToDo/public/stylesheets/…, not /public/stylesheets… )
I think whant you want to do is set the asset_host configuration
parameter for production mode to “/ToDo”
You might need to be wary of http://dev.rubyonrails.org/ticket/5406
Hi you all, after changing the asset in environment/production.rb (to
"config.action_controller.asset_host = “/ToDo” ") something strange
(for a newbie like me) has ocurred:
– With stylesheets: Before the change, the url Rails applied to the CSS
was right: ToDo/public/stylesheets/todo.css. After the change is
ToDo/ToDo/public… so it does not work
– With images (which was my initial problem):…nothing has happened! The
url is still /images/image.png…
What can I do?
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.