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

A MIRACLE posted:

You might want to look into Rubymine for an IDE. I'm technically faster in VIM but being able to run your specs inline is really handy for workflow.

Rubymine is kingshit for debugging a single spec. Saves me a ridiculous amount of time and wasted pp some_dumb_variable bullshit at work.

Adbot
ADBOT LOVES YOU

kayakyakr
Feb 16, 2004

Kayak is true
Rubymine is ok, but I've dropped it for Gedit + console.

Sil
Jan 4, 2007
pp variable_name? Just install pry and use binding.pry to work things out with breakpoints and the repl. I imagine that's basically what RubyMine gives you except it works with any editor you want.

The Journey Fraternity
Nov 25, 2003



I found this on the ground!
I use vim.vroom, with it's "run current file's spec" command bound to leader-r. Maybe not as fast as running a single spec, but not by much at all, and I still get vim's goodness.

Cocoa Crispies
Jul 20, 2001

Vehicular Manslaughter!

Pillbug

Sil posted:

pp variable_name? Just install pry and use binding.pry to work things out with breakpoints and the repl. I imagine that's basically what RubyMine gives you except it works with any editor you want.

Rubymine's a proper visual debugger. I thought I could do as well with open-source stuff, but the complete package is really great and worth the money. pry is Power Wheels and Rubymine is the comfort of a Benz with the power of a Corvette.

Smol
Jun 1, 2011

Stat rosa pristina nomine, nomina nuda tenemus.

Cocoa Crispies posted:

Rubymine's a proper visual debugger. I thought I could do as well with open-source stuff, but the complete package is really great and worth the money. pry is Power Wheels and Rubymine is the comfort of a Benz with the power of a Corvette.

Word.

Pollyanna
Mar 5, 2005

Milk's on them.


I have to say something about the Rails tutorial book: test-driven development should really be left until after the reader understands what's actually going on. As it is now, I'm writing tests for some vague reason and what exactly the drat program is doing is buried in a verbose mountain of :words:. Something like 50% of the book is TDD, as opposed to 100% teaching me how to make things in Rails. Writing unit tests only teaches me how to test code, if I'm just writing a bunch of tests I have no loving clue what is going on behind the scenes aside from "expect specification to render partial in view", which means jack poo poo if I haven't gotten familiar with all that already. I don't know what I'm doing! Let me figure that out first!

It's really distracting and just makes it harder for me to learn. It's pointless to learn TDD first if the tests mean nothing to me. IMO, learn it when you need it - i.e. when you're actually writing applications and feel the need for a testing framework. If you do the Rails tutorial book and you're completely new to either Rails or web development in general, skip the testing framework stuff - you'll get much more out of it wayyyy later in life.

EDIT: I also just found out about application templates so now I can just write one properly working application and then apply it to new apps! Thank god I don't have to write the same thing over and over again. Although I'm not sure how to add controller code here...

EDIT 2: Oh, I may not be able to. :saddowns: Oh well, I can always copy it from an example file.

Pollyanna fucked around with this message at 16:45 on Jun 17, 2014

EAT THE EGGS RICOLA
May 29, 2008

Pollyanna posted:

I have to say something about the Rails tutorial book: test-driven development should really be left until after the reader understands what's actually going on. As it is now, I'm writing tests for some vague reason and what exactly the drat program is doing is buried in a verbose mountain of :words:. Something like 50% of the book is TDD, as opposed to 100% teaching me how to make things in Rails. Writing unit tests only teaches me how to test code, if I'm just writing a bunch of tests I have no loving clue what is going on behind the scenes aside from "expect specification to render partial in view", which means jack poo poo if I haven't gotten familiar with all that already. I don't know what I'm doing! Let me figure that out first!

It's really distracting and just makes it harder for me to learn. It's pointless to learn TDD first if the tests mean nothing to me. IMO, learn it when you need it - i.e. when you're actually writing applications and feel the need for a testing framework. If you do the Rails tutorial book and you're completely new to either Rails or web development in general, skip the testing framework stuff - you'll get much more out of it wayyyy later in life.

EDIT: I also just found out about application templates so now I can just write one properly working application and then apply it to new apps! Thank god I don't have to write the same thing over and over again. Although I'm not sure how to add controller code here...

EDIT 2: Oh, I may not be able to. :saddowns: Oh well, I can always copy it from an example file.

What about the tests in his example is unclear? You've done a few things and should be able to follow along, even if it seems like a roundabout way to look at development.

Jaded Burnout
Jul 10, 2004


EAT THE EGGS RICOLA posted:

What about the tests in his example is unclear? You've done a few things and should be able to follow along, even if it seems like a roundabout way to look at development.

Could be an issue with the scope of the tests. The testing style preferred by Rails isn't very behavioural and so the assertions don't make a lot of sense to someone not familiar with rails.

In the example given by Pollyanna, rendering partials in views? Sure they're sort of generic terms but that's Rails terminology. How about "lists each animal on the page" or whatever, then at least the intentions of the test are clear to the authors before they start implementing the code to do it.

EAT THE EGGS RICOLA
May 29, 2008

Arachnamus posted:

Could be an issue with the scope of the tests. The testing style preferred by Rails isn't very behavioural and so the assertions don't make a lot of sense to someone not familiar with rails.

In the example given, rendering partials in views? Sure they're sort of generic terms but that's Rails terminology. How about "lists each animal on the page" or whatever, then at least the intentions of the test are clear to the authors before they start implementing the code to do it.

I think that the terminology is pretty generic, but I guess that there's a base level of familiarity you need to avoid having the learning curve be a vertical cliff.

Chilled Milk
Jun 22, 2003

No one here is alone,
satellites in every home
Given I have two sites on two different domains with the exact same backend/structure just separate data (and slightly different layouts), does it make sense to use a multitenancy model and run them off the same (production will almost certainly be Heroku) instance? The schema isn't terribly complex. I would think the overhead would still be less than running (let alone maintaining) two separate apps, just curious if anyone else has run into this.

Kobayashi
Aug 13, 2004

by Nyc_Tattoo
This may be beyond the scope of this thread or too much of a "do my homework for me" kind of question, but is anyone familiar with Gollum (and gollum-lib), the wiki that powers Github? I want to use it, with custom markup extensions for a small side project. The problem is, I don't know the first thing about Ruby, or Rails. I usually learn by hacking, but in this case, Gollum is too complex for me to even do that.

Specifically, I just need to figure out how to turn overload the double-bracket syntax that Gollum already uses and that should be enough of a toehold to figure out the rest:

code:
# This is Markdown

Gollum is a git-based wiki that links to pages [[like this]].

I want to extend that syntax with something like `[[custom:It worked!]]`

Which would yield "the custom tag says: It worked!"
By looking through the gollum-lib source code, I think I could either hack on tags.rb directly, or use one of the methods in this issue (such as gollum-descendent-tree) to make it work. Unfortunately, I don't even know where to test my hypothesis. I can't figure out the build system. I don't understand the boundaries between Rails and Ruby and gems and Sinatra and Rake and Bundle and Gollum and gollum-lib. I don't understand the directory structure. I don't understand the dependency hierarchy.

If I hack the source directly, I don't know download both repositories and tell them to use the local, hacked up versions. If I try to duck punch, I don't know how -- syntactically -- to do that either. Rails in general, and Gollum in particular, are just too complicated for me to make sense of. Are there any step-by-step guides, from a brand new Mac/Linux installation, that can teach me how to hack a project like this? I'm totally lost.

kayakyakr
Feb 16, 2004

Kayak is true

Kobayashi posted:

This may be beyond the scope of this thread or too much of a "do my homework for me" kind of question, but is anyone familiar with Gollum (and gollum-lib), the wiki that powers Github? I want to use it, with custom markup extensions for a small side project. The problem is, I don't know the first thing about Ruby, or Rails. I usually learn by hacking, but in this case, Gollum is too complex for me to even do that.

