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
Smol
Jun 1, 2011

Stat rosa pristina nomine, nomina nuda tenemus.
I'm using https://github.com/rails-api/active_model_serializers

Works well, but then again, I don't need any fancy features for this project. YMMV.

Adbot
ADBOT LOVES YOU

The Journey Fraternity
Nov 25, 2003



I found this on the ground!

Smol posted:

I'm using https://github.com/rails-api/active_model_serializers

Works well, but then again, I don't need any fancy features for this project. YMMV.

This is what I've preferred for simple ones as well, but I've found it falls over when you want more than one way of looking at the same model. I also didn't throw more than a few hours at trying to get it to work though, so :shrug:

Pollyanna
Mar 5, 2005

Milk's on them.


I'm having trouble installing recent versions of Ruby onto my OSX computer. I tried using the RVM, but it somehow managed to mess up whatever version I was using at the time. What's the most newbie-friendly recommended way to install Ruby, Rails, and whatever?

kayakyakr
Feb 16, 2004

Kayak is true

Pollyanna posted:

I'm having trouble installing recent versions of Ruby onto my OSX computer. I tried using the RVM, but it somehow managed to mess up whatever version I was using at the time. What's the most newbie-friendly recommended way to install Ruby, Rails, and whatever?

RVM is supposed to be the easiest. You install RVM, install a ruby, then run
code:
gem install bundler
gem install rails
If that doesn't work, well, I've never used it, but they advertise as the easiest way to install rails:
http://railsinstaller.org/en#osx

Pollyanna
Mar 5, 2005

Milk's on them.


kayakyakr posted:

RVM is supposed to be the easiest. You install RVM, install a ruby, then run
code:
gem install bundler
gem install rails
If that doesn't work, well, I've never used it, but they advertise as the easiest way to install rails:
http://railsinstaller.org/en#osx

Cool, I got it to work this time :3:

So...is there an IDE I should use? I'm used to whatever weirdo terminal Codecademy has, but I don't know if there's anything like this for OSX. Or does that not make sense?

EAT THE EGGS RICOLA
May 29, 2008

:can:

Commence argument about Sublime Text.

Nybble
Jun 28, 2008

praise chuck, raise heck
JetBrain's RubyMine is worth the money if you need a full featured IDE.

Smol
Jun 1, 2011

Stat rosa pristina nomine, nomina nuda tenemus.
Rubymine rocks.

kayakyakr
Feb 16, 2004

Kayak is true
I hated rubymine. Way more than you could ever need and java-based so it's performance was horrible.

A MIRACLE
Sep 17, 2007

All right. It's Saturday night; I have no date, a two-liter bottle of Shasta and my all-Rush mix-tape... Let's rock.

mVim or gVim is the only way... Or emacs if you're weird like that.

Seriously vim+terminal will do everything you need for rails development.

dexter
Jun 24, 2003

Pollyanna posted:

I'm having trouble installing recent versions of Ruby onto my OSX computer. I tried using the RVM, but it somehow managed to mess up whatever version I was using at the time. What's the most newbie-friendly recommended way to install Ruby, Rails, and whatever?

Install homebrew, then
code:
brew install rbenv
brew install ruby-build
rbenv install 2.0.0-p195
gem install bundler
gem install rails

Kallikrates
Jul 7, 2002
Pro Lurker

dexter posted:

Install homebrew, then
code:
brew install rbenv
brew install ruby-build
rbenv install 2.0.0-p195
gem install bundler
gem install rails

unless you run the auto rehash plugin theres going to be a couple
code:
rbenv rehash
s in there also

The Journey Fraternity
Nov 25, 2003



I found this on the ground!

Kallikrates posted:

unless you run the auto rehash plugin theres going to be a couple
code:
rbenv rehash
s in there also

Really should be built-in functionality, but what can you do?

(happy rbenv user here, screw rvm)

Pollyanna
Mar 5, 2005

