February 2011 Archives
I wanted to be able to open up gems easily from the command line. I tried `bundle open unicorn` and got the following error:
To open a bundled gem, set $EDITOR or $BUNDLER_EDITOR
To get rid of this error I used `export BUNDLER_EDITOR=mate`. This causes TextMate to open the gem of choice when I call `bundle open unicorn`
Continue Reading…
Posted by Liah on Feb 25, 2011
To turn escaped HTML into HAML, use
!= instead of just
=
To escape unescaped HTML, use
&= instead of just
=.
> Haml::Engine.new('!= " Hello World
"').render
=> " Hello World
\n"
> Haml::Engine.new('%p Hello World').render
=> "Hello World
\n"
> Haml::Engine.new('= " Hello World
"').render
=> " Hello World
\n"
Resources
Unescaping HTML
Escaping HTML
Continue Reading…
Posted by Liah on Feb 04, 2011
- redirect_to causes the browser to receive a 302.
- The browser makes a brand new request and you will need to supply the browser with the information it needs to make the request such as the object attributes.
- Any existing variables will be lost.
- redirect_to is the right choice when you are posting a completely filled out form with valid data.
- render causes the browser to return a 200.
- The browser does not make a new request and instead just renders the page you specify without sending any information to it.
- The code in the rendered action will not be executed, it simply returns the view
- render is the right choice when a form was incorrectly filled out and you want to display errors on the page you were just on as well as saving state of all the data that had already been entered into the form.
A link that helped me:
http://www.helloworlder.com/?p=6
Continue Reading…
Posted by Liah on Feb 02, 2011