"The ruby-debug Commands"

The ruby-debug Commands

What follows is a quick rundown of the most important ruby-debug commands, along with a brief description of what they do. Don’t worry too much about remembering every last detail — the built-in help command will list all the available commands for you. You can also use the help <commandname> syntax to get help with a specific command.

  • backtrace: Display a trace of the execution stack, similar to what is displayed when your application raises an exception.
  • break/delete: Display a list of breakpoints that have been set in your application. This command is also used to set new breakpoints, or delete existing ones, from within the ruby-debug shell.
  • cont: Leave the current debugger shell and resume execution of the application until the next breakpoint is encountered.
  • irb: Invoke an interactive Ruby interpreter at the current point of execution, similar to the shell used by the breakpoint library.
  • list: Display the code fragments surrounding the current point of execution. (We’ll make use of this command in a moment.)
  • method/method instance: Explore the available class methods and instance methods, respectively.
  • next/step: Continue execution one step at a time — this is a huge improvement over the breakpoint library.
  • p/pp: Short for print and pretty print respectively, these commands can be used to evaluate Ruby expressions and display the value of variables to the console.
  • quit: Exit the debugger. Note that this will also exit the application server if it was invoked from the command line, as demonstrated above. To just exit the current debugging session, use cont.
  • reload: Reload the Ruby source files from disk. This can be useful if you’ve changed class definitions and want to reload them dynamically without leaving the current debugging session.

For a list of all available commands and options, use the help command.

"The ruby-debug Commands"

"Changing the class of a div using rails NOT JS"

Consider we need to change the class of a particular DIV/SPAN , I was wondering how we could have done using some default rails method and NOT Javascript as what we can do in Javascript the same we can do using Rails but in lesser time and number of lines of code.
Using google with the correct key words resulted in the following


function change(id, newclass) 


