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
Cocoa Crispies
Jul 20, 2001

Vehicular Manslaughter!

Pillbug

Buckhead posted:

This is pretty cool. Is there a page that lists a summary of new features in Rails 4.1.0?

Also, does anyone have a recommendation for a logging plugin? I'm looking for something that will send a daily summary of any 500 errors with the relevant log output included.

Don't do that in Rails, configure your external log aggregator to do that.

Adbot
ADBOT LOVES YOU

Parker Lewis
Jan 4, 2006

Can't Lose


atastypie posted:

Using null in a boolean to mean anything more than an absence of a value is a bad practice.

Nothing wrong with a string that only allows three values, you can define the values as a constant in the model. This lets you throw the validations down on the constant, populate the form select/radio with the same values, base your tests on them, etc. You probably don't need to go all out and treat the attribute as a state, but you could always upgrade the string attribute to a state if your logic demands it.

Thanks, after some further digging it looks like that's the same approach my coworkers are using to handle situations like this (defining the set of possible values in a constant and using that for form helpers/validations). Seems like the way to go for now.

prom candy
Dec 16, 2005

Only I may dance
Deploying with Capistrano has been a real headache lately. I'm tired of all of my Rails 2.3.x deploys taking seconds while my Rails 3.1+ apps take ages because it has to run bundle install (even though my Gemfile hasn't changed) or run rake:assets:precompile (even though my assets haven't changed). Is there something better out there than Capistrano? Alternately, are there tried and tested recipes for skipping these long processes if they're not necessary? All I can find is some gists on blog posts from a few years ago that don't really work.

Chilled Milk
Jun 22, 2003

No one here is alone,
satellites in every home

prom candy posted:

Deploying with Capistrano has been a real headache lately. I'm tired of all of my Rails 2.3.x deploys taking seconds while my Rails 3.1+ apps take ages because it has to run bundle install (even though my Gemfile hasn't changed) or run rake:assets:precompile (even though my assets haven't changed). Is there something better out there than Capistrano? Alternately, are there tried and tested recipes for skipping these long processes if they're not necessary? All I can find is some gists on blog posts from a few years ago that don't really work.

The answer to the assets question is https://github.com/ndbroadbent/turbo-sprockets-rails3

kayakyakr
Feb 16, 2004

Kayak is true

prom candy posted:

Deploying with Capistrano has been a real headache lately. I'm tired of all of my Rails 2.3.x deploys taking seconds while my Rails 3.1+ apps take ages because it has to run bundle install (even though my Gemfile hasn't changed) or run rake:assets:precompile (even though my assets haven't changed). Is there something better out there than Capistrano? Alternately, are there tried and tested recipes for skipping these long processes if they're not necessary? All I can find is some gists on blog posts from a few years ago that don't really work.

I'm switching to dokku, but that won't speed you up too much. Deploys on dokku take ~1-2 mins but it doesn't cache the gems or assets.

Without changing deploy process, for your rails 3 apps, look into the turbosprockets gem. It fixes a few of the issues with assets precompiling. Also, your capistrano should be setting your bundler directory into the shared directory so it uses the same install each time. This is supposed to be done automatically with the bundler gem, but I dunno how you have capistrano set up.

But you really should consider migrating rails 2.3.x up as it's EOL. Rails 3 - Rails 4, in my experience, isn't a very hard upgrade either, and it will solve your issues with assets precompile.

prom candy
Dec 16, 2005

Only I may dance
I have about 100 rails 2 apps, we are probably going to get on the paid LTS version.

We use turbo sprockets and/or rails 4 for asset pipeline apps but the process of checking if assets need to be precompiled still takes considerably longer than just not running the task or (I'm guessing) checking via looking at the commit. Bundle install does put gems in the shared folder but running bundle install even when nothing actually needs to be installed still takes time. I think I'm just going to have to write some recipes that look at what was committed and selectively run those commands.

kayakyakr
Feb 16, 2004

Kayak is true

prom candy posted:

I have about 100 rails 2 apps, we are probably going to get on the paid LTS version.

We use turbo sprockets and/or rails 4 for asset pipeline apps but the process of checking if assets need to be precompiled still takes considerably longer than just not running the task or (I'm guessing) checking via looking at the commit. Bundle install does put gems in the shared folder but running bundle install even when nothing actually needs to be installed still takes time. I think I'm just going to have to write some recipes that look at what was committed and selectively run those commands.

yeah, looks like in your cases, you're pretty much doomed. Maybe look at modifying the capistrano 3 bundler gem to check for gemfile change?

Cap 3, btw, is nice once you get through the learning curve. Having switched to pure rake helped.

manero
Jan 30, 2006

prom candy posted:

Deploying with Capistrano has been a real headache lately. I'm tired of all of my Rails 2.3.x deploys taking seconds while my Rails 3.1+ apps take ages because it has to run bundle install (even though my Gemfile hasn't changed) or run rake:assets:precompile (even though my assets haven't changed). Is there something better out there than Capistrano? Alternately, are there tried and tested recipes for skipping these long processes if they're not necessary? All I can find is some gists on blog posts from a few years ago that don't really work.

I've used this technique to pretty good effect over the last couple years. It's been a huge timesaver:

http://www.bencurtis.com/2011/12/skipping-asset-compilation-with-capistrano/

prom candy
Dec 16, 2005

Only I may dance

manero posted:

I've used this technique to pretty good effect over the last couple years. It's been a huge timesaver:

http://www.bencurtis.com/2011/12/skipping-asset-compilation-with-capistrano/

That was one that I was looking at. Does it work with Rails 4 and Cap 3?

Edit: This does not work with Cap 3. I don't know what they've remapped the 'source' object to.

prom candy fucked around with this message at 18:27 on Feb 17, 2014

raej
Sep 25, 2003

"Being drunk is the worst feeling of all. Except for all those other feelings."
Is there an easy way to cast one column into another with a "friendly" name?

Example:

code:
ID      |Name                      |Friendly_name
--------------------------------------------------------------------
1       |Koutský 12° Světlý Ležák  |Koutsky 12 Svetly Lezak
2       |Koutský 10° Světlé Výčepní|Koutsky 10 Svetle Vycepni
3       |Únětické Pivo 12°         |Uneticke Pivo 12
4       |Matuška Zlatá Raketa 17°  |Matuska Zlata Raketa 17
The idea is to allow for typeable friendly URLs as well as be searchable to US keyboard input. Display will always use the correct Name column though.

Right now I have ID and Name, but need a way to interpret name to friendly name.

Pardot
Jul 25, 2001




The postgres unaccent extension does this. http://www.postgresql.org/docs/9.3/static/unaccent.html

You can also create an expression index on that, if you find yourself doing searches on it.

Tomahawk
Aug 13, 2003

HE KNOWS
What are some of the best resources out there right now to learn Rails? I was using TeamTreehouse and had a working app pretty quickly but I realized that I wasn't really learning.

Parker Lewis
Jan 4, 2006

Can't Lose


Tomahawk posted:

What are some of the best resources out there right now to learn Rails? I was using TeamTreehouse and had a working app pretty quickly but I realized that I wasn't really learning.

http://ruby.railstutorial.org/ is pretty solid.

Novo
May 13, 2003

Stercorem pro cerebro habes
Soiled Meat

kayakyakr posted:

yeah, looks like in your cases, you're pretty much doomed. Maybe look at modifying the capistrano 3 bundler gem to check for gemfile change?

Cap 3, btw, is nice once you get through the learning curve. Having switched to pure rake helped.

I've had pretty good success using "bundle check || bundle install" instead of just "bundle install"

prom candy
Dec 16, 2005

Only I may dance
An interesting side effect of cap 3 switching to normal rake tasks is that normal rake tasks are additive rather than overridden when you define them multiple times. So if you want to redefine something like deploy:assets:precompile you have to run clear_actions on it first. The other fun part about that is that when you clear a rake task like that it seems to clear any before or after tasks you attached to it.

I'll post some working recipes when I figure them out.

kayakyakr
Feb 16, 2004

Kayak is true

prom candy posted:

An interesting side effect of cap 3 switching to normal rake tasks is that normal rake tasks are additive rather than overridden when you define them multiple times. So if you want to redefine something like deploy:assets:precompile you have to run clear_actions on it first. The other fun part about that is that when you clear a rake task like that it seems to clear any before or after tasks you attached to it.

I'll post some working recipes when I figure them out.

yeesh, that seems like it could be problematic.

raej
Sep 25, 2003

"Being drunk is the worst feeling of all. Except for all those other feelings."
Does anyone use omniauth-facebook in conjunction with gravatar? I want to use a facebook photo if they connect through facebook, or if they do not, use their Gravatar, but I'm having difficulty finding a way to do this easily.

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder
I've been applying for ruby on rails jobs a lot lately, and the big thing that seems to be holding me back is that I don't have any experience dealing with applications "at scale." I'm running a "mission critical" rails app at my job, but it's mostly an internal app and it doesn't see a ton of traffic.

The "do you have experience scaling rails apps" question keeps coming up on interviews, and I don't have a good answer for it. Our app is deployed on aws and I have experience with that side of things, but I haven't dealt with load balancing and I coulnd't sync databases between CDNs.

How can I go about building some skill/knowledge in these areas without actually running a high traffic web application? Or should I not worry too much about this stuff if I'm just seeking a job as a junior developer?

Pollyanna
Mar 5, 2005

Milk's on them.


Okay, so two out of two interviews so far have touched on whether I was familiar with Rails. I am not, and I haven't done anything with Ruby past the tryruby tutorial months back, so I'm going to go ahead and just learn it already. Is the Rails tutorial a good place to start, or should I start with something more about Ruby in general?

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder

Pollyanna posted:

Okay, so two out of two interviews so far have touched on whether I was familiar with Rails. I am not, and I haven't done anything with Ruby past the tryruby tutorial months back, so I'm going to go ahead and just learn it already. Is the Rails tutorial a good place to start, or should I start with something more about Ruby in general?

Yeah it's the place to start. You don't need to start with Ruby. I'd start with Rails and then jump more deeply into Ruby later. But he even includes a more in depth look at ruby in section 3 or 4 or something. Alternatively you could just run through the codeacademy thing on ruby, that will get you up to speed in a few hours.

Also don't listen to those guys who told you not to bother with the testing stuff -- they might not care about it but almost everyone else will.

EAT THE EGGS RICOLA
May 29, 2008

Pollyanna posted:

Okay, so two out of two interviews so far have touched on whether I was familiar with Rails. I am not, and I haven't done anything with Ruby past the tryruby tutorial months back, so I'm going to go ahead and just learn it already. Is the Rails tutorial a good place to start, or should I start with something more about Ruby in general?

That's what I would recommend to anyone that wanted to get into rails.

Pardot
Jul 25, 2001




USSMICHELLEBACHMAN posted:

How can I go about building some skill/knowledge in these areas without actually running a high traffic web application? Or should I not worry too much about this stuff if I'm just seeking a job as a junior developer?

Don't worry about it too much. There are way too many aspects of that question to learn without actually also having a high traffic app. There also really isn't a set of generally applicable answers, practices, or solutions. The proper thing to do changes every time you grow an order of magnitude.

Just show that you'd be willing to learn.

kayakyakr
Feb 16, 2004

Kayak is true

USSMICHELLEBACHMAN posted:

Also don't listen to those guys who told you not to bother with the testing stuff -- they might not care about it but almost everyone else will.

This is actually good advice. develop a good testing habit so that you don't develop a bad no-testing habit like I did. It's hard to break.

USSMICHELLEBACHMAN posted:

How can I go about building some skill/knowledge in these areas without actually running a high traffic web application? Or should I not worry too much about this stuff if I'm just seeking a job as a junior developer?

You could caveat with not having had the fortune to have a high traffic web app yet, and then throw out a bunch of the usual suspects as things you would look into in order to scale upward:
- Code refactoring
- Smart Caching
- Vertical Scaling using a multi-threaded or multi-process servers on more powerful hardware
- Horizontal Scaling behind a load balancer
- Database scaling if that is the bottleneck

And on and on. Code refactoring is the most important part of that. You may be surprised at how much of an improvement you can get from identifying slow points and simply writing better, more efficient code.

But really, I don't know why they would be looking for experience with app scaling in a jr dev position unless they were trying to fix a problem they have without actually spending the money to hire someone who knows how to fix it by stealing away a jr dev who has seen it done. I wouldn't worry about it too much.

Pollyanna
Mar 5, 2005

Milk's on them.


So do I want the videos+book package or just one of the two?

Oh My Science
Dec 29, 2008

Pollyanna posted:

So do I want the videos+book package or just one of the two?

I believe the online version of the book is free. If you like the option of reading it on an ereader or watching videos go wild and buy them I guess.

Pollyanna
Mar 5, 2005

Milk's on them.


Cool. l'll stick with the book.

I'm confused on gems and gemsets and such. There's a section towards the beginning of the Rails tutorial that asks me to create a gemfile, but it's for RVM. I'm using rbenv and I installed bundler, how does that work in that case?

Oh My Science
Dec 29, 2008
rbenv doesn't have 'gemsets' and allows bundler to do its job.

http://robots.thoughtbot.com/using-rbenv-to-manage-rubies-and-gems

That is a decent writeup about using rbenv.

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder

kayakyakr posted:

This is actually good advice. develop a good testing habit so that you don't develop a bad no-testing habit like I did. It's hard to break.


You could caveat with not having had the fortune to have a high traffic web app yet, and then throw out a bunch of the usual suspects as things you would look into in order to scale upward:
- Code refactoring
- Smart Caching
- Vertical Scaling using a multi-threaded or multi-process servers on more powerful hardware
- Horizontal Scaling behind a load balancer
- Database scaling if that is the bottleneck

And on and on. Code refactoring is the most important part of that. You may be surprised at how much of an improvement you can get from identifying slow points and simply writing better, more efficient code.

But really, I don't know why they would be looking for experience with app scaling in a jr dev position unless they were trying to fix a problem they have without actually spending the money to hire someone who knows how to fix it by stealing away a jr dev who has seen it done. I wouldn't worry about it too much.

Thanks, I'll at least learn how to talk about this stuff. I guess I'm frustrated because I've gotten the 'I guess we were looking for someone a bit more senior' line a few times now and really the only Rails thing I'm definitely inexperienced with is operating at scale. (But it could just be that I've said dumb things during interviews. Or that I'm applying at places that don't know what they want).

I've asked a bit in the jobs thread, but I'll ask here: Aside from applying to everything on linked in, any leads for tracking down junior level rails positions? I've got about 2 years under my belt but like I said, it wasn't at any kind of scale. I feel like I should be a shoe-in for a jr position but I havent had a lot of luck yet.

double sulk
Jul 2, 2010

USSMICHELLEBACHMAN posted:

Thanks, I'll at least learn how to talk about this stuff. I guess I'm frustrated because I've gotten the 'I guess we were looking for someone a bit more senior' line a few times now and really the only Rails thing I'm definitely inexperienced with is operating at scale. (But it could just be that I've said dumb things during interviews. Or that I'm applying at places that don't know what they want).

I've asked a bit in the jobs thread, but I'll ask here: Aside from applying to everything on linked in, any leads for tracking down junior level rails positions? I've got about 2 years under my belt but like I said, it wasn't at any kind of scale. I feel like I should be a shoe-in for a jr position but I havent had a lot of luck yet.

Keep using SO Careers if you are already. Possibly WeWorkRemotely if you're interested in that, though they may generally be pickier. If you're looking to work in consultancies, the first quarter of the year is often rather slow from what I can gather. Companies will probably need to fill seats starting in April/May.

Pollyanna posted:

Cool. l'll stick with the book.

I'm confused on gems and gemsets and such. There's a section towards the beginning of the Rails tutorial that asks me to create a gemfile, but it's for RVM. I'm using rbenv and I installed bundler, how does that work in that case?

A good choice on Rbenv but the Gemfile is basically just for managing libraries. A `gem install bundler` followed by `bundle install` will install all of the gems you have listed in the Gemfile. If you need any help, you can PM me.

MrDoDo
Jun 27, 2004

You better remember quick before we haul your sweet ass down to the precinct.

USSMICHELLEBACHMAN posted:

Thanks, I'll at least learn how to talk about this stuff. I guess I'm frustrated because I've gotten the 'I guess we were looking for someone a bit more senior' line a few times now and really the only Rails thing I'm definitely inexperienced with is operating at scale. (But it could just be that I've said dumb things during interviews. Or that I'm applying at places that don't know what they want).

I've asked a bit in the jobs thread, but I'll ask here: Aside from applying to everything on linked in, any leads for tracking down junior level rails positions? I've got about 2 years under my belt but like I said, it wasn't at any kind of scale. I feel like I should be a shoe-in for a jr position but I havent had a lot of luck yet.

I was in a very similar situation as you until I got my current job a couple of months ago. I started to think it was a trend that Rails jobs are looking for "10+ years experience ninjas (really 10?!)". I ended up finding a place that isn't as "Standard Rails Shop" which was good because they were flexible with my experience and I got a more mid level position with 2 years experience, but also not so great because they aren't really as good about things like TDD or Agile which makes it hard for me to keep those skills up since its all on my own. Also I got my current job through a recruiter, so if you are desperate for a middle of road job to just get some skills up and make some money that might be an option. Figured I would share my experience, but keep after it there are definitely places out there.

MrDoDo fucked around with this message at 03:05 on Feb 22, 2014

kayakyakr
Feb 16, 2004

Kayak is true

USSMICHELLEBACHMAN posted:

Thanks, I'll at least learn how to talk about this stuff. I guess I'm frustrated because I've gotten the 'I guess we were looking for someone a bit more senior' line a few times now and really the only Rails thing I'm definitely inexperienced with is operating at scale. (But it could just be that I've said dumb things during interviews. Or that I'm applying at places that don't know what they want).

I've asked a bit in the jobs thread, but I'll ask here: Aside from applying to everything on linked in, any leads for tracking down junior level rails positions? I've got about 2 years under my belt but like I said, it wasn't at any kind of scale. I feel like I should be a shoe-in for a jr position but I havent had a lot of luck yet.

Where are you located? That makes a lot of difference.

You may try asking after a rejection where it was that they felt you weren't senior enough or what you did that turned them off. That might give you some sort of idea of what happened.

2 years is more than enough rails experience to fit into just about any job in the rails world. Keep up the confidence and keep at it.

e: I'd hire you to write tests for me, if one of my projects turns into a full company... Let this be a lesson kiddos: develop a good testing habit or else you never will.

Smol
Jun 1, 2011

Stat rosa pristina nomine, nomina nuda tenemus.
Testing is especially important in a dynamic language like Ruby. With statically typed languages you can trust the compiler to a certain extent that your fancy refactored code doesn't blow up, but with Ruby, the only way to be sure is to run it.

Smol fucked around with this message at 14:20 on Feb 22, 2014

Chilled Milk
Jun 22, 2003

No one here is alone,
satellites in every home
Coming from someone who had testing beat into his head early on but fell off the wagon for a stretch once I was working solo, let me tell you it's important to keep up with. Even when you're starting out writing fairly simple interactions, write the loving tests even to just get comfortable writing them and not get rusty. REPL only gets you so far. Your future self who starts getting into more complex applications where you NEED them will thank you.

Smol
Jun 1, 2011

Stat rosa pristina nomine, nomina nuda tenemus.
Indeed. Any nontrivial rails application that doesn't have a high test coverage across the board is nearly impossible to modify safely. Don't learn this the hard way, like many of us have.

kayakyakr
Feb 16, 2004

Kayak is true
Agree with all of the above. I think I'm going to start on a new side project today and try to test everything along the way. make new habits.

I've liked rspec, but have never been comfortable with testing controllers... to mock or not to mock, that is the question.

good jovi
Dec 11, 2000

'm pro-dickgirl, and I VOTE!

kayakyakr posted:

Agree with all of the above. I think I'm going to start on a new side project today and try to test everything along the way. make new habits.

I've liked rspec, but have never been comfortable with testing controllers... to mock or not to mock, that is the question.

Testing controllers has always been the least fun part for me. I usually just do enough to be satisfied it's not horribly broken. If you need much more than that, your controller is probably too fat anyways.

Cocoa Crispies
Jul 20, 2001

Vehicular Manslaughter!

Pillbug

USSMICHELLEBACHMAN posted:

Thanks, I'll at least learn how to talk about this stuff. I guess I'm frustrated because I've gotten the 'I guess we were looking for someone a bit more senior' line a few times now and really the only Rails thing I'm definitely inexperienced with is operating at scale. (But it could just be that I've said dumb things during interviews. Or that I'm applying at places that don't know what they want).

How to fake knowing how to scale:

  • Day zero: put your static files on s3/cloudfront/w/e and make sure you're using a multi-threaded or multi-process app server and not using thin like idiot brogrammers would do
  • Talk about profiling and benchmarking; New Relic is the standard, Twitter Zipkin can also be used, but it's something that requires an infrastructure and isn't really useful for a monorail
  • "monorail" means you have a rails app that does everything and talks to one or maybe two databases
  • Knowing how to comprehend EXPLAIN from your database is important. If they don't have a database with that, they're using Mongo or Redis or some other non-SQL database and have to do query planning by hand. Good luck with that, it sucks, ask me how I know.
  • Caching can be cool I guess.
  • If your deploys are really conservative (i.e. you can't just push new code to some production servers several times a day), you're going to have a hard time finding bottlenecks, and an even harder time testing possible solutions.

Normy
Jul 1, 2004

Do I Krushchev?


I'm experimenting with Hobo right now and basically just learning at this point. Am I right that I should be setting up all of my resources first and then going in and defining the relationships between them?

I'm working on a small social network with Users, Pages, Events, Posts etc.

Fillerbunny
Jul 25, 2002

so confused.
Hey guys. In Rails 4.0, is there a way to have multiple attributes of a single polymorphic type on a single model?

For example:

Ruby code:
#polymorphic model
class WikiEntry < ActiveRecord::Base
  belongs_to :wikiable, :polymorphic => true
end

class SomeObject < ActiveRecord::Base
  has_many :descriptions, class_name: "WikiEntry", as: :wikiable
  has_many :instructions, class_name: "WikiEntry", as: :wikiable
end

What I'm looking to do is have a wiki-like history of changes a user makes to properties like the Description, or other similar fields.

In the example above, making a call to SomeObject.first.descriptions.first would return the same record as SomeObject.first.instructions.first.

All I'm looking to capture in the WikiEntry object is the who, when, and what with user, updated_at, and content attributes, respectively. The above example is intentionally simplistic, but I think it illustrates what I'm trying to do. I know I'm missing a Type field somewhere, but I'm not sure where it should go. I tried creating a subclass of the WikiEntry class and associating that with SomeObject, but ultimately I ran into the same problem. I know I'm missing a layer and I can't pinpoint it.

Anybody have any advice?

Fillerbunny fucked around with this message at 19:24 on Feb 24, 2014

Adbot
ADBOT LOVES YOU

EAT THE EGGS RICOLA
May 29, 2008

Normy posted:

I'm experimenting with Hobo right now and basically just learning at this point. Am I right that I should be setting up all of my resources first and then going in and defining the relationships between them?

I'm working on a small social network with Users, Pages, Events, Posts etc.

Yes, you generate the resources, then you add your relationships (so your models\user.rb would get "has_many :posts" and "children :posts", models\post.rb would get "belongs_to :user"), then do a "hobo generate migration".

Hobo does a lot of weird magic and I like it for things that you have to get together super fast, but I've found it kind of frustrating to use for more detailed projects.

EAT THE EGGS RICOLA fucked around with this message at 16:45 on Feb 24, 2014

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