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
Chilled Milk
Jun 22, 2003

No one here is alone,
satellites in every home
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.

Adbot
ADBOT LOVES YOU

Chilled Milk
Jun 22, 2003

No one here is alone,
satellites in every home

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

Chilled Milk
Jun 22, 2003

No one here is alone,
satellites in every home
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

Chilled Milk
Jun 22, 2003

No one here is alone,
satellites in every home

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.

Chilled Milk
Jun 22, 2003

No one here is alone,
satellites in every home

Sitting Bull posted:

May I contact you off site? If so, what would the best method be?

PM or milkohol@gmail

Chilled Milk
Jun 22, 2003

No one here is alone,
satellites in every home
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

Chilled Milk
Jun 22, 2003

No one here is alone,
satellites in every home

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.

I'm thinking: OP would have resources, links to tutorials, and suggestions for setting up an environment. Probably mention hosting. A 2nd post would be a copy of my Digital Ocean deploy tutorial above.

Thoughts? Anything that'd need to be in the first set of posts that you'd like to see such as suggested gems or whatnot?

Go for it.

I could probably write up a quick guide/tips n tricks about Active Admin if there's any interest.

Chilled Milk
Jun 22, 2003

No one here is alone,
satellites in every home

kayakyakr posted:



I hate this. Requiring a front-end framework? These things are very easy to learn, I'd rather hire someone that can program that might not have experience with the framework and train them up than spend time looking for someone with just the right qualifications...

Welcome to the industry.

Chilled Milk
Jun 22, 2003

No one here is alone,
satellites in every home
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.

Chilled Milk
Jun 22, 2003

No one here is alone,
satellites in every home

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.

Your method of comparing time would work but it would be needlessly complicated unless it would achieve some purpose that I'm not understanding.

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:
Thread.new {
  loop do
    sleep 15.seconds # Just for testing
    image = SidebarImage.cycle_image
    puts "Cycling Sidebar Image: ##{image.position}: #{image.url}"
  end
}
in model:
code:
  def self.current
    @@current ||= first
  end

  def self.cycle_image
    if @@current == last
      @@current = first
    else
      @@current = find_by_position(@@current.position + 1)
    end
  end

Chilled Milk fucked around with this message at 19:04 on Feb 11, 2014

Chilled Milk
Jun 22, 2003

No one here is alone,
satellites in every home

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

Chilled Milk
Jun 22, 2003

No one here is alone,
satellites in every home
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.

Chilled Milk
Jun 22, 2003

No one here is alone,
satellites in every home

Popper posted:

This looks like the kind of code that if it breaks is terrible.
Why not just calculate the current image based on the time.

Something like
code:
  image_array[((Time.now.to_i - DateTime.now.midnight.to_i) / 15) % image_array.size]
Should return a different image every 15 seconds.

Yeah, that was my original idea. What I ended up going with was this (based on Cocoa Crispies answer):
code:
  class << self
    def current
      @@current = published.offset(seconds_into_cycle / time_per_image).first
    end

    def seconds_into_cycle
      Time.now.to_i % cycle_time
    end

    def cycle_time
      @@cycle_time ||= Rails.application.config.sidebar_image_cycle_time
    end

    def time_per_image
      cycle_time / published.count
    end
  end

Chilled Milk
Jun 22, 2003

No one here is alone,
satellites in every home

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:





Okay so this, as you can imagine, is all done via associations, child relationships, nested attributes, and some considerable finagling of the excellent cocoon gem. It's all working fairly well and people seem to like it, but now we have a new requirement: we need to be able to safe draft versions, track some level of revision history, and allow reversions to previous versions of items that are built with this content (this editor is part of a larger CMS and it can be attached to any number of models). poo poo.

I've looked into paper_trail and it doesn't look like it has a lot of support for saving a big cascade of nested models. I'm not against coding something up from scratch but I feel like someone must have solved this problem before. Does anyone have any suggestions for where to begin on something like this?

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.

Chilled Milk
Jun 22, 2003

No one here is alone,
satellites in every home
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

Chilled Milk
Jun 22, 2003

No one here is alone,
satellites in every home

Pardot posted:

code:
with first_milestones as
  (select stage_id, min(due_date) as first_date from milestones group by stage_id)

select stages.*, first_date from stages join first_milestones on stage_id = stages.id
http://sqlfiddle.com/#!15/c2007/5

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:
ID 	NAME 	FIRST_DATE
2 	a 	January, 10 2012 00:00:00+0000
1 	b 	January, 01 2012 00:00:00+0000
3 	c 	January, 19 2014 00:00:00+0000

Chilled Milk
Jun 22, 2003

No one here is alone,
satellites in every home

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.

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.

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.

Chilled Milk
Jun 22, 2003

No one here is alone,
satellites in every home

MALE SHOEGAZE posted:

In other news, I figured out that erb will let you do this:

code:
<%- 
def render_details(details)
  details.each do |k,v|
-%> 
    <details>
      <summary>
        <%= k.to_s %>
      </summary>
        <div style="padding-left:30px">
<%-   
          if v.class == Hash
            render_details(v)
          else 
