Rails Observer

Observer classes respond to lifecycle callbacks to implement trigger-like behavior outside the original class. This is a great way to reduce the clutter that normally comes when the model class is burdened with functionality that doesn‘t pertain to the core responsibility of the class. In my project,I have to track certain action (create and update) of user on particular model basically i am maintaining some kind of log, or audit trails.In my application eventlog model has attribute user and body.

Continue Reading

How to include another html page into existing html page using jquery

We can include another html page using jquery load method example is as shown below <html xmlns="http://www.w3.org/1999/xhtml">    <head>       <title>Loading an Html page</title>      <script src="jquery.js" type="text/javascript"></script>     $(document).ready(function() {         $('#loadpage').load('load.html or any server side page');     }); </head> <body>    <div id="loadpage" ></div> </body> </html>

Continue Reading

Multiple database in rails

In normal rails application contain one database,but if we want rails application having more than one database that is multiple data base.   we can achieve this using multiple way.one of the way is i am showing here.it’s just 3 steps. Lets take an e.g Project has many milestone and milestone has many task In normal scenario model looks like following way class Project < ActiveRecord::Base has_many :milestones end   class Milestone < ActiveRecord::Base has_many :tasks belongs_to :project end  

Continue Reading

Construct a link to use GET variables to instruct the script to execute a certain function

Here it is how we can do that magic, if( isset($_GET[‘function’]) ) { switch( $_GET[‘function’] ) { case ‘dosomething’: dosomething(); break; case ‘dosomethingelse’: dosomethingelse(); break; } } And then link to script.php?function=dosomething url rewriting Benifit : When a search engine visits the dynamic url like product.php?id=test it does not give much importance to that URL as search engine sees “?” sign treat it as a url which keeps on changing. so we’re converting the dynamic URL like the product.php?id=test to

Continue Reading

Site Footer