Milk's on them.


:stonk:

Okay, well, I went with Sublime. I understand that CMD-B does Build, but how do I get it so that I can input stuff, like for gets?

edit: Also, what does Ruby do besides Rails? I'm not necessarily interested in web development or maintaining servers, so any other things it can do (i.e. miniature OSX applications, small games, GUIs) I'd like to hear about.

Pollyanna fucked around with this message at 20:22 on Aug 21, 2013

Sil
Jan 4, 2007
tldr+warning: rails noob(?) not sure what I know, what to do next.

I'm trying to figure out where my Rails skills are, in terms of looking for a job and areas of further self-study.

I remember reading two interesting takes on what an entry level rails dev should know. The SO answer places me pretty comfortably at the entry level which makes me uncomfortable since I don't really feel job ready at all(partly because I have no idea what an entry level dev would do).

Aside from some guided tutorial applications so far I've done one serious full app. It's a glorified blog with an ActiveAdmin backend, that can also send out a newsletter/manage subscriptions, does RSS and posts to its own FB page, can handle attachment files/images through paperclip and dropbox. Zurb Foundation front-end, no custom JS. Deployed to Heroku, running on PG. Also completely untested. The hardest part of the whole thing was probably figuring out the AA DSL and setting up the whole email system.

Basically, it feels like I've bumped into most everything that web tutorials touch on and a bit more. As a designer I feel I have no idea what to do beyond looking at templates and copying them(though I feel comfortable with SCSS/html(as long as I know what look I want to produce), and copy-paste-tweak capable with js). In terms of the heavy programming(what would count as heavy?) I feel sort of comfortable identifying a problem and then googling around for a solution, but I struggle to identify the next step in the first place(yes, that's what TDD is for, I didn't use it for my first real app since I wanted to use ActiveAdmin). I feel like I can do any basic task as long as I can google for it, but I'm terrified of going into an interview since I use SO/railscasts/etc non-stop while I work. Looking at interview prep blog posts they talk about patterns and algorithm implementation which is stuff that I've never used for rails programming, so far(I think).

Finally, the question, what do I do? Applying for a job is a bit of a non-starter since I'm Romanian and there's like one Rails company in the country. I think I can start looking for contract work just because from what PHP friends tell me most of their work is, pretty much, building glorified blogs/simple CMSs for small companies. I built a super basic e-commerce site with Spree months back and that seemed easy as well. Should I look for some open-source rails projects and contribute/study them(recommendations?)


e. Sublime guy: why would you build anything? Save your files and reload whatever webpage you are working on. You started the server from the commandline, right? Sublime is just for editing your files, it doesn't run a server or show you browser output(ie. the actual web pages).

e2. Here's a way overdetailed workflow intro with Sublime Text 2.

Sil fucked around with this message at 20:24 on Aug 21, 2013

Pollyanna
Mar 5, 2005

Milk's on them.


Sil posted:

e. Sublime guy: why would you build anything? Save your files and reload whatever webpage you are working on. You started the server from the commandline, right? Sublime is just for editing your files, it doesn't run a server or show you browser output(ie. the actual web pages).

Err well, I just edited my post up there to clarify, but I'm not really working on web applications right now. I'm starting with simple scripts and hopefully coming to the point where I can click on a binary and it'll run for me.

Sil
Jan 4, 2007
Ruby can do scripts, I think you just want to navigate into the file folder with the Terminal and then run "ruby filename.rb" which will execute the ruby file. Ruby doesn't build, I don't think, since it doesn't have a compiler. Just save your *.rb file and run it.

e. "puts" prints to terminal, btw so you can have your first ruby program just be a file named "hello.rb" with the content "puts "hello"". Go in that folder with terminal and run it with "ruby hello.rb"

e2. ruby is interpreted, not compiled, so I don't think you ever get to it producing a binary for you. Just run it from the command line.

e3. Rails accounts for most of what Ruby is used for. I think Ruby is also used to for testing(from what I remember in old jobs posts I browsed) other programs, but it's very much a nice thing.

Sil fucked around with this message at 20:30 on Aug 21, 2013

Pollyanna
Mar 5, 2005

Milk's on them.


Sil posted:

Ruby can do scripts, I think you just want to navigate into the file folder with the Terminal and then run "ruby filename.rb" which will execute the ruby file. Ruby doesn't build, I don't think, since it doesn't have a compiler. Just save your *.rb file and run it.

e. "puts" prints to terminal, btw so you can have your first ruby program just be a file named "hello.rb" with the content "puts "hello"". Go in that folder with terminal and run it with "ruby hello.rb"

e2. ruby is interpreted, not compiled, so I don't think you ever get to it producing a binary for you. Just run it from the command line.

Right, I forgot. :downs: So how do people make games and applications in Ruby, then? Is everything just run from the terminal?

Sil
Jan 4, 2007
I'm not sure. I would assume you can just have an executable file that's essentially a wrapper that issues command-line type commands when you click it sort of like how I think bash script files work.

e. see this for packaging ruby scripts into an app on OS X

Sil fucked around with this message at 20:37 on Aug 21, 2013

Smol
Jun 1, 2011

Stat rosa pristina nomine, nomina nuda tenemus.

kayakyakr posted:

I hated rubymine. Way more than you could ever need and java-based so it's performance was horrible.

I hope that you're not seriously as a Ruby developer complaining about Java performance.

Lexicon
Jul 29, 2003

I had a beer with Stephen Harper once and now I like him.

The Journey Fraternity posted:

Really should be built-in functionality, but what can you do?

(happy rbenv user here, screw rvm)

I'll go further and recommend GitHub's Boxen. You get rbenv for free, along with boatloads of other stuff.

Safe and Secure!
Jun 14, 2008

OFFICIAL SA THREAD RUINER
SPRING 2013

Sil posted:

I remember reading two interesting takes on what an entry level rails dev should know.

Huh, what? I threw together a Rails app in my spare time, maybe 4 hours a day on average of just under a month, and I can do all the entry-level stuff on the SO link and have done most (and understand the rest) of the mid-level stuff.

Does anyone here actually agree with that? Surely things have changed in the three-ish years since it was posted?

E: According to this link, I'm a rookie: http://smsohan.blogspot.ca/2010/02/ruby-on-rails-interview-questions_23.html

Because I could only get like two of the questions.

Safe and Secure! fucked around with this message at 23:40 on Aug 21, 2013

kayakyakr
Feb 16, 2004

Kayak is true

Smol posted:

I hope that you're not seriously as a Ruby developer complaining about Java performance.

Java GUI performance on Linux machines using any sane upper memory limit is pretty terrible. Maybe on mac, rubymine runs better? I dunno, to me it was pretty crap.

Sil posted:

tldr+warning: rails noob(?) not sure what I know, what to do next.

Reading through that, you're absolutely entry level rails. You have more experience with Rails than the last guy I hired. If you understand programming and understand how to get things done, you'll be ok.

Pollyanna posted:

Right, I forgot. :downs: So how do people make games and applications in Ruby, then? Is everything just run from the terminal?

Mostly run from terminal or started as a server. It is possible to write desktop apps in ruby, though. Ruby Toolbox is a great place to look up what sort of things people have come up with.
https://www.ruby-toolbox.com/categories/game_libraries
https://www.ruby-toolbox.com/categories/packaging_to_executables
https://www.ruby-toolbox.com/categories/GUI_Frameworks

Obsurveyor
Jan 10, 2003

A MIRACLE posted:

Seriously vim+terminal will do everything you need for rails development.

vim+tmux is pretty drat killer. Especially if you remote connect to your development machine, never lose a thing from disconnect/reboots/crashes again.