-%>
            <%= v %>
<%-       end 
%> 
      </div>
    </details>
<%- 
  end 
end
render_details({omg: {look: "it's", at: :loving }, becky: { this: :bad, code: "!!!" } }  )
%>

You're a bad man for even joking about this

Chilled Milk
Jun 22, 2003

No one here is alone,
satellites in every home

xenilk posted:

Hi guys, small brain fart ...

I have two model functions that goes like this:

code:
  #return the active leases
  def active_lease
  	Lease.where("door_id = ? AND date_start <= now() AND date_end >= now()", self.id).first
  end

  #look if the door has any active lease/tenant
  def has_active_lease?
  	!self.active_lease.nil?
  end
It works fine, but am I right to think that "!self.active_lease.nil?" isn't elegant?
Well for starters you can use active_lease.present?

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

Chilled Milk
Jun 22, 2003

No one here is alone,
satellites in every home

Dystram posted:

I love working with Rails but I feel like a fraud, using gems for everything.

Should I try rolling my own functionality for lots of things rather than just installing a bunch of gems if I ever want to land a Rails dev job?

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.

Chilled Milk
Jun 22, 2003

No one here is alone,
satellites in every home

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.

Also don't forget that Rails is arranged in a very opinionated way and that extends to testing, too. Not everyone agrees with its defaults.

Most everyone agrees that more testing is better than less testing, and lots of people think TDD and BDD are good approaches. Beyond that it's a lot of nuance.

Would there be any value to me writing up the approach that I (and others) take with regard to Rails testing? There's no definitive approach but I find this one effective.

Well, I'm always interested in other devs' approaches and processes.

Chilled Milk
Jun 22, 2003

No one here is alone,
satellites in every home
I don't suppose there's a way to have basic http auth always reprompt for credentials?

Chilled Milk
Jun 22, 2003

No one here is alone,
satellites in every home
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.

Chilled Milk
Jun 22, 2003

No one here is alone,
satellites in every home

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

Chilled Milk
Jun 22, 2003

No one here is alone,
satellites in every home
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

Chilled Milk
Jun 22, 2003

No one here is alone,
satellites in every home
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

Chilled Milk
Jun 22, 2003

No one here is alone,
satellites in every home

EVGA Longoria posted:

We use rspec mostly because my team prefers the syntax and the plugins available.

It's not bad, but we never do test first. We end up writing tests at the end to hit about 80% coverage and go from there.

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.

Chilled Milk
Jun 22, 2003

No one here is alone,
satellites in every home

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?

Chilled Milk
Jun 22, 2003

No one here is alone,
satellites in every home

wins32767 posted:

Anyone have any good resources for learning RSpec?

Rails 4 Test Prescriptions

Chilled Milk
Jun 22, 2003

No one here is alone,
satellites in every home

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.

Here's a stripped down version of the current iteration:

code:
class ClassA
  has_many => :class_a_class_b
  has_many :class_b, :through => :class_a_class_b
end

class ClassB
  has_many => :class_a_class_b
  has_many :class_a, :through => :class_a_class_b
end

class ClassAClassB
  belongs_to :class_a
  belongs_to :class_b

  # database table class_a_class_b contains the following fields
  # class_a_id
  # class_b_id
  # some_other_attribute 
end

def some_method
  a = classA.new
  b = classB.new

  # If I do this, then there's no classA_classB object to populate with some_other_attribute, at 
  # least without saving first (which really isn't an option)
  a.class_bs << b
  puts a.class_bs.size                                                       # output = 1
  a.class_a_class_bs.size                                                    # output = 0; same 
                                                                             #  for b.class_a_class_b.size
  a.class_a_class_bs.first.some_other_attribute = "abc"                      # throws exception; 
end

def try_different_approach
  a = classA.new
  b = classB.new
  link = ClassAClassB.new
  link.class_a = a
  link.class_b = b
  link.some_other_attribute = "abc"
  a.class_a_class_bs << link
  b.class_a_class_bs << link

  # This works, but now I don't have the direct link between A and B, and doesn't inform
  # the main objects of the links at all.
  puts a.class_bs.size                                                      # output = 0
  puts a.class_a_class_bs.size                                              # output = 0
  # etc.
  # In this case, I'm also concerned about whether the link will even be saved when I save a or b.
end

def third_try
  a = classA.new
  b = classB.new
  link = ClassAClassB.new

  link.class_a = a
  link.class_b = b
  link.other_attribute = "abc"
  a.class_a_class_bs << link
  b.class_a.class_bs << link
  
  # Still doesn't hook up a -> b link, but at least is functional up to that point.
  puts a.class_a_class_bs.size                                              # output = 1
  puts b.class_a_class_bs.size                                              # output = 1
  puts a.class_bs.size                                                      # output = 0
  puts b.class_as.size                                                      # output = 0

  # However, even when I save a, it doesn't get the link to b without reloading.
  a.save
  puts a.class_bs.size                                                      # output = 0
  # Oddly, the other direction works fine.
  puts b.class_as.sizse                                                     # output = 1
  a.reload
  puts a.class_bs.size                                                      # output = 1