Specifically, I just need to figure out how to turn overload the double-bracket syntax that Gollum already uses and that should be enough of a toehold to figure out the rest:

code:
# This is Markdown

Gollum is a git-based wiki that links to pages [[like this]].

I want to extend that syntax with something like `[[custom:It worked!]]`

Which would yield "the custom tag says: It worked!"
By looking through the gollum-lib source code, I think I could either hack on tags.rb directly, or use one of the methods in this issue (such as gollum-descendent-tree) to make it work. Unfortunately, I don't even know where to test my hypothesis. I can't figure out the build system. I don't understand the boundaries between Rails and Ruby and gems and Sinatra and Rake and Bundle and Gollum and gollum-lib. I don't understand the directory structure. I don't understand the dependency hierarchy.

If I hack the source directly, I don't know download both repositories and tell them to use the local, hacked up versions. If I try to duck punch, I don't know how -- syntactically -- to do that either. Rails in general, and Gollum in particular, are just too complicated for me to make sense of. Are there any step-by-step guides, from a brand new Mac/Linux installation, that can teach me how to hack a project like this? I'm totally lost.

You should probably start with a beginner rails tutorial to let you know how some of these projects are structured. Then a beginner gems tutorial to show you how the gems are structured. Then you want to look up how to use bundler gemfile with a local directory.

Jaded Burnout
Jul 10, 2004


The Milkman posted:

Given I have two sites on two different domains with the exact same backend/structure just separate data (and slightly different layouts), does it make sense to use a multitenancy model and run them off the same (production will almost certainly be Heroku) instance? The schema isn't terribly complex. I would think the overhead would still be less than running (let alone maintaining) two separate apps, just curious if anyone else has run into this.

I have run into it but in situations where there were security implications involved so they had to be on different machines, let alone different apps.

It's a question of where do you want your complexity, in your code or in your configuration? I'd go for configuration myself, there's tools built to handle it (staging vs production is a common instance of this).

xenilk
Apr 17, 2004

ERRYDAY I BE SPLIT-TONING! Honestly, its the only skill I got other than shooting the back of women and calling it "Editorial".
Is anyone using Sublime Text 3 at all to interact with Ruby? I'm wondering if I should go with RubyMine instead.

Sil
Jan 4, 2007

xenilk posted:

Is anyone using Sublime Text 3 at all to interact with Ruby? I'm wondering if I should go with RubyMine instead.

I do all my Rails work in ST3. It's pretty fun. Then again I don't find that I need much IDE-level help working with Ruby/JS code. When I tried RubyMine I thought it was a) interesting and had potential b) slow and c) a decent chunk of of work to learn how to use properly for unclear benefits above ST3+command line tools.

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.

Sil posted:

I do all my Rails work in ST3. It's pretty fun. Then again I don't find that I need much IDE-level help working with Ruby/JS code. When I tried RubyMine I thought it was a) interesting and had potential b) slow and c) a decent chunk of of work to learn how to use properly for unclear benefits above ST3+command line tools.

pretty much. I use Rubymine because the shop uses it, but I'd probably be just as happy using VIM + command line. Having a shortcut to run any tests inline is pretty handy though. But there's probably plugins for that for Sublime

Coca Koala
Nov 28, 2005

ongoing nowhere
College Slice

Pollyanna posted:

I have to say something about the Rails tutorial book: test-driven development should really be left until after the reader understands what's actually going on. As it is now, I'm writing tests for some vague reason and what exactly the drat program is doing is buried in a verbose mountain of :words:. Something like 50% of the book is TDD, as opposed to 100% teaching me how to make things in Rails. Writing unit tests only teaches me how to test code, if I'm just writing a bunch of tests I have no loving clue what is going on behind the scenes aside from "expect specification to render partial in view", which means jack poo poo if I haven't gotten familiar with all that already. I don't know what I'm doing! Let me figure that out first!

