incompatible character encodings: ASCII-8BIT and UTF-8

I solved it by following these steps: Make sure config.encoding = “utf-8” is in the application.rb file. Make sure you are using the ‘mysql2’ gem. Put # encoding: utf-8 at the top of file containing UTF-8 characters. Above the <App Name>::Application.initialize! line in the environment.rb file, add following two lines: Encoding.default_external = Encoding::UTF_8 Encoding.default_internal = … Read more

How do I make dynamic ids in Haml?

There are two ways: The long form way (define the id as if it were a regular attribute): .box{:id => “item_#{x}”} produces this (x is what ever x.to_s evaluates to): <div class=”box” id=”item_x”> The short form way: .box[x] produces the following assuming x is an instance of item: <div class=”box item” id=”item_45″> See the HAML … Read more

How to write if-condition in Haml?

HAML is indentation based , and the parser can be tricky.You don’t need to use “- end” in Haml. Use indentation instead.In Haml,a block begins whenever the indentation is increased after a Ruby evaluation command. It ends when the indentation decreases.Sample if else block as follows. – if condition = something – else = something_else … Read more

Haml: Control whitespace around text

A better way to do this has been introduced via Haml’s helpers: surround = surround ‘(‘, ‘)’ do %a{:href => “https://stackoverflow.com/questions/1311428/food”} chicken Produces: (<a href=”https://stackoverflow.com/questions/1311428/food”>chicken</a>) succeed: click = succeed ‘.’ do %a{:href=>”https://stackoverflow.com/questions/1311428/thing”} here Produces: click <a href=”https://stackoverflow.com/questions/1311428/thing”>here</a>. precede: = precede ‘*’ do %span.small Not really Produces: *<span class=”small”>Not really</span> To answer the original question: I … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)