Recent submissions

Comment · 12 years ago
Comment · 13 years ago
We're talking microseconds here, not milliseconds
Comment · 13 years ago
Comment · 13 years ago
I believe this is solved with gocraft/web: https://github.com/gocraft/web

The middleware would be, per the example there:

  func (c *YourContext) UserRequired(rw web.ResponseWriter, r *web.Request, next web.NextMiddlewareFunc) {
      user := userFromSession(r)  // Pretend like this is defined. It reads a session cookie and returns a *User or nil.
      if user != nil {
          c.User = user
          next(rw, r)
      } else {
          rw.Header().Set("Location", "/")
          rw.WriteHeader(http.StatusMovedPermanently)
          // do NOT call next()
      }
  }
Compatibility with Handler/HandlerFunc is kept at the top level, but not at every step along the middleware chain.
Comment · 13 years ago
You're right about the attr_accessible statement not being entirely accurate. Rails 3 does indeed have the concept of contexts. And, we're still on Rails 2.3 :). It also seems like Rails 4 will being going Strong Attribute route.
Comment · 13 years ago
It seems like what you've done there is create two mutations (signup and delete_account) within a single namespace. You can certainly do that with the Mutations gem.

What I think you're getting at is: can you just replace controllers with mutations? That's an interesting concept that I've thought a bit about. In practice, we have found controllers to still be useful in collecting some information and doing 'wiring'. They're also nice because your SOA shouldn't really be concerned with the presentation of the response.

Finally, where do you put your mailings? You're right that controllers > models, but I'd also say that mutations > controllers > models.

Comment · 13 years ago
We're using this in Rails 2.3 without Strong Parameters. Mutations whitelist input just like strong parameters do. I don't really see why you would use both, although you certainly could.

The duplicate of validations between models and mutations is interesting. Currently at UV, we have some duplication -- however, in other cases we're relying entirely on the validations of the Mutation. I do think it's possible to rely entirely on validation from mutations -- I need to get some more real-world experience with this to know how well it will work out :)

Comment · 13 years ago
That's exactly the analogy I was going for. You don't want your general ruby code to be typed-checked, but it's actually fairly important to make sure your user inputs are checked, especially until Rails battens down its hatches.
Comment · 15 years ago
We use Mailgun at UserVoice.com for incoming mail.

Of particular help to us:

- All emails are converted to UTF-8

- There's always a 'plain' (text only) version of the email sent to us, even if the original email only included HTML.

- They offer a 'stripped-text' field, which lets us easily see the new part of an email thread.

- Pretty great support

Comment · 15 years ago
This type of programming is incredibly useful when writing efficient code in low level languages (eg, linear algebra in C). When writing Ruby web apps, though, I haven't found a need yet to think about cache lines or associativity.

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton