Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
aunt jenkins
Jan 12, 2001

https://github.com/mislav/will_paginate will make all your paginated dreams come true.

Adbot
ADBOT LOVES YOU

aunt jenkins
Jan 12, 2001

So I wrote and published my first gem, based on a need for a personal project. Basically, it allows you to include custom model methods in to_json/to_xml using a simple DSL instead of having to deal with overriding the methods yourself. It's kind of small and silly, but I didn't like how ugly it was to override the methods myself, plus I've been looking for a reason to write a gem that might actually get some use for awhile.

Github link

Would love to get any feedback/code critiques to learn from. I already learned a ton writing it :)

aunt jenkins
Jan 12, 2001

Sounds like an enum! Rails 4.1.0, which is at beta3 status, includes ActiveRecord::Enum in core. 37signalsBasecamp claims to be running 4.1.0 in production so it can't be total poo poo.

Or if you don't feel like living ON THE EDGE there are a few gems that'll do basically the same thing. simple_enum is one I've used.

aunt jenkins
Jan 12, 2001

semicolonsrock posted:

Is there a good general approach to making heavily html/Css/JavaScript sites back ends in Ruby if you really don't need it to do much?

Methinks you're looking for Middleman.

aunt jenkins
Jan 12, 2001

kayakyakr posted:

It has the benefit of invalidating when they change their password.

Dunno the specifics of your situation, maybe that is actually a good idea, but assuming this is something reasonably generic, API tokens shouldn't be invalidated by a user password change - that'd be totally unexpected behavior, IMO.

If possible, just have the client provide a user ID as well as the token, then you can store the token hashed and just compare it, similar to normal auth.

aunt jenkins
Jan 12, 2001

xtal posted:

check out Crystal.

:captainpop:
This is awesome! Exactly what I've been thinking over the last few days should exist. And it does, and it's actually pretty complete and good. Already got my first PR in :toot:

aunt jenkins
Jan 12, 2001

Peristalsis posted:

It could be worse, our recently departed developer went to a company still on Rails 2 for their product.

We have a customer still proudly running REE and Rails 1 in production with no plans to change. :monocle:

aunt jenkins
Jan 12, 2001

Pollyanna posted:

Let's say something went wrong in production and you have to do some database surgery through ActiveRecord. What's the safest, most accepted way of hotfixing live, production data?

Home projects, Rails console.
At work, has to be a migration, with the usual code review and testing etc that accompanies any other production code change.

aunt jenkins
Jan 12, 2001

I would use Sinatra with Sequel (since I'm presuming you aren't familiar with ActiveRecord yet) for this. Rails is way too much framework for what you're trying to do and you will spend more time trying to find which of the 45 auto-generated files you need to modify then actually programming. This should be about 20-30 lines tops with Sinatra, split across a main app.rb file and a view :)

Even if your overall objective is 'I wanna learn Rails' you'll do better by learning some Ruby syntax first and working with these gems, both of which are well-renowned for their elegant simplicity, will help set you up well to not have to learn both Ruby and Rails at once, which is a tough thing to do.

aunt jenkins
Jan 12, 2001

Pollyanna posted:

I'm guessing it's like any other conference, but with more people sitting on the floor with their laptops?

And all the laptops are Macs.

See you there! PM me if you want a New Relic sticker. :)

aunt jenkins
Jan 12, 2001

Pollyanna posted:

I'll be at the New Relic party, so I might see you there :)

Indeed you will. We have like 100+ people wait listed for our lil get-together so it should be fun. Definitely say hi and get a sticker, I'm the tall door-shaped dude in NR swag :shobon:

aunt jenkins
Jan 12, 2001

Also I should've slept in instead of attending this meandering word soup of a keynote :argh:

aunt jenkins
Jan 12, 2001

code:
+----------------------+--------+--------+---------+---------+-----+-------+
| Name                 | Lines  |   LOC  | Classes | Methods | M/C | LOC/M |
+----------------------+--------+--------+---------+---------+-----+-------+
| Controllers          |  41295 |  32489 |     409 |    2871 |   7 |     9 |
| Helpers              |  14802 |  12154 |       3 |    1300 | 433 |     7 |
| Models               |  67383 |  45900 |     686 |    5668 |   8 |     6 |
| Libraries            |  51124 |  38149 |     727 |    4464 |   6 |     6 |
| Integration tests    |   4678 |   3738 |      55 |      18 |   0 |   205 |
| Functional tests     |  54669 |  45044 |     314 |     422 |   1 |   104 |
| Unit tests           | 133438 | 109532 |    1063 |    1237 |   1 |    86 |
+----------------------+--------+--------+---------+---------+-----+-------+
| Total                | 367389 | 287006 |    3257 |   15980 |   4 |    15 |
+----------------------+--------+--------+---------+---------+-----+-------+
  Code LOC: 128692     Test LOC: 158314     Code to Test Ratio: 1:1.2
:confuoot:

aunt jenkins
Jan 12, 2001

necrotic posted:

^^^ that's some good test numbers. Are they actually useful tests?

I feel like they are, I don't directly work on that monolith so I don't deal with it code-wise on a daily basis but in general we seem to have very good quality and testing practices overall, especially considering the contribution volume:



We have a number of what probably could be best explained as "service gems" (which I do work on) and there are some circa 2009 tests in the monolith that depend on private APIs in the gems, but as we push new releases and notice the breakage we're cleaning up. So pretty much the usual "legacy codebase" story. :)

aunt jenkins
Jan 12, 2001

necrotic posted:

At least we're finally moving off of Ruby 1.9.3... next big upgrade is Rails :smithicide:

3.0 to 3.2 took 3 developers 4 months. Good luck! :homebrew:

aunt jenkins
Jan 12, 2001

As you said, you'll want to check your specific app's performance. The other reason it's used is because it can easily interop with Java libraries and SDKs. If you're not doing that or using JRuby-only gems that you can't replace, it's definitely worth an experiment. MRI 2.6 is definitely quite a bit faster than 1.9.3 was. :)

aunt jenkins
Jan 12, 2001

My company is actually working on something in this space (including a devise integration) but it's not quite ready for primetime yet. I had this problem myself on another side project and ended up just putting in recaptcha and haven't had to deal with it since.

Adbot
ADBOT LOVES YOU

aunt jenkins
Jan 12, 2001

necrotic posted:

Email verification? If you don't want emails then captchas may be your best option.

The problem is that the bots will use real people's emails to signup (I have no idea why or how this benefits the bot author but w/e) and then those people rightly mark your confirmation you sent as spam and your email provider gets pissy. So email confo alone won't really solve the problem.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply