Jump to content

The ultimate community for Ruby on Rails developers.


Photo

rails save static page url in database with other data, then fetch result and wrap result with that url

ruby on rails

  • Please log in to reply
3 replies to this topic

#1 arjunm009

arjunm009

    Signalman

  • Members
  • 12 posts
  • Locationindia

Posted 01 November 2013 - 06:10 PM

hey

how to figure this out. i building a travel application in which i will save data about many places, which have attributes like its name, short description, price,etc. also i like to save a url pointing to its static page which will have more information about that place.

since i am want to show detailed information(historical,culture,transit info,etc) about the place, thats why chose to create a static page.

now, when a user does a search using certain parameters, i like to load the result wrapped with its static page url in the show page.

now, how can this be done. and more importantly, is this a good way?



#2 james

james

    Guard

  • Moderators
  • 221 posts
  • LocationLeeds, U.K.

Posted 12 November 2013 - 12:46 PM

This is a bit difficult to answer but I'll have a stab.

 A search is likely to be an sql search unless you are embedding google search api functionality so you won't pick up static page content.

You could write a search bot that will trawl your static pages dumping the static content into a database that could be run as a background rake task on deployment. That way you can use whatever search gems/functionality you wish. Nokogiri gem or Mechanize gem which is built on top of nokogiri would massively simplify this task.

This would give you Postgres, Thinking Sphinx, Elastic Search or any of the other major search functionality available for the whole site threfore not needing to worry about embedding static pages in a search based on a url.

 

There are railscasts on all the above mentioned gems that might also help.

 

Hope that gives you something to think about and a possible starting point but there is not much more can be said without further clarity really.


Programming is just about problem solving!


#3 arjunm009

arjunm009

    Signalman

  • Members
  • 12 posts
  • Locationindia

Posted 12 November 2013 - 05:41 PM

i forgot to mention, i have a simple search filtering using select box. but what you suggested does gives me knowledge, if, when i am in a situation as u assumed.

 

now what i figured out for my issue was to just create static page controller, add content in the views, then load its url in a column for each particular listings.

 

and when i do a search and display a show page, i just place that url column inside a link_to.

 

this is how i worked around this situation. i am not aware of any other pro way.



#4 james

james

    Guard

  • Moderators
  • 221 posts
  • LocationLeeds, U.K.

Posted 12 November 2013 - 10:51 PM

Well, this is one of those times where that adage "If it works, don't fix it" comes to mind. :)


Programming is just about problem solving!






Also tagged with one or more of these keywords: ruby on rails

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users