I need to confirm ownership of domain, as instruction says, place special .html file in main directory.
It confused me. Tutorial says, that file should be avaliable as www.domain.com/file.html
I placed it in views folder, but nothing. I wouldn't like to set special controller-action-route for that(it is quite weird), but looks like I should? Or other way?
How do I do that in terms of Rails app?
Just put file.html under the public folder, and visit www.domain.com/file.html
In Rails everything within the public folder is visible to the outside world.
Related
This happened on ASP MVC.
When i tried to get access files from "Views" it can't read it.
I tried to get it showing like localhost:6036/Home(file content) and not like localhost:6036/Home/Home(file content)
already tried to move Home.cstml to any folder but it didn't work at all. it still gets me a message server error "/"
and now this is what my href looks like on "_Layout.cstml"
href="~/Views/Home">
So is there any possible to get "localhost:6036/(this is a directory file which i can access)"
If yes, how to that?
Thanks.
As you can see in the link below, MVC denies direct access to your views (that ends either in aspx/ascx, either in cshtml/ vbhtml) :
https://forums.asp.net/t/1799101.aspx?How+deny+access+direct+URL+to+my+partial+views+
If you just want to share a file (like an image, or anything else) you should use the "Content" folder.
Hope it helps !
I have the following folder structure in my zend framework 2 tutorial project in Ubuntu:
/zf2tutorial
/module
/Album
/view
/album
/album
myImage.png
index.phtml
in my index.phtml code I have a line such as this:
<img alt='SMALLIMG' src='myImage.png'/>
this does not work.
If I change the myImage.png to be http://www.someurlhere.com this works fine.
How do I load in myImage.png instead? I tried giving it the direct URL:
/home/myUsername/NetBeansProjects/zf2tutorial/module/Album/view/album/album/myImage.png
I've also tried doing the following:
../myImage.png
but neither of these worked.
Also please note, it has to be a bad path (I must be doing something wrong here) because the broken image icon shows up... indicating there is a linking problem here.. the direct URL is copy pasted from the properties section of the image itself..
It's not a problem of image or path. You are trying to make an impossible thing.
You certainly define in your virtualhost configuration that the documentRoot is your public directory.
That means your web server will give access to resources located from this public directory.
You have to put your resources from this public path (css, images..) or you can define a symbolic link if you allow followingSymlinks.
Hope this helps.
<img alt="" src="img/2 header960.png" align="center" >
The fundamental issue you are confusing is the difference between views vs public content.
View files are essentially HTML templates into which you can inject certain values at runtime. Your directory structure correctly places this stuff within a views directory inside your module. These template files themselves are never exposed to the end-user. They are only used by the application to generate fully-populated HTML chunks that are eventually sent to the browser.
In contrast, static assets - like images, javascripts, external stylesheets, etc - are served directly by the webserver to your visitors. As such they need to be in a directory that the webserver has been told to publicly serve to visitors.
The easy thing to do is to simply move directories containing these static assets out of the module and into the app's public folder.
But this is undesirable in the sense that you might reasonably want the module to be a self-contained entity: it can contain its own routes, its own controllers/actions, and, in particular, its own static assets.
So, how to make the webserver reach down into the module and treat some of the content there as "public"?
The answer is to use an "asset manager", a component that links certain module content into the app's public directory. Typically this means:
Activate the asset manager module
Create a public directory inside your module
Place those static assets there
Inform the asset manager which public module directories into the public app directory.
Take a look at the AssetManager module by Roberto Wesley Overdijk and additional instructions for use.
[As a side note, welcome to the world of web development. ZF2 is a great framework, but it's not the easiest thing for a beginner. It provides a lot of flexibility for doing things in a "good way", but it can certainly come off as convoluted at first. Try not to get discouraged. ;-)]
the reason may be the image extension (.png)
please check your exact extension case, is it written in small or capital case???
update your image link exactly as like the name of image.
eg.
myImage.png or myImage.PNG
try to look for an .htaccess file somewhere in your dir most probably on module folder..that file blocks the access for the image you are trying to link..(my basis here is my application in yii which fails to show the image even if the path is correct)
you may create an images folder in your home dir: /zf2tutorial/images for example and put all the images there calling it: src="/images/myImage.png"..
or
find the htaccess im talking about, change the restrictions(or delete it:|) and you can use this path: src="/module/Album/view/album/album/myImage.png"..
<div id='small_image'>
<a href='/feeds/posts/default' title='smallimg'>
<img alt='SMALLIMG' src='c:/home/myUsername/NetBeansProjects/zf2tutorial/module/Album/view/album/album/myImage.png'/>
</a>
</div>
in my grails application I would like to make all files in a specific folder in my web-app directory to be public so I can use them whenever I want. Is this possible when messing around with ApplicationResources.groovy config or is there any other smart way to make them public without calling them directly?
I imagine something like this: resource url:'images/flags/*'
Apparently the Resources plugin does not have this feature, see Resources Plugin -- How To include all contents in a directory?.
The linked post does, however, include a solution.
I have used paperclip to allow me to upload files to a rails application. Everything works and the file is uploaded, but instead of seeing a link to the actual file itself I see the location of it within the systems folder of the rails project.
I'm guessing its either a routing issue or I need to create a link to the file in question. However, I would like to hide the location of the file itself, and only see the link displayed.
I would be very grateful if someone could point me in the right direction here.
You want to hide the actual path of the file in the server, right?
You can achieve that using send_file (http://api.rubyonrails.org/classes/ActionController/DataStreaming.html#method-i-send_file) in a normal controller.
You will still need to do something to protect the download using the real path.
Am working my way thru Ruby on Rails Tutorial: Learn Rails by Example. I'm in the section entitled Mostly Static Pages.
I get an error after I create an HTML page in the public directory which is called public/hello.html and should appear as in Figure 3.3. My problem is that when I try to create the page and make it appear at localhost:3000/hello.html I don't see the rendered page. Instead, I get an error which says "Routing error No route matches "/ hello.html"
I have not made any changes to the routing; I thought that Rails was supposed to be smart enough to find "hello.html" because it's in the same directory as the "public/index.html" page and the name of the page is "hello.html"?
Can you please explain?
If you're like me and powering through the book, I left the server running from the prior chapter, so it was still loading index.html from the demo_app directory.
You're following an old guide. A newer version
http://ruby.railstutorial.org/chapters/static-pages#sec:green
tells you that you need to modify the routes.rb in the config folder.
I spent about an hour crying about this.
Are you sure you typed this correctly? It looks like you've typed "localhost:3000/[space]hello.html" rather than "localhost:3000/hello.html". Please double check.
Move the file to the Public folder. That did the trick for me.
The hint I used is that Rails serves the Public folder by default. So I figured, if I put it in the Public folder, that ought to work. You'll see it's in line with the index file, so I think that's proof, too.
Review your app directory again and make sure you save the file in (my case) :
C:\Users\Nnamdi\rails_projects\sample_app\public\hello.html
I had the same issue but realized that I did not save it in the right directory
..The solution above should work..cheers