page[“task_#{params[:id]}”].toggle_class_name “completed”

rails, javascript, page.toggle_class_name, change class name of div in rails

"Changing the class of a div using rails NOT JS"

“9 Ways To Improve the SEO of Every Website You Design”

One of the biggest challenges that online businesses face today is maintaining relevance in the eyes of the search engines, especially Google. With Google controlling more than 90% of the search traffic in the US alone, it’s not surprising that the most important goal of any web-based marketing strategy is to be number one in Google.


It’s a well-established principle that on-site SEO is one of the most basic building blocks every business needs to have as they start on the road to search engine domination. So it makes sense to add another string to your own marketing bow as a web designer and incorporate some simple SEO strategies into every web design you deliver.

Here are nine ways to improve the SEO strength of every website you design.

1. Add a blog

Adding a blog to any site gives your clients the opportunity to add fresh content easily and regularly. Search engines love fresh content and if you encourage your client to update the blog on at least a weekly basis, or hopefully even more regularly, you will be giving them a distinct SEO advantage. You can explain to your client that blogs naturally attract search engine traffic and they can take advantage of this by not only adding content as often as possible, but to allow visitors to ask questions or leave comments.

The interactivity of the blog also adds value to the site and can also increase the likelihood of potential customers social bookmarking it and sharing it their social networks, but remember to look out for spam comments and to remove anything that looks like duplicate content.

Blogs also increase the size of the website over time and this can provide a major SEO benefit in the form of an increase in website authority and a higher number of pages to leverage with internal links.

2. Add Google Analytics to each page

As you are no doubt aware, Google Analytics is a free analytics software package that can provide your client with a range of critical data about their site and how it is performing in the search engines.

By using such features as Goal Tracking, Event Tracking, bounce rates and Intelligence you can show your client which keywords, search engines and traffic sources are producing sales or leads for their business. You can also use this data as a way of showing them how they can improve their site over time (with your help) through ongoing split testing.

Bonus tip: Sign up for Google Webmaster Tools, which also have a ton of information that you can use to learn more about your keywords and web pages.

3. Reduce code bloat

Google’s spiders are on the lookout for unique content, and JavaScript and CSS in the HTML code make it harder for them to find it. For example, you should already know that all scripts and CSS files should be added as external files to reduce the time it takes for search engine spiders to find the actual content as well as reducing the code-to-content ratio.

Remember that excessive code not only slows the page’s loading time, but it also increases the possibility of coding errors that, whilst they may have no direct impact on the site’s SEO, may still cause difficulty for the search engine spiders.

4. Make each page unique

Google ranks the relevance of each website according to the content it contains, and is always seeking relevant content not contained anywhere else on the Internet. This means that the content of every page needs to be completely different not just from any other site on the Web, but also any other page on the same site. This raises the issue of duplicate content, the dread of all site owners.

Put simply, if you publish any content that appears somewhere else on the Internet, you run the risk of being ignored by search engines because the algorithm will be looking for content that sets your site apart.

Unique content removes any such impediments from your site and your design standards will support your clients’ SEO. It is also worthwhile pointing out that wherever you include snippets of information contained on other pages within the site to tempt the visitor to follow the link, you run the risk of being penalised for duplicate content. So be careful of the wording used in the snippets so that it provides a summary without repeating any of the words actually used.

5. Use meta description tags

<meta> description tags are what appear in the search engine results pages – they give the web surfer an overview of what the site is about. Put your marketer’s hat on and write a description that convinces visitors to click on the result. This is your site’s first opportunity to attract visitors, so it’s vital that you give your client the best chance of standing out from the other results.

Remember, Google also uses meta description tags to differentiate web pages (although not as much as title tags) so you also need to be careful to describe each page differently to avoid any duplicate content issues. Including free offers, guarantees and a phone number can improve the click through rate on your clients’ SEO ranking.

Make sure to limit the <meta> description tags to 160 characters in length, including spaces.

6. Remove repetitive wording from the website layout

It’s worth repeating again that unique content is vital to the success of any site’s SEO. When designing a website layout for a client it is tempting to include information such as copyright text, contact details and maybe even company mottos on every page of the site. If there is not enough unique content on every page then you run the risk of your client’s site being penalised for duplicate content. That’s why it’s important to remove such repetitive wording from the website layout so that the true informational content of the site is not diluted in any way.

7. Add footer links to every page

Linking between web pages using plain text links, with the target SEO keywords in the anchor text, can provide a significant boost to your clients’ SEO rankings. The problem is that most good website designs use graphical, JavaScript or Flash navigation that don’t use anchor text. If this is the case, you can use footer links to link between your pages, with the keywords you want to rank for within the anchor text of the links.

8. Create a separate web page for each keyword or keyword phrase

The best way for a website to rank for a particular keyword phrase is to create a web page targeted to that phrase with the keywords in the <title> tag, <meta> description tags, <h1>, body copy and URL. This means that it is critically important to create a separate web page for each product or service that the client sells, as well as category pages if they are needed. A dedicated page for each product or service will also ensure a good user experience as they will land directly on this page from the search engine results, making it much easier for them to buy online or submit a form for more information.

9. Use keyword rich title tags on each page

<title> tags appear in the title bar of the browser and are one of the factors used by search engines to determine the content of your page. Rather than including the company name in the<title>tag, use the keywords that your client wants to rank for. This will give your client a solid advantage for ranking in the search engines. Make sure to limit the <title> tags to 60 characters in length, including spaces, so that the full text of the title tags appears in the search engine rankings and doesn’t get cut-off by Google.

By integrating all of the above suggestions into each of your website design projects, you will give your clients the best possible chance of generating sales and profits from search engine rankings.

“9 Ways To Improve the SEO of Every Website You Design”

"“Inheritance” and “Mixin Modules”"

Some object-oriented languages (notably C++) support multiple inheritance, where a class can have more than one immediate parent, inheriting functionality from each. Although powerful, this technique can be dangerous, as the inheritance hierarchy can become ambiguous.

Other languages, such as Java, support single inheritance. Here, a class can have only one immediate parent. Although cleaner (and easier to implement), single inheritance also has drawbacks—in the real world things often inherit attributes from multiple sources (a ball is both a bouncing thing and aspherical thing, for example). Ruby offers an interesting and powerful compromise, giving you the simplicity of single inheritance and the power of multiple inheritance. A Ruby class can have only one direct parent, and so Ruby is a single-inheritance language. However, Ruby classes can include the functionality of any number of mixins (a mixin is like a partial class definition). This provides a controlled multiple-inheritance-like capability with none of the drawbacks.

When a class includes a module, that module’s instance methods become available as instance methods of the class. It’s almost as if the module becomes a superclass of the class that uses it. Not surprisingly, that’s about how it works. When you include a module, Ruby creates an anonymous proxy class that references that module, and inserts that proxy as the direct superclass of the class that did the including. The proxy class contains references to the instance variables and methods of the module. This is important: the same module may be included in many different classes, and will appear in many different inheritance chains. However, thanks to the proxy class, there is still only one underlying module: change a method definition in that module, and it will change in all classes that include that module, both past and future.

<table class=codebox border=0 cellspacing=0 cellpadding=3 width=500><tbody><tr><td colspan=3 valign=top>module SillyModule</td>
</tr><tr><td colspan=3 valign=top>  def hello</td>
</tr><tr><td colspan=3 valign=top>    "Hello."</td>
</tr><tr><td colspan=3 valign=top>  end</td>
</tr><tr><td colspan=3 valign=top>end</td>
</tr><tr><td colspan=3 valign=top>class SillyClass</td>
</tr><tr><td colspan=3 valign=top>  include SillyModule</td>
</tr><tr><td colspan=3 valign=top>end</td>
</tr><tr><td colspan=3 valign=top>s = SillyClass.new</td>
</tr><tr><td valign=top>s.hello</td>
<td valign=top>»</td>
<td valign=top>"Hello."</td>
</tr></tbody></table><table class=codebox border=0 cellspacing=0 cellpadding=3 width=500><tbody><tr><td colspan=3 valign=top>module SillyModule</td>
</tr><tr><td colspan=3 valign=top>  def hello</td>
</tr><tr><td colspan=3 valign=top>    "Hi, there!"</td>
</tr><tr><td colspan=3 valign=top>  end</td>
</tr><tr><td colspan=3 valign=top>end</td>
</tr><tr><td valign=top>s.hello</td>
<td valign=top>»</td>
<td valign=top>"Hi, there!"</td>

. If multiple modules are included, they are added to the chain in order.

If a module itself includes other modules, a chain of proxy classes will be added to any class that includes that module, one proxy for each module that is directly or indirectly included.

"“Inheritance” and “Mixin Modules”"