Tag: ROR

Configure Ruby on Rails with no database

Although Rails is intended for creating database-backed web applications, this example is simple enough that it doesn’t require one. In this case, you need to edit the enviroment.rb configuration file to indicate that your application does not use a database. It is possible to disable loading ActiveRecord by making a simple modification to environment.rb: 1. …

Continue reading

Permanent link to this article: https://blog.openshell.in/2010/12/configure-ruby-on-rails-with-no-database/

Fixing libmysql.dll issue in Rails

While working on rails with mysql as database you may got error like this “This application has failed to start because libmysql.dll was not found. Re-installing the application may fix this problem” while executing the code ‘rake db:create’. If that so, then fallow the fallowing steps: 1. type the command in the console gem install …

Continue reading

Permanent link to this article: https://blog.openshell.in/2010/12/fixing-libmysql-dll-issue-in-rails/

Quoting HTML attribute values

The values of attributes can contain text, hexadecimal color codes or numbers. In case of JavaScript event handlers, the values consist of small JavaScript code. A sincere advice for good and clean HTML coding is to always put quotes around attribute values. It is a good habit, will save you many headaches and avoid errors …

Continue reading

Permanent link to this article: https://blog.openshell.in/2010/12/quoting-html-attribute-values/

HTML mailto attribute

The HTML mailto is a quick way to add the facility of receiving feedback from visitor on the web site. when the visitor clicked the HTML mailto, It lanuches their email program with new email window. Note: HTML mailto assumes that the visitor has configured an email client (Outlook Express, Netscape Messenger, Thunderbird or any …

Continue reading

Permanent link to this article: https://blog.openshell.in/2010/12/html-mailto-attribute/

Tips to inspect the code in Rails

Inspect It inspects the value. It formats the array with square brace, hash with curly braces with arrows between the key value pairs inspecting parameter. Type It identifying the type of the instance variable. Debug It give nice, easy to read inspection of the value and displayed in a formatted way. These are all some …

Continue reading

Permanent link to this article: https://blog.openshell.in/2010/11/tips-to-inspect-the-code-in-rails/

Ruby Symbols Description

Matter related to the old and new Ruby programmer, and Ruby’s symbols are confusing sometimes or always. Smoothly before this, can not get used is pretty. People learn about the Ruby language is often Rubionreiruzu learn from the project. The Rubionreiruzu symbol is everywhere. There really is everywhere. So, pay attention to the concept of …

Continue reading

Permanent link to this article: https://blog.openshell.in/2010/11/ruby-symbols-description/

Debugging Rails

You can always debug your application and get it back on the rails if ever it something goes wrong. You have to check the application log files. See to it that “tail –f” commands are running on the server.log and development.log. Rails will then show debugging and runtime information to these files and debugging information …

Continue reading

Permanent link to this article: https://blog.openshell.in/2010/11/debugging-rails/

Finders are great but be careful

Finders are very pleasant to use, enable you to write readable code and they don’t require in-depth SQL knowledge. But the nice high level abstraction come with a computational cost. Follow these rules of thumb: Retrieve only the information that you need. A lot of execution time can be wasted by running selects for data …

Continue reading

Permanent link to this article: https://blog.openshell.in/2010/11/finders-are-great-but-be-careful/

Optimize your Ruby code

This may seem obvious, but a Rails application is essentially ruby code that will have to be run. Make sure your code is efficient from a Ruby standpoint. Take a look at your code and ask yourself if some refactoring is in order, keeping in mind performance considerations and algorithmic efficiency. Profiling tools are, of …

Continue reading

Permanent link to this article: https://blog.openshell.in/2010/11/optimize-your-ruby-code/

Group operations in a transaction

ActiveRecord wraps the creation or update of a record in a single transaction. Multiple inserts will then generate many transactions (one for each insert). Grouping multiple inserts in one single transaction will speed things up. Insead of: my_collection.each do |q| Report.create({:phrase => q}) end Use: Report.transaction do my_collection.each do |q| Report.create({:phrase => q}) end end …

Continue reading

Permanent link to this article: https://blog.openshell.in/2010/11/group-operations-in-a-transaction/