Sign in through GitHub

Please read for an updated status on RailsCasts:

Learn more or hide this

Dominik Menke's Profile

GitHub User: dmke

Site: https://dmke.org

Comments by Dominik Menke

Avatar

Usually, I stick with LaTeX and PGF/TikZ to produce PDF graphs.

This has some disadvantages, though:

  • you have to know how to write a TeX document (takes ~2 years of experience with TeX).
  • you have to figure out how TikZ wants to work.
  • you have to combine Rails and LaTeX (which also requires a ~1GB installation of a recent TeX distribution)
  • I won't mention the higher memory and CPU requirements when compiling the PDF file... ;-)
  • using TeX for PDF and Morris/g.raphaël/whatever for HTML of course means maintaining two interfaces for your data (have fun extracting that into a gem ;-))

It's more of an advanced task (not the Ruby/Rails part, but the LaTeX one), but if you value the high quality of TeX'ed documents, it's definitely the way you should go.

Using v8 on the other hand sounds far to nice to be true :-)

Avatar
sh
TWITTER_CONSUMER_KEY=... TWITTWR_CONSUMER_SECRET=... rails server

or

sh
export TWITTER_CONSUMER_KEY=...
export TWITTWR_CONSUMER_SECRET=...
rails server
Avatar

You mentioned Rubinius/JRuby - how about an episode deploying to these platforms?

Avatar

Great episode!

A small side note: On Debian/Ubuntu/Mint Linux, you'll need libpq-dev (Postgres headers) to install the pg gem, not libpg.... That annoys me every time I setup a new server... ;-)

Avatar

I've built a more colorful formatter. This code might be not optimized yet, since I didn't investigate the type of severity (nor did I for Logger::Severity::DEBUG and friends).

Maybe you'll find it useful, too ;-)

log_formatter.rb
class Logger::SimpleFormatter
  # from activesupport/lib/active_support/core_ext/logger.rb
  def call(severity, time, progname, msg)
    "#{severity_color severity} #{String === msg ? msg : msg.inspect}\n"
  end

private

  def severity_color(severity)
    case severity
    when "DEBUG"
      "\033[0;34;40m[DEBUG]\033[0m" # blue
    when "INFO"
      "\033[1;37;40m[INFO]\033[0m" # bold white
    when "WARN"
      "\033[1;33;40m[WARNING]\033[0m" # bold yellow
    when "ERROR"
      "\033[1;31;40m[ERROR]\033[0m" # bold red
    when "FATAL"
      "\033[7;31;40m[FATAL]\033[0m" # bold black, red bg
    else
      "[#{severity}]" # none
    end
  end
end
Avatar

That qualifies for »abandoned«, in my opinion ;-)

I had have also trouble to install ruby-debug19 on some Debian machines with Ruby 1.9.2 using either RVM or rbenv. debugger works like a charm :-)

Avatar

Nice-to-know episode! Any idea, why ruby-debug19 was abandoned?

—Dominik

Avatar

Any idea, why localizing nested attributes is unbelievable painful? Consider this setup, where you need a lot of repetition to create correctly localized error messages.

Am I doing it wrong?

Avatar

With #334, I figured out, that I have used the »compass« and not the »compass-rails« gem...

So far, the @import 'icons/*.png' had always failed... Now I know better ;-)

Avatar

I'd really like to see a COMPASS introduction, too. In particular I'm having trouble to setup image sprites...

Avatar

That also crossed my mind, but in this case it basically adds complexity. Instead of a Rails.env.demo?, I would have a rollout? helper call and an overhead through the feature set management (the demo-abilities won't change over time)

I've also thought of a custom form builder to shrink down the view overhead—but then I still need a comfortable way to define the accessibility restrictions…

—Dominik

Avatar

Is there a convenient way to separate view and controller logic depending on the environment? I have, for example, a "demo" environment which limits some of the functionality of the app. In result, I have many snippets like

ruby
# in a view
<% if Rails.env.demo? %>
  <dt>Amount (fixed in demo)</dt>
  <dd>2</dd>
<% else %>
  <dt><%= f.label :amount %></dt>
  <dd><%= f.text_field :amount %></dd>
<% end %>

and a corresponding conditional in the controller (+ some modified models – but I don't think, there is a way around different behavior, is it?), which is some kind of messy, especially if only some fields are going to be unchangeable in the demo environment.

Maybe CanCan 2.0 could be a solution, since then the "demo abilities" are more or less centralized... But: would that be the right way?

—Dominik

Avatar

I often use FriendlyId in combination with a UUID column. This way, the guessing of further resources is much harder (cp. /foo/1 → /foo/2 with random, 32-digit identifiers). Of course you will still need a authorization mechanism...

Avatar

Thanks! config.assets.compile = true + config.assets.digest = true saved my day. Lost hours yesterday figuring out, why stylesheet_link_tag 'application' had refused to link /assets/application-md5hash.css...