Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

bs, there are a few very good serialization gems. ActiveRecord and Hibernate/JPA work a lot better than concatenating your own SQL strings.

If there's something that really doesn't benefit from your model (reports), then you'd fallback to either SQL, or still use ActiveModel + the aggregates



Please list the good serialisation gems, as I can't find any ;)

What if you have a complex/dynamic query, how do you build it? You said yourself that AR works better than concatenating SQL strings, but AR doesn't even support CTEs atm and building complex queries is not trivial and sometimes even possible without just SQL strings...


Big fan of raw sql, but practically speaking (as it relates to developing with rails) CTEs can be rewritten as subqueries, the advantage being that they are linear instead of nested in SQL.

With AR queries you can do the same and make it linear in ruby (and then the computer doesn't really care if your sql is nested)

    last_three_posts = Post.limit(3).order(created_at: :desc)
    @posts = Comment.where(post_id: last_three_posts)


It's not perfect or painless but I think jsonapi-serializer is pretty good




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: