Question

Currently developing a RoR mobile web application for displaying information about particular places.

Let's call these places 'installations'. Each installation has at least one 'venue', which is a specific instance of the installation. So for example an installation could be a city park, and one of its corresponding venues could be the park during a concert or event. If this example is confusing, disregard, it doesn't matter much.

The data for these installations and their corresponding venues is hosted on Amazon Web Service S3 as json objects. I use HTTParty to read in the AWS S3 json objects. I am currently reading them in like so:

In the application controller I have:

inlcude HTTParty
base_uri 's3.amazonaws.com/our_bucket'
before_filter :set_up_httparty

def set_up_httparty
  @installation = "INSTALLATION"
  @venue = "VENUE"
  @dir_url = "/#{@installation}/#{@venue}/"
end

In my corresponding controllers, where I get separate information I have:

response =
  ApplicationController.get("#{@dir_url}/ConstantUniqueName.json")

Currently I am hardcoding INSTALLATION and VENUE values to point to a specific set of folders. This works great, but I need to be able to take in these values from the url like so:

www.themobilewebapp.com/INSTALLATION/VENUE/index

Now I am sure it is most likely possibly to pass in these values with params like so:

www.themobilewebapp.com/index?installtion=INSTALLATION&venue=VENUE

But if possible I would like to set my URL's up the previous way. I need to have the URL's be friendly for users to put in themselves and have QRC codes point directly to a specific installation and corresponding venue.

If not possible to be able to do something like www.mobwebapp.com/INSTALL/VEN/index then is it possible to set up sub domains for each venue and then pull in that venue as a string?

Any help is appreciated!! Thanks!

Was it helpful?

Solution

If you put this in your config/routes.rb file then you will be able to use the URL pattern that you want:

match ':installation/:venue/index', :controller => :venue, :action => :index
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top