end

def desperate_attempt
  # Just hook everything up manually
  a = classA.new
  b = classB.new
  link = ClassAClassB.new
  link.class_a = a
  link.class_b = b
  link.other_attribute = "abc"
  a.class_a_class_bs << link
  b.class_a_class.bs << link
  a.class_bs << b
  b.class_as << a
  
  # That seems to work at first, but the link between a and b is actually separate from the explicit 
  # link object here.  So, when I save, I get this:
  a.save
  puts a.persisted?                                                         # output = true
  puts b.persisted?                                                         # output = true
  puts link.persisted?                                                      # output = true
  puts a.class_a_class_bs.size                                              # output = 2
end

So, is there a good way to do this for new records? I'd like to have confidence that when the clients use the returned objects I create, they can use the rails connections without reservation, but they also need to decide when (and whether) to save them to the database, so I can't do that for them.

Edit: If I could force the link between a and b to use the link object I've created, I think that would solve this. Is there a way to do something like
code:
a.class_b = b, :using => link
???

Have you tried futzing with #build? That should set up associations without persisting.
http://api.rubyonrails.org/classes/ActiveRecord/Associations/ClassMethods.html

Chilled Milk
Jun 22, 2003

No one here is alone,
satellites in every home
Quick question, as I didn't get enough sleep last night

Is there a way to do this purely in AR/SQL?
code:
    firms.joins(:countries).reject { |firm| firm.countries.map(&:alpha2).include?(country_code) }
Trying to only get records where NONE of the has_many'd records match a condition

In my haze I initially wrote this
code:
    firms.joins(:countries).where.not('countries.alpha2' => country_code)
But obviously that will still grab any record where any of the children don't match. Not a huge deal but it's nice to avoid farting up AR Collections by running enumerable methods on them

Chilled Milk
Jun 22, 2003

No one here is alone,
satellites in every home

Peristalsis posted:

I have a comment and a question.

We've been developing our main rails app for over a year now, sort of learning stuff as we go along. It's been interesting, sometimes frustrating, and often slow as we find our way through the gems and other tools. The other day, we got a request to do a prototype for a new app. Since we can share some functionality and general formatting, we just made it an extension of our current app to save time (we can split it out when we get actual specs and create a new design, etc.). We still needed to create new models and tables, set up some new screens, etc., but by re-using some of our current infrastructure, and by knowing Rails much better than we did at the beginning of our current app, we were able to put a demo together from design to implementation with about 6-8 person-hours of work. I think this is the first time I've really been able to appreciate and benefit from all the voodoo and shortcuts. I mean, we've been getting faster and better all along, but the difference between this effort and how long it took to really get our first app up and running really threw the speed of the tools and how far we've come into sharp relief.

And now my latest (minor) problem. Actually, it's been this way all along, just not important enough to worry about. The created_at dates in our test-server's objects are all off by 5 hours. (Prod might be the same, but it's harder to tell since we do have users legitimately running scripts late at night.) MySQL returns the correct current time and date if I query for it, the test server's time is correct, and Rails reports the correct time in console, but the created_at dates are clearly not being adjusted for time zone. How can every system report the correct time interactively, but still somehow conspire to get the created_at times wrong? Is there a special setting for row dates somewhere? Should I just try to move the university to England?

Have you set a time zone? A generated application.rb will have this, fiddle as necessary
code:
    # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
    # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
    # config.time_zone = 'Central Time (US & Canada)'

Chilled Milk
Jun 22, 2003

No one here is alone,
satellites in every home
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


  • User logs in, goes to Claim old account or w/e
  • User fills in the email address of the old account
  • System creates an AccountClaim record, with the user_id, email they input, and generates some random token with SecureRandom.urlsafe_base64
  • System mails out a link to the specified address with that token
  • User clicks link
  • System looks for an AccountClaim by that token, and probably makes sure it matches the user that is logged in
  • If found, system looks up old accounts by that email address and 'merges' them into the users current account, tosses the old records, and flags the AccountClaim as done.

Chilled Milk
Jun 22, 2003

No one here is alone,
satellites in every home

kayakyakr posted:

Seems like Bob would get an email asking him to claim his account?

That's fairly close to a reset password flow, which is fairly standard.

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.

Chilled Milk
Jun 22, 2003

No one here is alone,
satellites in every home
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

Chilled Milk
Jun 22, 2003

No one here is alone,
satellites in every home

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:

code:
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
Guess I'll try running the rvm get stable command.

EDIT: Ran the command, nothing changed.

is RVM in your PATH ?
code:
export PATH="$PATH:$HOME/.rvm/bin" # Add RVM to PATH for scripting
You also don't necessarily need .ruby-version or .ruby-gemset; you can specify them in your Gemfile like this



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

Chilled Milk
Jun 22, 2003

No one here is alone,
satellites in every home

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.

Is input file multiple (html5) + paperclip best/easiest way to go?

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/

Adbot
ADBOT LOVES YOU

Chilled Milk
Jun 22, 2003

No one here is alone,
satellites in every home
I've gotten that occasionally ever since they made the switch to keep test in-line with development. :shrug:

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