|
EAT THE EGGS RICOLA posted:I just switched from a Windows machine doing dev stuff in a Linux VM to a Mac. Anything I should know or keep in mind about doing dev stuff on one? I've never used a Mac before other than just casually. homebrew is a pretty nice thing, but you'll probably end up compiling more things from source than you're used to. I recommend not trying to outsmart homebrew with the permissions it wants (at one point it was asking you to chmod /usr/local). It sounds kind of awful, but dealing with the alternative is much worse. good jovi fucked around with this message at 02:03 on Sep 5, 2013 |
# ¿ Sep 4, 2013 23:18 |
|
|
# ¿ Apr 27, 2024 14:11 |
|
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. 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.
|
# ¿ Feb 22, 2014 21:27 |
|
Lexicon posted:I feel like I should know the answer to this, but apparently don't: is it possible to rely exclusively on 'bundler' for gem installation? I'm about to start using middleman for static site generation, and all the tutorials are requiring that I 'gem install middleman' first, despite referencing bundler later. Can I not just structure things so only bundler installs the gem? Or is that not feasible because the 'middleman' command needs to be available in the terminal? Yes, you can just let bundler handle all the gem installation. The only downside is that you might have to preface your middleman calls with "bundle exec". Bundler doesn't strictly sandbox gems like using gemsets, or python's virtualenv. Think of it as a filter on the larger pool of gems that you have installed, making sure that only the ones you've specified are activated.
|
# ¿ May 4, 2014 17:06 |
|
Sil posted:Wait. Where did I pick up that """ """ thing? It must have been some rails tutorial book, but I could have sworn they said that's the way to do multiline strings in ruby. I see now, in IRB, that regular string literals do that just fine. Have you been reading any python tutorials? It uses triple quotes for multiline strings.
|
# ¿ May 9, 2014 13:15 |
|
Pardot posted:In fact, the check first really doesn't do anything because someone could have added a violating record in between the check and the insert. Which is why the rails unique validator is huge bullshit that doesn't do anything. Don't you see, uniqueness checks are "business logic" and don't belong in the database.
|
# ¿ May 19, 2014 22:06 |
|
Pollyanna posted:Right, I think I get it...but then the Rails tutorial goes through setting up authentication and factories and stuff from scratch. Am I basically gonna be replicating the Rails tutorial every time I want to set up something with authentication and a database? Only in the sense that yes, you're going to have to actually write your application. Eventually you figure out what gems best handle common tasks (like authentication) for you, and maybe even write a few of your own to encapsulate anything you find yourself writing over and over again.
|
# ¿ Jun 13, 2014 15:27 |
|
On that topic, it looks like Rails is finally getting builtin support for foreign keys! http://weblog.rubyonrails.org/2014/8/20/Rails-4-2-beta1/ (Until that lands, everyone should probably be using foreigner)
|
# ¿ Aug 21, 2014 15:21 |
|
This isn't strictly an answer to your question, but I'd do something like this:code:
It's the responsibility of a lease to define what "active" means. And defining active_lease as a relation rather than a method lets you avoid the N+1 problem by includesing :active_lease in your initial Lease query and not fetch it for every individual lease. i.e. code:
would only have to make 2 queries. good jovi fucked around with this message at 00:05 on Sep 1, 2014 |
# ¿ Aug 31, 2014 21:12 |
|
I had a interviewer ding my code sample for no tests because he didn't look in spec/.
|
# ¿ Nov 21, 2014 20:54 |
|
Also, don't create database objects in before(:all) blocks. They are executed outside of the transaction, so those rows won't get cleaned up.
|
# ¿ Dec 2, 2014 21:50 |
|
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 |
|
duck hunt posted:I've been a Python developer for a long while, and I'm inheriting and taking on a lot of Ruby projects at work right now. We use Puppet extensively as well as other internal tools written in Ruby. Seems like there is a lot of overlap conceptually between Python and Ruby. Python meet ups have stupid names about snakes and Holy Grail this and that, while all the Ruby meet ups seem to happen on Tuesdays. Especially for someone coming from Python, I recommend Metaprogramming Ruby 2. It may sound kind of specific, but I'm assuming you don't need to know how if statements work or whatever. The metaprogramming bits are most of what distinguishes Ruby from Python anyway.
|
# ¿ Mar 8, 2015 21:35 |
|
Docjowles posted:I'm having my first real encounter with ruby and I have what is probably a really retarded question. Why does this ERB template not do what I expect? It's being run through Chef, if that matters: What if you replace the whole thing with code:
This is really a Rails thread, but there doesn't appear to be a general Ruby thread, or a Chef thread, so whatever.
|
# ¿ Aug 26, 2015 15:54 |
|
These days you should really just be checking in a database.yml and managing any secrets or environment-specific config through environment variables (ie DATABASE_URL).
|
# ¿ Oct 8, 2015 16:01 |
|
duck monster posted:I'm fairly new to rails (Coming from a django background, new jobs uses rails), but was completely dumbstruck that active record doesnt create database constrains on relationships, and the dude who wrote them apparently doesnt believe in them. Thats a pretty bad sign in my books, so whats the alternatives? AR will create foreign key constraints if you tell it to - http://guides.rubyonrails.org/active_record_migrations.html#foreign-keys The only other ORM I've seen any kind of support for in the Rails world is Mongoid, and gently caress that noise.
|
# ¿ May 9, 2016 22:49 |
|
Pollyanna posted:but from what I can tell, this fails in @asset.update(asset_params) due to the arbitrary tag not having an ID, and not existing yet. What's the general approach for something like this, where you both update and create a resource at the same time? Are you on postgres? Just store the tags in an array field on Asset. You've gotta set up an index on the tags, but it's so much easier to deal with. EDIT: Or I could actually read your problem. An array would actually be really bad for you, there isn't really an efficient way to get all the tags. good jovi fucked around with this message at 20:17 on Jun 8, 2016 |
# ¿ Jun 8, 2016 20:15 |
|
Am I correct that using native postgres types forces you to switch your app schema over to :sql format? That seemed to be required last time I tried to use them, and I can't remember why that was undesirable exactly. Has anyone experienced any problems there?
|
# ¿ Aug 11, 2016 17:26 |
|
Handling multiple ruby versions is a breeze. rbenv has an extension called "ruby-build" (also available through Homebrew). Just install that and drop a .ruby-version file in each project. No problem*Peristalsis posted:On a completely different note, I have a side project coming up that involves writing a custom scheduling app. It's for a research lab that needs to send text messages to their subjects on a pre-determined schedule, and send occasional ad hoc texts on demand. To address your actual question, the first approach that comes to mind is to have a cron job running that is responsible for the actual sending of messages. So the rails app is just responsible for dumping scheduled messages into the database. Decide on a minimum resolution for message scheduling (say, 10 minutes), and then have the cron job run on that schedule (say, every 10 minutes). The job will then look in the database for any messages scheduled to go out in the past that haven't been sent yet and send them. That's just one approach, though, and assumes a certain scale (relatively small). Other options might depend on the infrastructure available to you. If you wanted to use a message queue like RabbitMQ or SQS, they both have a concept of delayed messages. Instead of putting SMSs in the database, you could just throw them on the queue with a delay of (send_time - current_time) and then again have a separate process responsible for consuming messages off that queue and just sending them out right away. In general, something like this wouldn't be done with threading inside the web app process, but by a separate process (cron job, sidekiq worker, whatever) solely responsible for handling that out-of-band work. The web process should be dedicated to serving up web pages, and anything not essential to the rending of those pages should be shipped off. *it's ruby, so "no problem" means "no problem as long as your use case exactly matches that of the program's author"
|
# ¿ Sep 20, 2016 13:50 |
|
|
# ¿ Apr 27, 2024 14:11 |
|
Partycat posted:I have been working on developing my internal toolset in ruby and rails, and have been slowly improving with my techniques, built my own internal gem for some modules, etc No, it’s fine. Ruby’s not going anywhere. They just previewed some upcoming features in Ruby 3 that sound quite neat, too. If you want to do a different language, try something with a very different paradigm. Expand your mind a bit. Like, say, clojure, or perhaps an Elm frontend for your rails app. Vastly different languages like that actually complement each other better in your brain, in my experience. Seeing other ways of doing things is going to make you a better programmer. Going from Ruby to Python is just going to make you focus on piddly poo poo like indentation. The fact that you’re even asking the question suggests that you’re not going to be applying for any jobs where they’d expect you to have really deep, specialized knowledge about a particular language. So get some breadth.
|
# ¿ Apr 25, 2019 15:03 |