|
code:
That will print out a json encoded version of the object, which can go directly into your javascript block.
|
# ? Nov 6, 2014 23:55 |
|
|
# ? May 28, 2024 14:19 |
|
We're being taught differently, as we use Rails as an API server (database, AJAX, etc.) and don't bother to use the asset pipeline or Javascript libraries since it's headless. Instead, we create separate front-end static asset servers that hand out HTML, CSS and JS to the client which then access the API server to render everything. Is this common?
|
# ? Nov 7, 2014 00:34 |
|
Pollyanna posted:We're being taught differently, as we use Rails as an API server (database, AJAX, etc.) and don't bother to use the asset pipeline or Javascript libraries since it's headless. Instead, we create separate front-end static asset servers that hand out HTML, CSS and JS to the client which then access the API server to render everything. Is this common? I would characterize this approach as 'modern' if not necessarily 'common' (yet). It's not unusual to see this done with front-end frameworks like Ember.js, etc.
|
# ? Nov 7, 2014 01:00 |
|
I do ajax this way:
|
# ? Nov 7, 2014 01:15 |
|
e: ^^ that's a very old-school way of doing it.Pollyanna posted:We're being taught differently, as we use Rails as an API server (database, AJAX, etc.) and don't bother to use the asset pipeline or Javascript libraries since it's headless. Instead, we create separate front-end static asset servers that hand out HTML, CSS and JS to the client which then access the API server to render everything. Is this common? It happens. I am doing something similar in one of my projects, except that I am using the asset pipeline and ember-rails to package up my assets and I have 3 traditional controllers that are serving the root pages. I don't think that should be something you always do, some apps (both simple and complex) are better designed as traditional rails apps. I would only do that if it makes sense for the site to be a single page or if you're going to have a high amount of JS interaction anyway.
|
# ? Nov 7, 2014 01:48 |
|
MasterSlowPoke posted:I do ajax this way: Why ditch erb?
|
# ? Nov 7, 2014 01:49 |
|
Peristalsis posted:Well there's 3 hours of my life I'm never getting back. https://github.com/haml/html2haml
|
# ? Nov 7, 2014 15:19 |
|
Pollyanna posted:We're being taught differently, as we use Rails as an API server (database, AJAX, etc.) and don't bother to use the asset pipeline or Javascript libraries since it's headless. Instead, we create separate front-end static asset servers that hand out HTML, CSS and JS to the client which then access the API server to render everything. Is this common? We're doing this now at work. Our monorail, which contains the old dashboard and all of our business logic, now exposes an api that a separate project speaks to. The assets are served up through the monorail in the end (well, a cdn, but the view lives in the monorail), but we are eventually moving that away too.
|
# ? Nov 7, 2014 17:42 |
|
Yep using asset pipeline sucks for SPAs. Best to keep the frontend completely separate. You get to use better build systems as well.
|
# ? Nov 7, 2014 18:34 |
Knockout is a pretty good library if you just want a nice interface helper. You have to write all the ajax stuff yourself though.
|
|
# ? Nov 7, 2014 18:44 |
|
kayakyakr posted:e: ^^ that's a very old-school way of doing it. Do you know of a tutorial for a more modern way of doing it? I learned that from the rails docs.
|
# ? Nov 8, 2014 15:52 |
|
MasterSlowPoke posted:Do you know of a tutorial for a more modern way of doing it? I learned that from the rails docs. Not really. New school is mostly using Backbone, Angular, Ember, or something similar, combined with jquery to make calls against a JSON interface, or in the case of Ember, a custom made store (since I didn't like ember-data or the other ember data stores) Myself, if I'm doing a traditional rails app with server-rendered interfaces, I usually build and initialize singleton classes listening for events on various items (generally class-based, rarely id based), pulling data out of a data element. Serve it all up via sprockets. Ex: JavaScript code:
Mind, this is my own style that I've sorta built up from using various frameworks and various lack of frameworks. It's pretty old school prototypal JS, but I'm going to claim that makes it flexible. I can easily refactor to use a framework's classing system and it doesn't make me feel dirty like most jquery code does.
|
# ? Nov 10, 2014 00:36 |
|
Factory Girl is pissing me off. It can't seem to find the factories that it makes itself. I have a spec/factories/tests.rb with this content:Ruby code:
code:
code:
edit: Apparently factories can't exist without models. I'm crying. edit 2: NOPE I take that back it's still not working. Pollyanna fucked around with this message at 22:01 on Nov 10, 2014 |
# ? Nov 10, 2014 21:24 |
|
Pollyanna posted:edit: Apparently factories can't exist without models. I'm crying. this makes sense: factory girl is all about initializing your models with data in a repeatable, predictable way. If you don't have a model, then what is it initializing? Pollyanna posted:edit 2: NOPE I take that back it's still not working. This also sorta makes sense if you haven't required your factory files in some form or fashion.
|
# ? Nov 10, 2014 22:17 |
|
kayakyakr posted:This also sorta makes sense if you haven't required your factory files in some form or fashion. Yeah, do you have the factory_girl_rails gem? It handles loading factories automatically. It looks like you do based on the use of generators. I've never had this problem myself. Maybe something weird with your bundle file and test not finding factory_girl_rails?
|
# ? Nov 10, 2014 22:47 |
|
I forgot to add require 'rails_helper' to my spec files.
|
# ? Nov 11, 2014 02:14 |
|
Pollyanna posted:I forgot to add require 'rails_helper' to my spec files. Yeah that'll do it. Glad it was a dumb mistake and not some arcane issue with gem deps!
|
# ? Nov 11, 2014 03:03 |
|
Is there a recommended guide/book for making a Rails API out there? There's a bunch of different ones that talk about using RSpec for integration, Cucumber for integration, doing metaprogramming for all your different resource controllers, etc. All of them tend to be very sketchy quality and I still don't even know if what I'm doing is a good idea. Does anyone have a workflow/specs they like?
|
# ? Nov 11, 2014 18:03 |
|
I'm driving down to Rubyconf in San Diego from San Francisco on Sunday. Are any of you going? It's my first, and I have no friends.
|
# ? Nov 13, 2014 07:53 |
|
plasticbugs posted:I'm driving down to Rubyconf in San Diego from San Francisco on Sunday. Are any of you going? It's my first, and I have no friends. They rejected my talk
|
# ? Nov 13, 2014 08:38 |
|
Pardot posted:They rejected my talk Well, that sucks. What was your talk going to be on? I'm torn between a few of the scheduled talks that take place at the same time. I consider myself at the intermediate level, but some of the beginner talks sound interesting enough that I might learn a couple new things. The alternative is taking a chance on an advanced talk and it all going a little over my head.
|
# ? Nov 13, 2014 08:46 |
|
New Question: whats the best way to replicate the functionality of rails 4 routing conerns? This looks pretty good, is there anything better? http://ruby-journal.com/how-to-dry-your-rails-routes/ I have a handful of routes that I want to go to a non-restful controller, how do I group a couple of routes to the same controller without doing this: Ruby code:
Ruby code:
e: Got it Ruby code:
Ruby code:
KoRMaK fucked around with this message at 16:23 on Nov 18, 2014 |
# ? Nov 18, 2014 15:56 |
|
I'm being forced to take the Ruby Association Certified Ruby Programmer Silver given by "Ruby Association". Was wondering if anyone had taken it, and had any study guidance. I contacted the "Ruby Association" and they state they are planning on putting out a study guide. I also realize this cert, it probably bogus, and is a waste of my time... but figured I would ask if any of you poor souls had/chose to take the drat test.
|
# ? Nov 19, 2014 05:26 |
|
Some poor idiot will actually pay for that? Clearly I'm in the wrong business and should stop everything, make a clone of RubyMonk that includes "competence tests" and charge people a couple hundred bucks to get the Tao Jones Ruby Institute Silver Star or whatever.
|
# ? Nov 19, 2014 05:53 |
|
Partnering with Prometric isn't cheap and the Ruby Association claims to be chaired by Matz, so it's probably not bogus. Probably not very useful, either, but not totally bogus.
|
# ? Nov 19, 2014 07:10 |
|
Random questions but what would you recommend someone who's almost done with the rails tutorial ebook (I'm at chapter 10/12) and has done the Code School classes and would be looking for something to continue learning?
|
# ? Nov 20, 2014 22:53 |
|
xenilk posted:Random questions but what would you recommend someone who's almost done with the rails tutorial ebook (I'm at chapter 10/12) and has done the Code School classes and would be looking for something to continue learning? Find a pet project and just starting working on it. Its the best learning experience you can get. Also try your best to do as much TDD as possible while doing it. If you want to learn how to be a better ruby programmer I would suggest the books Eloquent Ruby (haven't read it yet but hear great things) and Metaprogramming Ruby. EDIT: Also The Rspec Book and Practical Object Oriented Design in Ruby are great as well.
|
# ? Nov 20, 2014 23:38 |
|
Yeah, Eloquent Ruby, POODR, and The RSpec Book are the three must have books. You're unlikely to grasp the majority of it the first time through but the more you expose yourself to the concepts as you work the more you'll absorb and improve.
|
# ? Nov 21, 2014 05:37 |
|
The Milkman posted:Yeah, Eloquent Ruby, POODR, and The RSpec Book are the three must have books. You're unlikely to grasp the majority of it the first time through but the more you expose yourself to the concepts as you work the more you'll absorb and improve. I'm sure this is heresy or something, but is RSpec really that much better than the built in testing suite? I found a quick introduction to it in one of the books I read (Eloquent Ruby, maybe?), very poor documentation and examples online, and I just didn't see how it was fundamentally better than the unit tests and fixtures. Are there tests I can do in RSpec that I can't do with the built-in testing framework, or is it just supposed to be more slick and fashionable? I'll admit that I find it tiresome that every Rails tool I use has something newer/shinier/better that everyone says I should be using instead (except when I shouldn't) - Pry instead of the built-in debugger, HAML instead of erb, RSpec instead of whatever the built-in tools are called, and so on. I'd rather get proficient at using a set of good tools, than constantly be in learning curves for things that are only marginally better, and possibly not as stable. As an example, we recently updated our Ruby and Rails versions, which made the built-in debugger almost useless. So, we're using Pry now, but I get some weird behavior from it sometimes, as well as some memory errors in my testing. I don't know if Pry isn't quite ready for prime time, or I just don't know how to use it correctly. I also don't know if Pry is causing the memory errors, or if something in my code changes is doing that. So, everything slows down and gets harder just because we want to recapture the same functionality we had before upgrading. Sorry, I'll quit ranting now. Peristalsis fucked around with this message at 16:51 on Nov 21, 2014 |
# ? Nov 21, 2014 16:47 |
|
Peristalsis posted:I'm sure this is heresy or something, but is RSpec really that much better than the built in testing suite? I found a quick introduction to it in one of the books I read (Eloquent Ruby, maybe?), very poor documentation and examples online, and I just didn't see how it was fundamentally better than the unit tests and fixtures. Are there tests I can do in RSpec that I can't do with the built-in testing framework, or is it just supposed to be more slick and fashionable? RSpec doesn't let you do more than the core Test framework, but it is far more expressive. If you're doing BDD/TDD its a much stronger tool as you can literally describe your code before your write it out. Then you write the code and it all works. You can probably do it successfully with Test, and really it boils down to personal preference. I can use either, but if I am doing TDD I vastly prefer rspec.
|
# ? Nov 21, 2014 17:13 |
|
Peristalsis posted:I'm sure this is heresy or something, but is RSpec really that much better than the built in testing suite? I found a quick introduction to it in one of the books I read (Eloquent Ruby, maybe?), very poor documentation and examples online, and I just didn't see how it was fundamentally better than the unit tests and fixtures. Are there tests I can do in RSpec that I can't do with the built-in testing framework, or is it just supposed to be more slick and fashionable? RSpec has a larger feature set than TestUnit, things like more human-readable syntax, much more useful feedback, that sort of thing. It's also been around long enough to respond to a lot of its early problems, like too much Ruby metaprogramming magic which it's now backing away from. There's a whole suite of features I never use in RSpec but I'm happy for the ones that exist. TestUnit hasn't changed in 10 years and that's the way some people like it. With any of these things nobody who isn't a complete tool will think less of you for using one over the other, be that rspec vs testunit, erb vs haml, etc etc. Use what works for you and your team. With this and all things I've always found having a standard to work to is more important than what that standard actually is.
|
# ? Nov 21, 2014 19:10 |
|
when I have to write tests, I prefer rspec. Kiddos, learn how to do TDD early, because when you get into the bad habit of not doing it, then you'll hate testing forever.
|
# ? Nov 21, 2014 19:54 |
|
kayakyakr posted:when I have to write tests, I prefer rspec. I was fortunate enough that my first Rails job insisted on 100% BDD.
|
# ? Nov 21, 2014 20:11 |
|
MrDoDo posted:Find a pet project and just starting working on it. Its the best learning experience you can get. Also try your best to do as much TDD as possible while doing it. If you want to learn how to be a better ruby programmer I would suggest the books Eloquent Ruby (haven't read it yet but hear great things) and Metaprogramming Ruby. Yeah I've been working on a project to harden my rails skills but I just like reading on it from time to time I do need to practice my TDD tho! Thanks for the recommendation, I've ordered Eloquent Ruby
|
# ? Nov 21, 2014 20:35 |
|
First thing I did at my new job was look in /test/. Nothing.
|
# ? Nov 21, 2014 20:41 |
|
I had a interviewer ding my code sample for no tests because he didn't look in spec/.
|
# ? Nov 21, 2014 20:54 |
|
xenilk posted:Yeah I've been working on a project to harden my rails skills but I just like reading on it from time to time I enjoyed Eloquent Ruby pretty well. I also liked Design Patterns In Ruby. It's more specialized, but there's still some good, generally useful stuff in there, in addition to the pattern-specific parts. Arachnamus posted:With any of these things nobody who isn't a complete tool will think less of you for using one over the other, be that rspec vs testunit, erb vs haml, etc etc. Use what works for you and your team. Somewhere deep within the bowels of my mind, I knew this. I guess I was just blowing off some steam. Peristalsis fucked around with this message at 21:30 on Nov 21, 2014 |
# ? Nov 21, 2014 21:20 |
|
kayakyakr posted:when I have to write tests, I prefer rspec. a thousand times this. it happened to me and i'm just getting good at testing a year on.
|
# ? Nov 21, 2014 22:46 |
|
MasterSlowPoke posted:First thing I did at my new job was look in /test/. Nothing. I assume it was right before you left your resignation letter. Maintaining rails apps is hard without good test coverage. Don't even try to skimp on tests, kids.
|
# ? Nov 21, 2014 22:51 |
|
|
# ? May 28, 2024 14:19 |
|
Smol posted:Maintaining Extends to libraries as well.
|
# ? Nov 21, 2014 23:49 |