Live data from Hacker News

Ruby on Rails in a week

simplethread.com

161–170 of 176 posts

Re: Ruby on Rails in a week

#161
post #73

> Blocks are one of the most confusing, yet most powerful elements of Ruby. They allow you to group expressions, save them to a variable, and even pass them to a method. I’m still getting used to blocks and realizing their usefulness, but overall I feel that they condense a lot of code, and also make code more reusable and extensible. Agreed re: confusion! I've been using Ruby (and Crystal) for years and I'm only sli…

> Blocks are just anonymous functions. That's it. Blocks in ruby have non-local return, unlike anonymous functions. compare `[1,2,3].map {|e| return true if e > 1 }` in ruby to `[1,2,3].map(e => {if(e > 1) { return true}})` in javascript. The ruby version will return a single `true` value, while the javascript version will return an array. This post walks through a example that resembles my experience writing bugs wh…

Interesting! I recall reading about this before but I’d forgotten it.

And I suppose one of the things that trips people up a lot about ruby is that the implicit return gives a different result — eg your example but without the “return true if” part DOES return an array, like JavaScript.

Re: Ruby on Rails in a week

#162
post #64

Earlier quoted context omitted.

Would you say Rspec is better than the Python equivalents like behave or pytest-BDD? Curious as I've never worked with Ruby/Rails but I'm aware there are some things that are way ahead of other toolchains (and others that are way behind as you've noted).

RSpec is definitely better, but I've mimicked it this way with pytest because I didn't like each Given/When decorator in pytest-bdd requiring a separate method to setup. It was way too verbose. I want to be able to quickly nest them, like in RSpec. So I do: TestSomeMethod: TestWhenDateProvided: def test_it_does_not_use_system_date(fixture, ...): assert ... TestWhenDateNotProvided: def test_it_uses_system_date(fixture…

Ah so you’d say the nested setup is one thing that differentiates Rspec.

I’d use inherited test classes for this case, either sharing the setup in the parent and having each child define their own tests, or defining the test cases in the parent and overriding the setup in the child classes.

Seems like the latter might be hard in Rspec? But the former sounds more concise in the Rspec notation, I agree. I think Ruby’s anonymous blocks seem to be the differentiator in the toolset, I’ve not seen a Python DSL that’s as good in that regard.

Re: Ruby on Rails in a week

#163
post #31

Asking someone to learn a brand new framework/language in a week as part of a job interview is pretty harsh.

I once learned Vue on the go as I reimplemented the company's admin dashboard from static rails-generated templates to a SPA. In a week. As a paid project assignment. It was wild, but super fun. They took too long to make an offer, though, and I ended up somewhere else.

I also completely forgot all about Vue in the mean time.

Re: Ruby on Rails in a week

#164
post #62
post #31

Asking someone to learn a brand new framework/language in a week as part of a job interview is pretty harsh.

Pivotal expects this as a matter of course. The interview involves full-time pairing for a day, and you (probably) won't know one of the programming languages. Pivotal does full-time pairing, and an experienced pairs should expected to pick up languages from new teams on-the-fly. After all, the rest of the team knows the language, and you'll get constant real-time mentorship as part of daily rotations. This is perhap…

As an introvert working alone and remote for 13 years, full-time pairing sounds like a nightmare.

Re: Ruby on Rails in a week

#165

I took a rails job by accident- I knew rails was in use but I was interviewed in Go and talked about new things going on in Go micro services. I didn’t expect 40 hours a week of rails / ember JS work and that’s my fault. I have 12 years with Django and I was shocked there wasn’t the equivalent of the Django tutorial. Everyone says the rails tutorial is good and I’m sure it’s worth the money but no one at work endorse…

I would recommend a chromium protocol based library for golang. Ginkgo is heavy and error prone.

Re: Ruby on Rails in a week

#166

I took a rails job by accident- I knew rails was in use but I was interviewed in Go and talked about new things going on in Go micro services. I didn’t expect 40 hours a week of rails / ember JS work and that’s my fault. I have 12 years with Django and I was shocked there wasn’t the equivalent of the Django tutorial. Everyone says the rails tutorial is good and I’m sure it’s worth the money but no one at work endorse…

I would recommend a chromium protocol based library for golang. Ginkgo is heavy and error prone.

I’m unfamiliar with this. Do you have a specific link with more info?

Re: Ruby on Rails in a week

#167
post #6
post #2

Having picked up Rails 9 years ago and having been using it literally daily ever since, it's joyful to read from someone that is just starting. I also started with https://www.railstutorial.org/book , highly recommend it. I also loved Metaprogramming Ruby (Paolo Perrotta) - it's more advanced and starts to open your mind to how Rails magic DSL's were built. I just bought today "Rebuilding Rails" ( https://rebuilding-…

Those are great resources. One I'd add to it, for general ruby programming, is the Well Grounded Rubyist ( https://www.manning.com/books/the-well-grounded-rubyist-thir... ) . It's been kept up to date (3rd edition was released in 2019) and I found it very readable and informative.

Highly recommended! I started with the Rails Tutorial as well and read The Well-Grounded Rubyist afterwards to get more in-depth with Ruby.

After that, I bought Bob Race‘s tutorial Build a Saas App with Rails which covers more practical aspects of building a multi-user SaaS app using well-known gems (instead of building everything by myself as in the Rails tutorial): https://leanpub.com/basair6

Re: Ruby on Rails in a week

#168
post #2

Having picked up Rails 9 years ago and having been using it literally daily ever since, it's joyful to read from someone that is just starting. I also started with https://www.railstutorial.org/book , highly recommend it. I also loved Metaprogramming Ruby (Paolo Perrotta) - it's more advanced and starts to open your mind to how Rails magic DSL's were built. I just bought today "Rebuilding Rails" ( https://rebuilding-…

I read all of those and would like to add two more: 1) Learn to Program , by Chris Pine. It's the best book I've read on learning to program in any language. 2) Practical Ruby Projects: Ideas for the Eclectic Programmer, by Topher Cyll. In a sense it wasn't "practical" at all. But it was a joyous eye-opener to all kinds of applications that turned me into a whirlwind of enthusiasm for months!

Aw, thanks! (3rd edition is in the works)

Re: Ruby on Rails in a week

#169

Years ago I put together a Rails app to store iPhone/iPad apps for curation. There was a backend that connected to the iTunes API and then I parsed the data elements I needed and entered them into the DB. The most infuriating thing was realizing that I needed to update the model with a new data element, or that some API responses didn't include the needed data. There was all this controller and model code and then th…

Try jsonb fields (postgres only maybe?) and the jsonb accessor gem: https://github.com/madeintandem/jsonb_accessor I use this for prototyping new apps a lot, where I'm not sure on the best design. Then I migrate to proper database columns when I'm sure of something. Feels like the best of both worlds to me.

Yeah I think I learned this the hard way: even making DB columns can be a premature optimization.

Re: Ruby on Rails in a week

#170
I won't add any value to this thread, just wanted to say thanks to the folks that piled on with additional learning resources. I've always _meant_ to pick up Ruby at some point, and it feels like there's a lot of great information out there to get started.
Post reply on HN