Feeds:
Posts
Comments

Archive for the ‘Ruby on Rails’ Category

Greetings!

Today when i was working with helper methods for a ruby on rails project, i faced a problem of not rendering HTML tags in View

Instead it rendered as a String.

For example, the actual scenario is,

I had the following code in helper module

def show_list(num, page=nil)
..........
..........
content = []
for i in collection
content << "<li> #{i.name} </li>"
end
.........
.........
end

Inside view when i called this method

<%=  show_list(25) %>

I got the output as a string, “<li>actual data goes here</li>”, not interpreting the HTML tags

Then after surfing for nearly a couple of hours, i came to know that its a wrong way of calling the method in View

The right way  is to prefix the method using raw helper method

Correct way


<%= raw show_list(25) %>

Now the view displays the data as a list item 🙂

Read Full Post »

Hai, today when i created an empty database

rake db:create

for a rails project, i faced the following error

Error:

rake aborted!
undefined method `task’ for #<Pagescroll::Application:0xb74dcb0c>

(See full trace by running task with –trace)

To solve it,  i followed the  below steps which i found while surfing

The issue is because of the version of rake

Steps:

1. gem uninstall rake -v 0.9

2. gem install rake -v 0.8.7

3. Edit the Gemfile and add

i. gem ‘rake’, ‘0.8.7’

4. bundle update

Now when i gave

rake db:create

It works  🙂

Read Full Post »

Hai, iam using Fedora 14.

Today i cloned a repo from github.

When i executed the application i faced  the following mysql error

Mysql2::Error

Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’ (2)

Then after googling, i came to know that we need to change the path ( must give the correct path of mysql.sock )  of a socket attribute in config/database.yml

To know its path, i just gave the following command

[rajee@localhost ~]$ locate mysql.sock

/var/lib/mysql/mysql.sock

Now the socket attribute path is changed as socket: /var/lib/mysql/mysql.sock

This path must also be changed in test, production in config/database.yml

Hope this helps for someone 🙂



Read Full Post »

Hai today when i was working with a rails project, when i gave bundle install ( after editing the Gemfile ), i received the following error

Error :

/usr/lib/ruby/gems/1.8/gems/bundler-1.0.9/lib/bundler/ui.rb:56: uninitialized constant Gem::SilentUI (NameError)
from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.9/lib/bundler/cli.rb:16:in `initialize’
from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.9/lib/bundler/vendor/thor.rb:246:in `new’
from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.9/lib/bundler/vendor/thor.rb:246:in `dispatch’
from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.9/lib/bundler/vendor/thor/base.rb:389:in `start’
from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.9/bin/bundle:13
from /usr/bin/bundle:19:in `load’
from /usr/bin/bundle:19

Inorder to get away from this error, just update the bundler by running the following command

sudo gem install bundler

Now bundle install will work 🙂

 

Read Full Post »