Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 24c2729e6e
Fetching contributors…

Cannot retrieve contributors at this time

46 lines (34 sloc) 2.449 kb
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title><![CDATA[Category: console | Entreprevelopment adventures]]></title>
<link href="http://luisalima.github.com/blog/categories/console/atom.xml" rel="self"/>
<link href="http://luisalima.github.com/"/>
<updated>2012-12-19T19:58:35+00:00</updated>
<id>http://luisalima.github.com/</id>
<author>
<name><![CDATA[Luisa Lima]]></name>
</author>
<generator uri="http://octopress.org/">Octopress</generator>
<entry>
<title type="html"><![CDATA[Adding automatic code reloading to rails console]]></title>
<link href="http://luisalima.github.com/blog/2012/12/13/adding-automatic-code-reloading-in-rails-console/"/>
<updated>2012-12-13T10:56:00+00:00</updated>
<id>http://luisalima.github.com/blog/2012/12/13/adding-automatic-code-reloading-in-rails-console</id>
<content type="html"><![CDATA[<p>So I have no idea why the rails console in development mode doesn't already do this, since the whole idea of the console in development mode is for us to mess around and test random stuff in development mode, right? Anyway, I got inspired and helped by <a href="http://jkfill.com/">Jkfill</a> with his post on <a href="http://jkfill.com/2012/12/08/automatic-code-reloading-in-rails-console">Automatic Code Reloading in Rails Console</a>, so here goes, more for my records than yours since you should follow the instructions in his post. I am using Rails 3.2.9, so I had to copy the code from the <a href="https://github.com/rails/rails/blob/master/railties/lib/rails/console/app.rb#L25">reload! method in the rails console code</a>, which is not exactly the best practice, but it's just for dev mode and it works :-)</p>
<pre><code> #this should be in config/initializers/irb_reloading.rb
if defined?(IRB::Context) && !defined?(Rails::Server) && Rails.env.development?
class IRB::Context
def evaluate_with_reloading(line, line_no)
ActionDispatch::Reloader.cleanup!
ActionDispatch::Reloader.prepare!
evaluate_without_reloading(line, line_no)
end
alias_method_chain :evaluate, :reloading
end
puts "=> IRB code reloading enabled"
end
</code></pre>
<p>In the meanwhile, shortly browsed the code at <a href="https://github.com/rails">the Rails gihub project</a> and it's really a nice way to learn more about rails... must do it more often.</p>
]]></content>
</entry>
</feed>
Jump to Line
Something went wrong with that request. Please try again.