Also, to go back to the cucumber thing a bit ago: Don't, don't, don't use it if you work by yourself or stakeholders(:haw:) aren't going to look at them. It's a complete waste of time and a maintenance nightmare. Just use rspec+capybara.

Smol
Jun 1, 2011

Stat rosa pristina nomine, nomina nuda tenemus.

kayakyakr posted:

Java GUI performance on Linux machines using any sane upper memory limit is pretty terrible. Maybe on mac, rubymine runs better? I dunno, to me it was pretty crap.

Works fine for me on both Mac and Linux. Both machines have an SSD and at least 16 gigs of ram though - maybe that's the key difference.

Smol fucked around with this message at 14:13 on Aug 22, 2013

double sulk
Jul 2, 2010

A little late to the whole RSpec thing but the problem I've always had with it is that the semantics seem to change with every other version and the team working on it can't stick to anything. I haven't really used Cucumber all that much and it seems like it could become a bit bloated, although it seems more straightforward than RSpec in a lot of ways because you only end up with the natural language in the feature file opposed to a bunch of ugly code blocks everywhere.

What is the deal with Shoulda? Just glancing at the Github readme it kind of seems like a cut down RSpec (with regards to being based around shoulds)?

I have a few projects I'm working on where at least a couple of them might need some test rewrites, so I could probably do some experimenting this weekend.

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder
Tru cucumber. I'm on day 3 of migrating all my integration tests from rspec to cucumber and it's awesome.

It sounds awful in theory but it's awesome in practice. Keeping bloat down feels really natural compared to rspec.

DONT THREAD ON ME fucked around with this message at 18:16 on Aug 22, 2013

no_funeral
Jul 4, 2004

why
Quick question about assigning class variables: Can I do something like foo.bar.baz = foo? Specifically, for doing binary tree peer linking, can I say node.left.nextright = othernode? I'm getting a nomethoderror, so what I guess is happening is it thinks that nextright is a non-existent method in the class, but nextright is one of the node class variables.

Smol
Jun 1, 2011

Stat rosa pristina nomine, nomina nuda tenemus.
Try adding attr_accessor :nextright to the class. Instance variables are private in ruby, the only way you can modify them from outside is via methods.

prom candy
Dec 16, 2005

Only I may dance

chumpchous posted:

Tru cucumber. I'm on day 3 of migrating all my integration tests from rspec to cucumber and it's awesome.

It sounds awful in theory but it's awesome in practice. Keeping bloat down feels really natural compared to rspec.

Would you be willing to share a before/after of one of your tests? I'm thinking of adding Cucumber into a site that I've been managing for a few years. Our business-end client is exactly the kind of guy who can read and understand natural language features so I'm thinking it could be a good fit, but every time I sit down to write cucumber tests I feel like I'm wasting my time programming to a crazy DSL rather than just telling it what I want to test.

Cocoa Crispies
Jul 20, 2001

Vehicular Manslaughter!

Pillbug

gucci void main posted:

What is the deal with Shoulda? Just glancing at the Github readme it kind of seems like a cut down RSpec (with regards to being based around shoulds)?

For me, shoulda's a way to get nested contexts with MiniTest::Unit assertions, and a handful of Rails-specific test helpers.

Ruby code:
class TeamTest < ActiveSupport::TestCase
  should have_many :instances
  should have_many :redemptions
  should have_many :flags
  should have_many(:captures).through(:redemptions)
  should 'find a team by ssl key guid' do
    …
  end
end
I usually use shoulda, factory_girl, and mocha.

Novo
May 13, 2003

Stercorem pro cerebro habes
Soiled Meat

The Journey Fraternity posted:

Really should be built-in functionality, but what can you do?

(happy rbenv user here, screw rvm)

gem install rbenv-rehash

Smol posted:

I hope that you're not seriously as a Ruby developer complaining about Java performance.

I wouldn't use an IDE written in Ruby either if it was as slow as RubyMine is. What a lemon.

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder

