|
I inherited a project that uses DataMapper, and I'm having some weird problems around Floats. Upon save any value gets rounded to the closest whole number. e.g 1.4 becomes 1.0, 2.8 becomes 3.0. I'm not altering the value at any point in the controller, just a straight form to save. It happens in rails console too. property :duration, Float, :required => true I tried futzing around with the scale and precision but to no avail.
|
# ¿ Jul 18, 2013 22:22 |
|
|
# ¿ Apr 27, 2024 09:34 |
|
Molten Llama posted:Is it being persisted to an underlying column/field/whatever of the correct type? It's possible to end up with the database and model out of sync. If DataMapper can make a value reasonably fit the existing column type, it generally will. Ahh, yes this must be it. Pretty sure this field was an integer at some point. I did run an auto_upgrade! while making some other changes, I would have figured that would take care of it. Alright, thanks I now know what to look into to
|
# ¿ Jul 19, 2013 03:17 |
|
What's a good way of presenting a way for users to add an event to their calendar? Specifically on mobile? Generating an .ics seems to work well enough for desktop and iPhones, but android doesn't seem to know what to do with it without a separate app. Edit: Peculiar, my s3 on Cyanogenmod doesn't want to handle any sort of ics file, but the office Tab 2 we have for testing works great. Now I'm wondering if it's just the stock calendar app that doesn't support it. Or maybe my phone is just borked. Chilled Milk fucked around with this message at 18:31 on Sep 27, 2013 |
# ¿ Sep 27, 2013 17:14 |
|
Sitting Bull posted:Does anybody here have experience with ActiveAdmin, specifically activeadmin-mongoid (https://github.com/elia/activeadmin-mongoid)? At my new job I've been put in charge of implementing various admin features(edit/delete a post or user, etc), and I've run into nothing but problems. Even the basic Formtastic operations don't seem to be working, aside from input(non-plural) and I have no idea where to go for help, as the documentation for both ActiveAdmin, and especially activeadmin-mongoid, are extremely sparse. I'd really appreciate anybody with experience giving me a push in the right direction. Haven't touched much mongoid stuff but I'm fairly up on my AA. I can say off the bat if you're running Rails 4 you'll need to be grabbing the GitHub master branch, no release with it yet. Post your model and AA resource file for it and I'll give it a once over.
|
# ¿ Oct 4, 2013 03:04 |
|
Sitting Bull posted:May I contact you off site? If so, what would the best method be? PM or milkohol@gmail
|
# ¿ Oct 4, 2013 04:18 |
|
The New Relic/Heroku "trick" is fairly widely known and has been for a good long while. If it truly was a problem they would have done something about it by now. That said, Digital Ocean is a great alternative if you don't mind getting your hands slightly dirty setting things up. Once you have capistrano rolling it's just as turnkey. Edit: And that's a good write up above this post
|
# ¿ Dec 16, 2013 21:59 |
|
kayakyakr posted:yeah, yeah, double posting, but what would you guys think about starting a new thread? The OP is from over 6 years ago, everything in it is horribly out of date, the poster hasn't posted here since 2008, and with a 122 page thread, the same questions have tended toward being asked many times already. Go for it. I could probably write up a quick guide/tips n tricks about Active Admin if there's any interest.
|
# ¿ Dec 16, 2013 23:36 |
|
kayakyakr posted:
Welcome to the industry.
|
# ¿ Feb 4, 2014 02:54 |
|
I'm working on a thing where an admin can upload a series of images, and the front end will display one, then after X amount of time start displaying the next one. Alternatively it could complete a cycle every X (6-12ish) hours. It's not super strict in that regard. It's not a live loading JS thing, just on page load you'll get an image from the server. My first thought would be whenever/cron but perhaps there's a better way? Perhaps slicing up a chunk of time by the count of images and comparing it against the current time? I'd appreciate input from anyone who's tackled something like this before.
|
# ¿ Feb 10, 2014 23:54 |
|
USSMICHELLEBACHMAN posted:I'm not really understanding your question. Why can't you just use timeout? If you're not doing liveloading, you can just have an array of image URLs and every x minutes it pops a url off the array and displays it. Because I didn't know about timeout Yeah I wasn't crazy about that idea, that's why I asked. Never had to deal with time in this sort of way before, especially in a web application and figured there had to be something better than what I cooked up on a monday with little sleep. Thanks! Edit: here's what I came up with this morning initializer: code:
code:
Chilled Milk fucked around with this message at 19:04 on Feb 11, 2014 |
# ¿ Feb 11, 2014 05:05 |
|
prom candy posted:Deploying with Capistrano has been a real headache lately. I'm tired of all of my Rails 2.3.x deploys taking seconds while my Rails 3.1+ apps take ages because it has to run bundle install (even though my Gemfile hasn't changed) or run rake:assets:precompile (even though my assets haven't changed). Is there something better out there than Capistrano? Alternately, are there tried and tested recipes for skipping these long processes if they're not necessary? All I can find is some gists on blog posts from a few years ago that don't really work. The answer to the assets question is https://github.com/ndbroadbent/turbo-sprockets-rails3
|
# ¿ Feb 17, 2014 07:10 |
|
Coming from someone who had testing beat into his head early on but fell off the wagon for a stretch once I was working solo, let me tell you it's important to keep up with. Even when you're starting out writing fairly simple interactions, write the loving tests even to just get comfortable writing them and not get rusty. REPL only gets you so far. Your future self who starts getting into more complex applications where you NEED them will thank you.
|
# ¿ Feb 22, 2014 18:58 |
|
Popper posted:This looks like the kind of code that if it breaks is terrible. Yeah, that was my original idea. What I ended up going with was this (based on Cocoa Crispies answer): code:
|
# ¿ Feb 26, 2014 18:16 |
|
prom candy posted:We have a WYSIWYG editor that we've built that splits content up into Rows and Pieces which are classified as RowTypes and PieceTypes. Basically it lets a user build a page by adding rows like "Two Columns of Text" or "An image with text wrapped around it" or "an embed code" or whatever, here I'll just post some screenshots so you can see what I mean: Sounds pretty similar to something I had to build this year (various parent models have a series of various kinds of content chunks). Thankfully I don't forsee needing this level of revision history for our purposes but I'm interested to see what kinds of solutions exist.
|
# ¿ Apr 17, 2014 04:54 |
|
Say I have two models Stage - has_many milestones Milestone - belongs_to stage - has a due_date Given that various Stages may overlap (ie the range of its milestones' due_date), what's the best way to retrieve the Stages in order of its earliest milestone? I could do it with ruby but trying to build the right SQL query for it eludes me on this little sleep
|
# ¿ Jun 5, 2014 20:24 |
|
Pardot posted:
That looks close but it's coming back ordered by id, change the schema to insert into stages (id, name) values (2, 'a'), (1, 'b'), (3, 'c'); and you get code:
|
# ¿ Jun 5, 2014 22:20 |
|
Pardot posted:add order by first_date asc to the end I was going to say I tried that but looking at it again I was writing first_milestones. Ugh. Thanks, man.
|
# ¿ Jun 5, 2014 22:54 |
|
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.
|
# ¿ Jun 17, 2014 23:59 |
|
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 aroundLexicon 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.
|
# ¿ Jul 8, 2014 07:06 |
|
MALE SHOEGAZE posted:In other news, I figured out that erb will let you do this: You're a bad man for even joking about this
|
# ¿ Aug 26, 2014 23:37 |
|
xenilk posted:Hi guys, small brain fart ... http://railsless.blogspot.com/2011/08/difference-between-nil-empty-blank.html Chilled Milk fucked around with this message at 19:53 on Aug 31, 2014 |
# ¿ Aug 31, 2014 19:50 |
|
Dystram posted:I love working with Rails but I feel like a fraud, using gems for everything. No, you should be using gems where it's a good fit. But, having an idea of how it accomplishes things under the hood will expose you to common patterns and practices, as well as being able to work with that particular gem.
|
# ¿ Oct 15, 2014 18:16 |
|
Arachnamus posted:There's lots of styleguides out there you can use as a basis until you get the hang of it. That applies to user stories too. Well, I'm always interested in other devs' approaches and processes.
|
# ¿ Oct 22, 2014 23:12 |
|
I don't suppose there's a way to have basic http auth always reprompt for credentials?
|
# ¿ Oct 29, 2014 02:29 |
|
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 |
|
good jovi posted: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. Good to know, I've probably made this mistake on some of my earlier work
|
# ¿ Dec 2, 2014 22:06 |
|
Well I'm definitely interested in the assets gem. Especially since it purports to play nice with ActiveAdmin. I'm on my phone so I can't really dig into it but I'll check it out soon
|
# ¿ Dec 11, 2014 02:14 |
|
Yeah, RSpec + Capybara, with FactoryGirl and Timecop as the situation calls for. Simplecov generates a nice coverage report if you need to care about that. Coincidentally, I just learned Rails 4 Test Prescriptions came out and have a copy on the way, though it's through work and we have the holiday weeks off so it'll be awhile before I can dig into it myself. https://pragprog.com/book/nrtest2/rails-4-test-prescriptions
|
# ¿ Dec 19, 2014 19:14 |
|
EVGA Longoria posted:We use rspec mostly because my team prefers the syntax and the plugins available. As much as I would like to try the test first mindset I think coding as exploration is far too ingrained in my brain. Lately I have been at least switching over to specs once I have a rough outline of things and bouncing back and forth from there. I think that's probably the way to go in practice, for me at least. At least it feels better than the write everything and fart out some tests after I'm 99% sure it's working method.
|
# ¿ Dec 21, 2014 22:11 |
|
MasterSlowPoke posted:Is there a fast .xls reader for Ruby? I don't want to write anything or look at fonts or whatever, I'm just interested in the data. I've tried out Roo, but it's taking 3-4 minutes to load a very small (33x10) spreadsheet. Roo isn't the speediest but that's a still few orders of magnitude off. How are you parsing it?
|
# ¿ Jan 19, 2015 18:22 |
|
wins32767 posted:Anyone have any good resources for learning RSpec? Rails 4 Test Prescriptions
|
# ¿ Feb 3, 2015 15:28 |
|
Peristalsis posted:I keep running into the same problem with many-to-many relationships in Rails, and I've never really found a great solution. It deals with storing meaningful data in join tables, and I'm hoping there's something obvious I'm missing, not that it's just a limitation of rails. Have you tried futzing with #build? That should set up associations without persisting. http://api.rubyonrails.org/classes/ActiveRecord/Associations/ClassMethods.html
|
# ¿ Feb 26, 2015 20:20 |
|
Quick question, as I didn't get enough sleep last night Is there a way to do this purely in AR/SQL? code:
In my haze I initially wrote this code:
|
# ¿ Mar 5, 2015 20:58 |
|
Peristalsis posted:I have a comment and a question. Have you set a time zone? A generated application.rb will have this, fiddle as necessary code:
|
# ¿ Mar 17, 2015 17:10 |
|
Security-ish question. I'm currently working on a migration path for users of a few largely similiar legacy apps into this one new system. Since a user may have had an account on multiple sites and for Business Reasons the auth system has changed I need a mechanism for users to 'claim' their old accounts and merge the data into their new one. I've got the merging part in place and unit tested and whatnot but I wanted to make sure my idea for the workflow for it is sound. Basically, like how a password reset might go
|
# ¿ May 2, 2015 23:19 |
|
kayakyakr posted:Seems like Bob would get an email asking him to claim his account? Yeah, that's what I was going for. There'd be some warning text, and it could check that the user who originated it is the same one who clicked the link.
|
# ¿ May 3, 2015 04:33 |
|
You could also try rvm get stable --auto-dotfiles If you don't mind it mucking with your dotfiles and just want to be fairly sure it's getting loaded properly. It doesn't do anything obnoxious in my experience
|
# ¿ May 11, 2015 15:18 |
|
Gmaz posted:Already have the .ruby-version and .ruby-gemset files with proper versions inside and this is the relevant line in my .bash_profile: is RVM in your PATH ? code:
I switched to doing it that way since that how Heroku looks for the version, and I just like having fewer dotfiles in a project
|
# ¿ May 11, 2015 16:53 |
|
necrotic posted:Resque should be fine. I wouldn't use it at scale from past experiences, but if you go the ActiveJob route switching out backends is dead simple. Yeah definitely use ActiveJob if you can, the abstraction is well worth it. xenilk posted:I'm trying to wrap my head around the best solutions for multiple attachment from one form. That will work well enough if you don't need IE < v10. You'll need an attachment model that's has_many'd to your main model. The cleanest way would be something like this that just uses accepts_nested_attributes_for http://www.tkalin.com/blog_posts/multiple-file-upload-with-rails-3-2-paperclip-html5-and-no-javascript/
|
# ¿ May 15, 2015 03:11 |
|
|
# ¿ Apr 27, 2024 09:34 |
|
I've gotten that occasionally ever since they made the switch to keep test in-line with development.
|
# ¿ May 28, 2015 21:55 |