Rails route dynamic number of segment - ruby-on-rails

I search to use url like that
/tree/show/folder/subfolder/……/subsubfolder
the content of the page will match the content of a physical folder
The number of segment can be variable obviously since I can show folder then subfolder then another, then another…… As you can imagine it can be long (and of course I'm aware of the limitation of url length)
I precise that I do not want to show public content (like it was already asked here), but to show a page with information relative to a folder
Is it possible ?

You can use wildcard route globbing. Eg:
get 'folders/*subfolders', to: 'folders#index'
This will direct a request for /folders/subfolder/subsubfolder/subsubfolder/ to FoldersController#index, and the called path subfolder/subsubfolder/subsubsubfolder will be accessible in params[:subfolders]
http://guides.rubyonrails.org/routing.html#route-globbing-and-wildcard-segments

Related

How to use external URL as path (Rails)

I am trying to create routes within an app that I am working on like the following example:
http://www.example.com/entrepreneur.com/article/251468
My hope is to basically load an external page into an iframe by adding our domain to the URL. It needs to be without storing the external url in a database because I need every website accessable in this way. How can I do this?
You need a route with a wildcard like this:
get 'url/*args', to: 'your_controller#your_action'
See http://guides.rubyonrails.org/routing.html#route-globbing-and-wildcard-segments
I would suggest you namespace the route under some keyword to catch this wildcard route explicitly (hence url in the above).
You may need to tweak the route to allow periods to prevent them from becoming the format. I forget if that's true for these or not.

Is the format of URLs imported to IP4.1 from IP3.9 correct?

I have now successfully imported the text, pictures and pages from IP3.9 to IP4.1.
IP4.1 on localhost has truncated URLs.
For example URL in IP3.9
localhost/ip39/en/top/graphene/cvd-graphen/cvd-on-metals/multilayer-graphene-on-nickel-foil/
when imported to IP4.1 becomes
localhost/ip41/multilayer-graphene-on-nickel-foil
Is this normal ? If IP4 changes the format of the URLs then I think all the Google links will be lost.
Alan
Since v4.x we removed requirement to have language, zone or parent page in the path of pages. Which means that each page (despite its location in the menu tree) can have any URL starting from the root. You can put URL with slashes, too.
You have two options:
Manually change back all paths to the format you need (you can do that in the archive before import, too).
Create required redirects for search engines to understand what happened.

jquery ajax load (full URL)

hi is there a wait to load a full url.?
url= 'http://www.example.com/whatever.php'
$('#selector').load(url); // this way returns null (empty result)
instead of :
url = 'whatever.php'
$('#selector').load(url); // works fine
Some may think whats the difference i want to use this because im using multiple directories. so i could be on a page like...
example.com/dir/
but the dir folder will not have the whatever.php
so anyone has a fix for this that i should always use the full url?
thank you.
You could always use relative paths
putting / before the path will tell the browser to go the root of the page. For your example you could call /whatever.php.
You can also move up one directory at a time. Lets say you are in a page at http://www.example.com/dir/foo/bar.php and want to access something in the dir folder, you could specify ../inTheDir.php to move up one directory or ../../inTheRoot.php to move up two.
This should work for you, but based on your comment it sounds like you have a problem somewhere else since your www. page doesn't seem to respond correctly.
No, there isn't.
If http://www.example.com/ takes longer to load than http://example.com/ then it is probably because you have the DNS record for example.com cached but not the record for www.example.com.
Corrected after having realized a typo changed the meaning of the question.:
This is a case of having a mismatch between the host name the page is loaded from and the host name the Ajaxed resource is requested from. i.e. The Same Origin Policy.
Pick a host name to be canonical, use that one in your requests, and redirect (with a 301 status code) from the other so that people don't go to the wrong one by mistake.

How do I get pages like src/pages/myrootpage.erl to show up at http://mysite.org/myrootpage using nitrogen?

Nitrogen does not seem to like pages being at the root url path, only addon paths like /web/ is there some way to get pages to show up at the root url like /mypage ?
Currently you can not do it. You can change what this prefix is, it doesn't have to be '/web', but at the moment there has to be one root element with some name. This may change soon but because Nitrogen currently does not include support for static file sharing then this is the current reality.

How does magento parse url?

We used django and in django there is one file urls.py which mention all possible url patterns. So we just want to know that when i open url http://localhost/magento/index.php/test123.html how this will map to product and which file i can check for this.
Magento has more than one way of matching URLs. modules can register their own patterns, and these will generally be of the form /module/controller/action
In addition, CMS pages have URL identifiers and these can be anything you like - they can contain /s to give the illusion of hierarchy, but they're not significant.
Finally, Categories and Products have URL identifiers and there's a whole table of URL rewrites that map a path (/[category]/[subcategory]/[product] for example) to a product. In your example, I would guess that the product's URL identifier is 'test123' and that the store is setup to suffix URLs with '.html'
So, there's no file to look in (in this case), but rather the database/admin area.

Resources