|
MALE SHOEGAZE posted:
The lib folder is a junk drawer that really shouldn't exist. If something is part of your application but doesn't cleanly fit into app/models or app/controllers or app/something, put it in app/someotherthing. If it's not part of your application, put it in a gem. There's nothing wrong with having app/sweepers, app/services, and so on in your Rails app.
|
# ? Jan 31, 2015 22:18 |
|
|
# ? May 24, 2024 18:23 |
|
xtal posted:The lib folder is a junk drawer that really shouldn't exist. If something is part of your application but doesn't cleanly fit into app/models or app/controllers or app/something, put it in app/someotherthing. If it's not part of your application, put it in a gem. There's nothing wrong with having app/sweepers, app/services, and so on in your Rails app. Yeah but there's also nothing wrong with having lib/services, lib/sweepers. My main point is that if you're trying to follow rails conventions, you probably shouldn't be putting it in models. That said, I agree with Thalagyrt that rails conventions not always the best, and it's fine to treat your models folder as "domain models." Personally I'd prefer to keep all my domain stuff out of AR classes, though. DONT THREAD ON ME fucked around with this message at 22:38 on Jan 31, 2015 |
# ? Jan 31, 2015 22:30 |
|
MALE SHOEGAZE posted:Yeah but there's also nothing wrong with having lib/services, lib/sweepers. My main point is that if you're trying to follow rails conventions, you probably shouldn't be putting it in models. Yeah, my entire argument is that the conventions are bunk, and people are making it harder to reason about their codebase by splitting up a single namespace into more than one directory. I've never seen that done in anything other than Rails - in every other language, the module tree and directory tree in a given project will look the same, so to someone who hasn't seen this weird pattern before, it'd make sense to think that /lib would be a Lib module, /app/models App::Models, /app/controllers App::Controllers, /app/services App::Services, etc - but they're one big module that just globs all this stuff up instead. I think the concept of having app/services, app/actions, app/models, etc all actually being the same module makes it harder to reason about. In my opinion, organizing your code by functional module (in my case, Servers, Accounts, Users, Email, etc) makes it easier to reason about. I'm not thinking about whether something is a service, or AR model, or whatever when I'm thinking about where it belongs. Instead, I'm thinking about whether it's part of Accounts, or Servers, or Tickets, etc. Here, check out my app/models. I think you might see why I argue for this. You might also call me crazy, who knows. http://hastebin.com/laxuzoyufe.avrasm Each one of these subdirectories is pretty much one self-contained component to the site. There are some dependencies between modules - most everything has a dependency on the Accounts and Users modules - but for the most part, dependencies stay within a module. I could probably split these up further into more subdirectories, but I haven't found that necessary. But the key takeaway is that my code is organized by logical groupings of functionality, not by whether something is a service, or an AR, or something else. Thalagyrt fucked around with this message at 01:01 on Feb 1, 2015 |
# ? Feb 1, 2015 00:53 |
|
Thalagyrt posted:Yeah, my entire argument is that the conventions are bunk, and people are making it harder to reason about their codebase by splitting up a single namespace into more than one directory. I've never seen that done in anything other than Rails. I think the concept of having app/services, app/actions, app/models, etc all actually being the same module makes it harder to reason about. Here, check out my app/models. I think you might see why I argue for this. You might also call me crazy, who knows. No, I'm totally with you on keeping your modules discrete. It makes way, way more sense to do: code:
code:
This is what I mean about designing your code as if it's a gem. This is how (I would prefer, at least) my lib folder to be arranged. I don't care if it's in your app or your lib folder. I don't care if it's in the models folder either except that Rails has its own ideas about what should go in models.
|
# ? Feb 1, 2015 01:03 |
|
MALE SHOEGAZE posted:No, I'm totally with you on keeping your modules discrete. It makes way, way more sense to do: Yeah, this is exactly what I mean. My only argument against throwing it all in lib is that in the vast majority of cases this stuff isn't going to make sense outside of the context of your app - and lib is traditionally a directory used for external/third party libraries - so unless it's something I'm going to extract into a gem, I keep it out of lib. I was looking at Discourse earlier today and found it incredibly weird that they basically have structured their files in such a way that it suggests that the core of their application is a third party library. Edit: The top two results for "rails lib directory" on Google seem to agree with me, as well. These guys use it as a staging place for code that you could extract into a gem and reuse in another application. http://blog.codeclimate.com/blog/2012/02/07/what-code-goes-in-the-lib-directory/ http://reefpoints.dockyard.com/ruby/2012/02/14/love-your-lib-directory.html Thalagyrt fucked around with this message at 01:25 on Feb 1, 2015 |
# ? Feb 1, 2015 01:11 |
|
MasterSlowPoke posted:!(session[:user_id].nil?) #present? is great, but it's ActiveSupport's monkey patching, so it's not always around so it's less known and sometimes avoided by those of us who works in both Rails and Ruby. I think the only Rails-specific thing i really use is #blank? because it's so ridiculously better than the alternatives and should've been core in the first place.
|
# ? Feb 1, 2015 15:46 |
|
I think I agree with you guys about file organization however I think there's an argument to be made that fighting against how Rails dictates that your files should be organized can make your codebase harder to reason about for a new developer joining your project. The organization of controllers, specifically, is also somewhat tied to how Rails expects things to be laid out in order to work quickly and easily with routing. I think it would be interesting to open an app folder and see something like code:
|
# ? Feb 1, 2015 18:14 |
|
prom candy posted:I think I agree with you guys about file organization however I think there's an argument to be made that fighting against how Rails dictates that your files should be organized can make your codebase harder to reason about for a new developer joining your project. The organization of controllers, specifically, is also somewhat tied to how Rails expects things to be laid out in order to work quickly and easily with routing. Controllers aren't part of your domain model. They're a boundary between HTTP and your application, and their entire job should be to take a request, tell your application to do one thing, and then render the outcome of that action as HTML/JSON/etc. Controllers having a completely separate namespace structure that lines up with your URL structure makes sense and I definitely wouldn't try to put them in the same set of modules as my domain model.
|
# ? Feb 1, 2015 18:26 |
|
Is the model necessarily part of the domain model in that case? Ideally the model deals with nothing but the persistence layer and matters of persistence. Rails has tacked some extra things into there like validations and child-object creation, but I think if you're being strict about responsibilities then that stuff probably belongs in a form object. And then what about views? Should the code that handles rendering a representation of an instance be part of an object be part of your domain model? Or are you thinking something like: code:
|
# ? Feb 1, 2015 19:55 |
|
Separating your application by feature is a great idea that a lot of new frameworks and tools are using. But I don't think that means moving everything from app/views/posts and such to app/posts -- it's more nuanced than that. If you were to cut out the app/posts component and convert it to a gem, would those views or controllers still work and still be useful? Maybe, but probably not. The controller probably has less to do with the posts module and more to do with your routing and rendering layer. So maybe you'd end up with app/controllers/posts_controller.rb, and also app/posts/post_creator.rb, app/posts/post_finder.rb, and so on.
|
# ? Feb 1, 2015 20:27 |
Is anyone hiring remote right now? Hoping to relocate back home to TN but the software scene is abysmal there.
A MIRACLE fucked around with this message at 01:48 on Feb 2, 2015 |
|
# ? Feb 1, 2015 21:46 |
|
prom candy posted:I think it would be interesting to open an app folder and see something like We have a rather large Angular app at work that we organize this way, and I think it has worked out rather nicely. There are half a dozen or so people working on the app, and organizing by feature helps at least contain people's unique ideas about where code belongs or what it should be called.
|
# ? Feb 1, 2015 22:15 |
|
A MIRACLE posted:Is anyone hiring remote right now? Hoping to relocate back home to TN but the software scene is abysmal there. https://github.com/lukasz-madon/awesome-remote-job/
|
# ? Feb 2, 2015 06:29 |
|
Anyone have any good resources for learning RSpec?
|
# ? Feb 3, 2015 04:04 |
|
wins32767 posted:Anyone have any good resources for learning RSpec? Rails 4 Test Prescriptions
|
# ? Feb 3, 2015 15:28 |
|
Yep, that book is the best (I was going to recommend the previous version which is apparently now out of print? here https://pragprog.com/book/nrtest/rails-test-prescriptions) Here's some super-newbie resource, if you're coming in totally new: http://code.tutsplus.com/tutorials/ruby-for-newbies-testing-with-rspec--net-21297 I also like http://betterspecs.org/ DON'T feel bad about using "it {} over expect if it's a single check on the same line. The functionality's the same and sometimes the flow is better.
|
# ? Feb 4, 2015 19:12 |
|
I just got that book - can't wait to get into it! I also just bought Build Awesome Command-Line Applications in Ruby, though, and I'm wondering if I shouldn't have gotten the Ruby 2 version instead. Is there a major difference between the two? I can't seem to find a list of differences or updates. So far, it's a pretty good book - I downloaded the source code for it though, cause I was getting sick of having to look down and copy all the time. Sorry this isn't a Rails-specific question, but this seems to be the general Ruby thread as well. I really like this site - is there a similar site for, say, putting together a RESTful API (Rails or not)? Other sites in this vein for other subjects would be great to know about too. vv Woop woop, thank you! Pollyanna fucked around with this message at 21:22 on Feb 4, 2015 |
# ? Feb 4, 2015 21:14 |
|
Pollyanna posted:
https://github.com/interagent/http-api-design
|
# ? Feb 4, 2015 21:19 |
|
I want to integrate a native android app as a cleint for my rails App. Where should I start? Devise seems to have booted support for it. I know I have to pass the crsf and another key around, but how do I take care of authing? General question: when a username/password is submitted via browser how does it get transmitted safely if there is no SSL cert (and thus not https)? Or does it not get submitted securely? This looks like a nice resource. Always looking for more though.
|
# ? Feb 4, 2015 22:26 |
|
KoRMaK posted:I want to integrate a native android app as a cleint for my rails App. I think you can still do token authentication with devise. I've actually been casually keeping an eye out for something that implemented devise as an oauth service. Depending on what you need (and how secure things had to be), I'd limit things to providing a single token and authenticating the API off that. CSRF tokens don't really make too much sense in an API. You want to allow cross-site requests. You'll store the user authentication key in local storage, which is theoretically silo'ed. Unless your API has major side effects, in which case you want to add secret keys and whatnot. And if you don't have SSL, then it's not secure. It's transferred in plain text and has been for some time. Get SSL and run everything (including the API) through that. kayakyakr fucked around with this message at 22:37 on Feb 4, 2015 |
# ? Feb 4, 2015 22:30 |
|
kayakyakr posted:I think you can still do token authentication with devise. I've actually been casually keeping an eye out for something that implemented devise as an oauth service. Depending on what you need (and how secure things had to be), I'd limit things to providing a single token and authenticating the API off that. So the only way to do secure stuff is to get the cert. Great, that sounds like a nice blanket to wrap myself in. I have two issues with that: my site is just for farting around on so I don't want to pay a bunch of money for an SSL. Are thre free reliable ssl cert services out there? I'm also on heroku, which provides a free ssl connection but I can't use my domain name, I have to use their monkeybanana-srv01.herkoku.com address. So lets say I use the heroku https address and now I want to go public, how do I plug ssl into my heroku instance? e: How is token authing different than whatever a browser does (whats the name for browser authing?)?
|
# ? Feb 4, 2015 22:34 |
|
KoRMaK posted:Hah ok, so there is no magic that is going on that I'm not seeing when it comes to passwords coming through to my server. I noticed that in the rails console password fields in the params hash are like this "password => [PROTECTED]" or something. I thought there was some back end encrypting. If your site is just for farting around, then don't worry about it. If your site starts to get traffic, then you'll be able to afford a cert. Komodo certs start at something like $3 or less, so they're really not that expensive. Namecheap does the cheap certs. They are a bit of a pain in the rear end, which I why it's not something I do until I've got a fair user base. And with token auth, you pass a token with every API request, either as an explicit parameter or as a header. Browsers use a cookie with a session parameter saved on the cookie.
|
# ? Feb 4, 2015 22:41 |
|
kayakyakr posted:If your site is just for farting around, then don't worry about it. If your site starts to get traffic, then you'll be able to afford a cert. Thanks alot, you helped demystify the token auth convention.
|
# ? Feb 4, 2015 22:44 |
|
I guess I shouldn't say fair user base. I should say when I'm leaving alpha/beta.
|
# ? Feb 4, 2015 23:18 |
|
HTTPS should be your default choice for all apps. You can get free SSL from StartSSL or for free with a domain from Gandi or NameCheap.
|
# ? Feb 5, 2015 01:02 |
|
xtal posted:HTTPS should be your default choice for all apps. You can get free SSL from StartSSL or for free with a domain from Gandi or NameCheap. Or wait for the summer to roll around and these guys to come online: https://www.eff.org/deeplinks/2014/11/certificate-authority-encrypt-entire-web
|
# ? Feb 5, 2015 03:28 |
|
EVGA Longoria posted:I think the only Rails-specific thing i really use is #blank? because it's so ridiculously better than the alternatives and should've been core in the first place. This is awesome, I'm going to use #blank? all over the place now. BTW I just found this thread, looks like an awesome resource. I'm a student at the Turing School in Denver, which is like a long-form (7 mo) bootcamp for Ruby/Rails/JS. If anyone knows about anyone hiring junior devs in the Denver metro area or remotely, let me know! Otherwise I'll just be lurking and putting my two cents in occasionally.
|
# ? Feb 6, 2015 17:56 |
|
big boi posted:This is awesome, I'm going to use #blank? all over the place now. Casimir runs a pretty good program- we hired one of his grads a little over a year ago.
|
# ? Feb 6, 2015 18:13 |
|
Pollyanna posted:I really like this site - is there a similar site for, say, putting together a RESTful API (Rails or not)? Other sites in this vein for other subjects would be great to know about too. As an addendum, is there a site / gem / module / blog that talks about or has a ruby module to interface WITH an already existing REST api? Another group's got a ruby on rails application that spits out JSON with some basic create/delete entries and I can't help but think I'll be re-inventing the wheel if I try and come up with my own interface.
|
# ? Feb 6, 2015 18:47 |
|
Bhodi posted:As an addendum, is there a site / gem / module / blog that talks about or has a ruby module to interface WITH an already existing REST api? Another group's got a ruby on rails application that spits out JSON with some basic create/delete entries and I can't help but think I'll be re-inventing the wheel if I try and come up with my own interface. If the other group uses json schema perhaps with a tool to generate the schema, you can auto generate clients in ruby or go.
|
# ? Feb 6, 2015 18:53 |
|
I initially thinking of some library that did the heavy lifting of creating a class with initialize pulling/converting the JSON into an openstruct, with create/delete serialization methods that submit the appropriate JSON, but this looks like it'll work, although it's a completely different way of doing it. I'll give it a try! (A guy just told me they use httparty + rocket_pants to do it all on their end, dunno if that matters, but now I have some reading to do) - I may just be able to use that gem to do the decode/construct. Bhodi fucked around with this message at 19:09 on Feb 6, 2015 |
# ? Feb 6, 2015 19:02 |
|
The Journey Fraternity posted:Casimir runs a pretty good program- we hired one of his grads a little over a year ago. Good to know I'm in good hands. Entering the final module now, and my engineer friends are really impressed with how far I've come since September (thanks to Casimir et al).
|
# ? Feb 6, 2015 20:32 |
|
Pardot posted:you can auto generate clients in ruby or go. Uh, is this actually better than rolling your own client for something, or is it just easier?
|
# ? Feb 7, 2015 00:30 |
|
MALE SHOEGAZE posted:Uh, is this actually better than rolling your own client for something, or is it just easier? So for a small interface, or a simple app, this is way overkill. Instead I'd just make a straight up call with something like Excon. But for big projects it's super useful. Getting the documentation generated, and large parts of cli clients generated, not just once, but on an ongoing basis is great.
|
# ? Feb 7, 2015 00:41 |
|
Does anyone know if there are any consultancy services or SaaS services for Rails provisioning and deployment that let you use your own hosting or are hosting agnostic? I need to modernize our provisioning/deployment process but I don't really have time to be a sysadmin on top of being a full-time developer. I don't want to use Heroku.
|
# ? Feb 9, 2015 17:01 |
|
prom candy posted:Does anyone know if there are any consultancy services or SaaS services for Rails provisioning and deployment that let you use your own hosting or are hosting agnostic? I need to modernize our provisioning/deployment process but I don't really have time to be a sysadmin on top of being a full-time developer. I don't want to use Heroku. In house hosting? Your best bet is something like Ansible. I'm very intrigued by http://tutum.co which is providing docker deploys that are infrastructure independent. They've got a "bring your own hardware" feature on their list.
|
# ? Feb 9, 2015 17:08 |
|
re: Integrating with a native App/SSL/Certs/security. Turns out I can just slap an s at the end of https when I hit my domain and I get TLS 1.2 It's a wildcard cert for heroku, so I have to click past some WARNINGS about SECURITY, but thats it. So it looks like I can at least by myself some safe development time thanks to heroku.
|
# ? Feb 11, 2015 04:28 |
|
Just finished the Codeacademy Ruby + Rails tracks (the Rails one is worthless, in my opinion, for anything other than getting a vague feel of what things look like) and then https://www.railstutorial.org. I really like it as a language, and it integrates sosososo well with R, which is really nice for a lot of my applications of it. (I also appreciate that all the programming languages I'm using start with R). Since then I've been working on my own web app, but was wondering if there are any other good next steps for learning more? I've applied for some part time bootcamp things (Codeacademy schools, at a $250 price point, seems like a good deal), but am not sure if any of those will come through, and am signed up for some hackathons with friends, but obviously those are intermittent. An example might be -- a series of programming challenges where you make specific apps?
|
# ? Feb 16, 2015 19:35 |
|
semicolonsrock posted:Just finished the Codeacademy Ruby + Rails tracks (the Rails one is worthless, in my opinion, for anything other than getting a vague feel of what things look like) and then https://www.railstutorial.org. I really like it as a language, and it integrates sosososo well with R, which is really nice for a lot of my applications of it. (I also appreciate that all the programming languages I'm using start with R). Why not just start a pet project? I found it was a good way to kind of tie it all together. Ideally if you can include github/heroku into it i belive it ll be a good way to test what you ve learned. That s what im doig right now and i m enjoying it.
|
# ? Feb 16, 2015 22:09 |
|
|
# ? May 24, 2024 18:23 |
|
xenilk posted:Why not just start a pet project? I found it was a good way to kind of tie it all together. Ideally if you can include github/heroku into it i belive it ll be a good way to test what you ve learned. The way that I did this was to start with (admittedly useless and stupid) pet projects and just go out and code them until they're working. At first- you'll likely be all like "oh poo poo- everything I want to do, there is a Gem to do exactly that!" At first, use those Gems and just get your app working however you want. Over time, cut one Gem out at a time and code it yourself until you're able to do all the functions that common gems provide. Then you can go back to using them- but at least you'll understand how they work when you need to edit for your own use cases!
|
# ? Feb 17, 2015 00:19 |