It's really distracting and just makes it harder for me to learn. It's pointless to learn TDD first if the tests mean nothing to me. IMO, learn it when you need it - i.e. when you're actually writing applications and feel the need for a testing framework. If you do the Rails tutorial book and you're completely new to either Rails or web development in general, skip the testing framework stuff - you'll get much more out of it wayyyy later in life.

Does the tutorial get better in the later chapters? I've gone through the first few so far and I have sample applications written in rails, but I don't actually know anything about rails. It's all been "Use rails generate scaffold! Now you have a site! Look at the site, you made that!". I'm getting the impression that Rails is really helpful for developing web apps, but I'm not interested in making a twitter clone and so far I haven't seen anything in the tutorial that will teach me to do anything that isn't making a twitter clone.

Smol
Jun 1, 2011

Stat rosa pristina nomine, nomina nuda tenemus.
You should use Rubymine, because it understand ruby code, so code navigation, automated refactoring etc. actually work and the debugger is awesome.

fruition
Feb 1, 2014

Coca Koala posted:

...I'm not interested in making a twitter clone and so far I haven't seen anything in the tutorial that will teach me to do anything that isn't making a twitter clone.

Yeah I'm in the same boat currently, but I realize I have to walk before I run. Rails seems really powerful but there's a poo poo ton to learn before I can start kicking rear end...I just have to stick with it and one day (not so soon) I'll be able to dream it and do it.

This is as far as I've ever come with a framework and it's exciting to have so many "a-ha!" moments. I think the rails guide is just enough to get your feet wet so you can start referencing the api/docs whenever you want to tackle a new problem, or at least know what to google.

Lexicon
Jul 29, 2003

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

Sil posted:

I do all my Rails work in ST3. It's pretty fun. Then again I don't find that I need much IDE-level help working with Ruby/JS code. When I tried RubyMine I thought it was a) interesting and had potential b) slow and c) a decent chunk of of work to learn how to use properly for unclear benefits above ST3+command line tools.

How does ST3 compare to ST2? I've used the latter very happily for a few years now, and I'm only vaguely aware that ST3 even exists.

Chilled Milk
Jun 22, 2003

No one here is alone,
satellites in every home
Even though I was brought up using Visual Studio/Eclipse it never seemed like there was too much to gain from a Ruby IDE. Then again the ruby I'm writing isn't the most complex stuff around

Lexicon posted:

How does ST3 compare to ST2? I've used the latter very happily for a few years now, and I'm only vaguely aware that ST3 even exists.

Mostly it's more complicated to get package manager installed.

Less cheeky answer:
https://www.sublimetext.com/forum/viewtopic.php?f=2&t=16369

I've been using 3 for about a year now and the only issue I have with it is sometimes the terminal helper is bad at opening the folder I pass in sometimes.

Pollyanna
Mar 5, 2005

Milk's on them.


I'm having trouble understanding how to write a front-end heavy application in Rails, and how a JavaScript MVC framework would work in tandem with it. The way I learned it, the server handles stuff like routing and logic (a GET request to this URL does this action, a POST request to this other URL does this other action), database interaction (@user = User.find(1)), and serving up a page (index.html.erb, etc.). Apparently, though, JSMVC frameworks like Angular or Ember handle routing and modeling and everything themselves. It's basically like, writing a standard desktop application in JavaScript, sending that to the user, and only using the server to store and serve data. Is that correct?

What does a basic, single-page JS MVC app look like in Rails?

Smol
Jun 1, 2011

Stat rosa pristina nomine, nomina nuda tenemus.
Typically, the the backend side has at least two responsibilities.

1) Provide an (JSON) API for the JS frontend.
2) Serve the correct frontend code for the browser.

While the frontend has two responsibilities as well.