prom candy posted:

Would you be willing to share a before/after of one of your tests? I'm thinking of adding Cucumber into a site that I've been managing for a few years. Our business-end client is exactly the kind of guy who can read and understand natural language features so I'm thinking it could be a good fit, but every time I sit down to write cucumber tests I feel like I'm wasting my time programming to a crazy DSL rather than just telling it what I want to test.

Yeah let me find some less embarrassing code. I'm pretty new to testing so my before/afters might not be a great example, but maybe you guys can give me some pointers.

Question: I had a bug in my application that was causing the DB to lock up when a form got double posted. I switched to postgres and fixed some issues, but I've never actually managed to replicate the bug. The post is submitted via JSON, and I've tried just sending multiple JSON posts but it wont happen. I've also tried manually clicking the button really fast but that doesn't do it either. Still though, users are managing to pull it off. Any tips?

dexter
Jun 24, 2003

chumpchous posted:

Question: I had a bug in my application that was causing the DB to lock up when a form got double posted. I switched to postgres and fixed some issues, but I've never actually managed to replicate the bug. The post is submitted via JSON, and I've tried just sending multiple JSON posts but it wont happen. I've also tried manually clicking the button really fast but that doesn't do it either. Still though, users are managing to pull it off. Any tips?

What do you mean lock up? Are you seeing deadlocks in your postgres logs? What kind of locking (if any) are you doing on your models?

kayakyakr
Feb 16, 2004

Kayak is true

chumpchous posted:

Question: I had a bug in my application that was causing the DB to lock up when a form got double posted. I switched to postgres and fixed some issues, but I've never actually managed to replicate the bug. The post is submitted via JSON, and I've tried just sending multiple JSON posts but it wont happen. I've also tried manually clicking the button really fast but that doesn't do it either. Still though, users are managing to pull it off. Any tips?

Were you using sqlite? Were you using a multi-instance server like unicorn? If so, that was your problem.

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder
Yeah I was using SQLite, and now I'm using postgres, so the problem is fixed. I just want to know how to test for the error, because I can't replicate it (on a server using an SQLite db).

kayakyakr
Feb 16, 2004

Kayak is true

chumpchous posted:

Yeah I was using SQLite, and now I'm using postgres, so the problem is fixed. I just want to know how to test for the error, because I can't replicate it (on a server using an SQLite db).

The problem is sqlite is single threaded. It works until someone hits the database at the same time as someone else. If you were using unicorn, this would happen any time two requests are submitted at the same time.

You can't really test for the error, you just have to know that if you're using sqlite, you can only use one server process at a time.

no_funeral
Jul 4, 2004

why

Smol posted:

Try adding attr_accessor :nextright to the class. Instance variables are private in ruby, the only way you can modify them from outside is via methods.

I tried this, but I'm now thinking that the problem is maybe in the binary tree library I'm using. When I populate the tree it says that every element's left AND right is the next element in the tree. Is there a reliable binary tree library out there?

prom candy
Dec 16, 2005

Only I may dance

Cocoa Crispies posted:

For me, shoulda's a way to get nested contexts with MiniTest::Unit assertions, and a handful of Rails-specific test helpers.

Ruby code:
class TeamTest < ActiveSupport::TestCase
  should have_many :instances
  should have_many :redemptions
  should have_many :flags
  should have_many(:captures).through(:redemptions)
  should 'find a team by ssl key guid' do
    …
  end
end
I usually use shoulda, factory_girl, and mocha.

Is it common to write a test for all your relationships and validations? It seems like overkill to me.

Adbot
ADBOT LOVES YOU

EAT THE EGGS RICOLA
May 29, 2008

Are there any decent ruby gems for doing decent visualizations, in the form of graphs/charts/maps/anything? I have a bunch of varied datasets that I've been asked to make interesting with, and all of my code that works with the api is ruby-based so I'd like to just carry on with that.

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