1) Communicate with the backend API (e.g. "Give me the list of users in JSON format", or "Save this new user with these and these attributes")
2) Display the information to the user ("Now that I have the list of users in JSON format, transform it to a bunch of HTML and display it on the page".

Pollyanna
Mar 5, 2005

Milk's on them.


So, for example, my Rails app would:

  • Defines models and interacts with the database
  • Match URLs (routes.rb)
  • Handle controller logic and CRUD:
    Ruby code:
    def create
      @post = Post.new(params[:post_info])
      if @post.save  # this is supposed to be validation
        @post.save  # or w/e you know what i mean
      else
        #complain
      end
    end
    
  • Define a REST API, like get 'posts/:id' => 'posts#show', and change the data objects found into JSON
  • Serve the index page (root 'home#index') with the big-rear end JS script for the UI
  • Specifically NOT serving any HTML, just JSON

While the big-rear end JS script does this:

  • Uses $.getJSON('posts/99') and the like to load/save JSON objects to and from the server, which it handles depending on the URL's associated action
  • UX/UI code that I haven't ever really made before but does stuff like building the DOM for the page, templates, all that (how do instance variables like @user get passed to it from the server?)

Is that right? Where does the MVC come into play with the JS framework, then? This just seems as though it only handles V, while the server still handles M and C. Where does it do routing and everything? What does it control?

xenilk
Apr 17, 2004

ERRYDAY I BE SPLIT-TONING! Honestly, its the only skill I got other than shooting the back of women and calling it "Editorial".

Pollyanna posted:


While the big-rear end JS script does this:


By "big-rear end js script" are you talking about something like angular.js ?

If yes, I'm just about on the same boat than you are... intrigued with how you'd be doing all of this.

Edit:

I think ruby would be the RESTful API (with all the routes etc for the api) while angular.js would have its own routes for display purposes that use the API to fetch its data?

xenilk fucked around with this message at 18:01 on Jul 8, 2014

KoRMaK
Jul 31, 2012



If you're using Rails, I think the only thing you'll be able to sub in is the V. Otherwise, you'd stop using rails since its the M and C. Optionally, the JS stuff does MVC for the front end, but I don't know what that would be. I guess the model would be your view state, and the controller would... uh I dunno: handle what objects get instantiated and what they are interacting with.

e: Why would you do this? What is your end implementation and user experience?

Pollyanna posted:


(how do instance variables like @user get passed to it from the server?)

You gotta pass those yourself. I'm not sure you are getting why to use rails and it's different parts. The erb engine is integrated so that it handles all the passing. You may be looking at re-implementing existing functionality with the way you are going instead of using a hybrid.

For instance, you can keep your JS library and use ruby js/json responses to supply variables. But why use JS for something other than front-end, and try to re-implement already existing functionality?

KoRMaK fucked around with this message at 18:05 on Jul 8, 2014

Pollyanna
Mar 5, 2005

Milk's on them.


That's exactly why I'm confused. Apparently MVC frameworks are what make single page apps much easier(?), but they're mutually exclusive with anything that isn't Node or...are apparently standalone? Otherwise, there's a whole lot of repetition going on. I don't understand.

If I'm gonna be using Rails, then I'm really only ever gonna be using JS as part of the View. Probably not to 100% replace it - ERB is there for a reason, isn't it? - but apparently the toast of the town in modern web dev is a heavy front end, which as far as I can tell just means that the server can be replaced with a hard drive and the rest of the server code is sent to the client.

It kinda feels like front-end heavy stuff is just trying to wrangle web applications into being written like desktop applications.

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.

Just go make a Meteor practice app

KoRMaK
Jul 31, 2012



Pollyanna posted:

It kinda feels like front-end heavy stuff is just trying to wrangle web applications into being written like desktop applications.

I get that vibe too. I think for node.js the server is written in js and then run through an interpretor. Why use JS to power a server? I have no idea. But I also didn't get RoR's when I first started and thought it was overly complicated, but I ended up turning around on that as soon as I got past the hello world app (the most useless and irrelevant example of MVC)

kayakyakr
Feb 16, 2004

Kayak is true
I've been using Ember on the last couple of projects I've done and it's not bad. Don't use Ember-Data, it blows, there are a couple of others that are better, and I've rolled my own.

What makes it possible in Rails is the ember-rails gem:
https://github.com/emberjs/ember-rails

This is key because it effectively gives you your file structure and code design. Thing with Ember is that while it claims to be a MVC front end, it's got 2 view components, 1 controller, and 2 model components (1 of which is optional). Plus their controller acts as a sort of model in its own right. So I can see how you might be confused with that.

But do it the ember-rails way, it'll work out for you.

Pollyanna
Mar 5, 2005

Milk's on them.


This is gonna sound horrible, but the reality of programming languages is that they all become the same thing in the end so you can use them all for pretty much the same implementation - there's no reason you can't do systems programming in Lua or Cobol on Wheelchair. The issue I have is that...I just prefer JavaScript to be specific to UI/UX. JavaScript just makes more sense in that context, and there's no reason it can't be a server, but there's no reason it has to be either. Maybe I'm just being nitpicky but I prefer JS sticks to what it's good at.

It's like segregation, which is a little hosed up.

kayakyakr posted:

Thing with Ember is that while it claims to be a MVC front end, it's got 2 view components, 1 controller, and 2 model components (1 of which is optional). Plus their controller acts as a sort of model in its own right. So I can see how you might be confused with that.

So if I use Ember with Rails, I end up having at least two Models, two Controllers, and three Views? That...isn't very dry. Not to say that code benchmarking is the point of coding, but whether something makes sense or not affects whether I know what the gently caress I'm doing or not.

Pollyanna fucked around with this message at 18:41 on Jul 8, 2014

KoRMaK
Jul 31, 2012



Pollyanna posted:

Maybe I'm just being nitpicky but I prefer JS sticks to what it's good at.

It's like segregation, which is a little hosed up.

Haha, ok easy. Easy on yourself there. Separation of duties is a more applicable phrase.

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.

Haha, since when is Javascript "good" at UI? You have to lug templating libraries with you to get even basic UI sensibility (unless you're cool with jQuery spaghetti). Javascript works for the browser DOM because it has to apply to everyone's OS, screen size, browser version etc. But a baked in UI language (smartphones, hell even Java windows) will always be easier to write for

KoRMaK
Jul 31, 2012



A MIRACLE posted:

Haha, since when is Javascript "good" at UI? Javascript works for the browser DOM because it has to apply to everyone's OS, screen size, browser version etc. But a baked in UI language (phones, hell even Java windows) will always be easier to write for
I interpret "javascript good at ui" to mean bootstrap + jquery

Pollyanna
Mar 5, 2005

Milk's on them.


Okay by "good at" I mean "typically used for". I really don't understand what JS is supposed to be for. Scripting? DOM manipulation? Just kinda sorta whatever?

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.

Pollyanna posted:

Okay by "good at" I mean "typically used for".

[small]I really don't understand what JS is supposed to be for. Scripting? DOM manipulation? Just kinda sorta whatever?[/small]

Just sorta whatever. It has a weird history and barely resembles the version I learned in like 1999. It's lightning fast in its NPM implementation which is why some hipsters like to use it on the server. You have to be *really* down with closures though

Smol
Jun 1, 2011

Stat rosa pristina nomine, nomina nuda tenemus.

KoRMaK posted:

Haha, ok easy. Easy on yourself there. Separation of duties is a more applicable phrase.

Separation of concerns would be the appropriate software term.

KoRMaK
Jul 31, 2012



A MIRACLE posted:

You have to be *really* down with closures though
I think I had this asked in an interview, I still don't get it. http://en.wikipedia.org/wiki/Closure_(computer_programming) If I understand it right, a practical example that I deal with regularly is a jquery iterator, e.g. each(function() { ... });

Smol posted:

Separation of concerns would be the appropriate software term.
Nuh uh you said decoupling, I seent it!

Adbot
ADBOT LOVES YOU

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.

KoRMaK posted:

I think I had this asked in an interview, I still don't get it. http://en.wikipedia.org/wiki/Closure_(computer_programming) If I understand it right, a practical example that I deal with regularly is a jquery iterator, e.g. each(function() { ... });

Yep, basically your nested scope has access to everything above it in order of proximity. Scopes are limited to functions and loops, if-clauses don't have their own scope.

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