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
enki42
Jun 11, 2001
#ATMLIVESMATTER

Put this Nazi-lover on ignore immediately!
It really depends on what approach to multitenancy you want to take. If you're using scoping, you will need to make some sort of script that goes through the following steps:

  • Extract a backup from Heroku
  • Import the backup into a staging database on your local machine
  • Set the site id on all multitenanted tables to whatever site id you're working with
  • Repeat for each of your clients

If you're using schemas to seperate data, you could take a similar approach, but move tables to new schemas with ALTER TABLE after moving them over.

In any case, it's not going to be a trivial migration and you should plan for some downtime when doing it.

To be honest, if expanding beyond 5-10 sites seems like a possibility, and particularly if you want some interaction between different clients, I would probably look into using a library from the start. Getting apartment up and running really isn't all that complicated (set up a config file, and remember to use rake apartment:migrate instead of rake db:migrate and you're set.)

Adbot
ADBOT LOVES YOU

NotShadowStar
Sep 20, 2000
I'm heading to Seattle in mid-January, staying with friends and getting settled. I can't seem to find much about the area ruby-wise except Seattle.rb and a rails meet up. Can someone tell me what it's like around that area for rails and-or ruby work?

Cocoa Crispies
Jul 20, 2001

Vehicular Manslaughter!

Pillbug

NotShadowStar posted:

I'm heading to Seattle in mid-January, staying with friends and getting settled. I can't seem to find much about the area ruby-wise except Seattle.rb and a rails meet up. Can someone tell me what it's like around that area for rails and-or ruby work?

Send Eric or Ryan an email if you don't hear from seattlerb guys here.

Trying seattlerb's hack night concept in Miami: http://www.meetup.com/miamirb/events/43260922/

Pardot
Jul 25, 2001




Be advised with the multi-schema approach: when you start getting into the several thousand relation (each schema gets its own copies of each table) range, pg_dump breaks and makes everyone sad.

Deus Rex
Mar 5, 2005

Is ActiveResource really as goddamn slick as it seems? Automatically map REST resources from an external API to models in my application? :aaa:

Cocoa Crispies
Jul 20, 2001

Vehicular Manslaughter!

Pillbug

Deus Rex posted:

Is ActiveResource really as goddamn slick as it seems? Automatically map REST resources from an external API to models in my application? :aaa:

Yes*

*if you are consuming a public API from 37signals because nobody else uses ActiveResource.

Deus Rex
Mar 5, 2005

BonzoESC posted:

Yes*

*if you are consuming a public API from 37signals because nobody else uses ActiveResource.

what do you mean by this? as far as I can tell it doesn't require ActiveResource on the web service's end, just REST resources with JSON or XML representations. the big caveat I see to ActiveResource is that there's no baked-in OAuth support, and almost every interesting public-facing REST API (Twitter, Flickr) requires OAuth

Cocoa Crispies
Jul 20, 2001

Vehicular Manslaughter!

Pillbug

Deus Rex posted:

what do you mean by this? as far as I can tell it doesn't require ActiveResource on the web service's end, just REST resources with JSON or XML representations. the big caveat I see to ActiveResource is that there's no baked-in OAuth support, and almost every interesting public-facing REST API (Twitter, Flickr) requires OAuth

Every time I've used it's seemed like more work than just grabbing a gem for the service.

8ender
Sep 24, 2003

clown is watching you sleep
Also the third option, HTTParty:
http://httparty.rubyforge.org/

This gem is all sort of fun to use.

Cocoa Crispies
Jul 20, 2001

Vehicular Manslaughter!

Pillbug
So Heroku is deprecating "cron" in favor of daily, hourly, and decaminutely commands. Is there a good way to turn the hourly version of these into something cron-like, with day-of-week/day-of-month matching, de-repetition, etc.?

Pardot
Jul 25, 2001




BonzoESC posted:

So Heroku is deprecating "cron" in favor of daily, hourly, and decaminutely commands. Is there a good way to turn the hourly version of these into something cron-like, with day-of-week/day-of-month matching, de-repetition, etc.?

If you want super fine control, the best way is always going to be a clock process type in Procfile and something like clockwork. The obvious downside is that it's an additional dyno, so it's not free.

If you're using the scheduler addon, and want something different than what it offers you have some tradeoffs. The important thing to keep in mind is that it makes it's best effort to call your app every [whatever] time period, but it can slip. So if you keep a table of job types and the next time they are supposed to run. Then have your scheduler process check for which ones have a date less than now, run them, and update their next time.

Cocoa Crispies
Jul 20, 2001

Vehicular Manslaughter!

Pillbug

Pardot posted:

If you want super fine control, the best way is always going to be a clock process type in Procfile and something like clockwork. The obvious downside is that it's an additional dyno, so it's not free.

If you're using the scheduler addon, and want something different than what it offers you have some tradeoffs. The important thing to keep in mind is that it makes it's best effort to call your app every [whatever] time period, but it can slip. So if you keep a table of job types and the next time they are supposed to run. Then have your scheduler process check for which ones have a date less than now, run them, and update their next time.

code:
  desc 'Daily stuff'
  task :daily => [
                  :daily_mail,
                  :weekly_mail,
                  :monthly_mail
                 ]

  task :daily_mail do
    PicoMailScheduler.daily_dispatch
  end

  task :weekly_mail do
    next unless Time.now.sunday?
    PicoMailScheduler.weekly_dispatch
  end

  task :monthly_mail do
    next unless Time.day == 1
    PicoMailScheduler.monthly_dispatch
  end
Look sane?

Adahn the nameless
Jul 12, 2006
Ruby had a reputation for being impractical to use on a Windows box because of lagging apis or whatever. Is that still true? If so, does Ubuntu keep pace fine?

Cocoa Crispies
Jul 20, 2001

Vehicular Manslaughter!

Pillbug

Adahn the nameless posted:

Ruby had a reputation for being impractical to use on a Windows box because of lagging apis or whatever. Is that still true? If so, does Ubuntu keep pace fine?

Ruby probably still sucks on Windows, but it's just fine on Ubuntu.

Pardot
Jul 25, 2001




BonzoESC posted:

code:
  desc 'Daily stuff'
  task :daily => [
                  :daily_mail,
                  :weekly_mail,
                  :monthly_mail
                 ]

  task :daily_mail do
    PicoMailScheduler.daily_dispatch
  end

  task :weekly_mail do
    next unless Time.now.sunday?
    PicoMailScheduler.weekly_dispatch
  end

  task :monthly_mail do
    next unless Time.day == 1
    PicoMailScheduler.monthly_dispatch
  end
Look sane?

That's pretty good, but it doesn't solve the issue if scheduler is down for an entire sunday. If instead you set the next time to run the weekly_mail task, when scheduler is back up on monday, you will know you still need to run that task.

That said, it's extremely unlikely that scheduler would be down for an entire sunday but there is nothing special about scheduler—it's just a heroku app.

Cocoa Crispies
Jul 20, 2001

Vehicular Manslaughter!

Pillbug

Pardot posted:

That's pretty good, but it doesn't solve the issue if scheduler is down for an entire sunday. If instead you set the next time to run the weekly_mail task, when scheduler is back up on monday, you will know you still need to run that task.

That said, it's extremely unlikely that scheduler would be down for an entire sunday but there is nothing special about scheduler—it's just a heroku app.

Yeah, this is just a short-term thing; once we start doing recurring billing we'll probably move to clockwork or something else more robust.

Nybble
Jun 28, 2008

praise chuck, raise heck
If you have any of the following problems:

  • "rails server" doesn't work.
  • "gem install <any>" doesn't work.
  • "rake db:migrate" doesn't work

And you are completely confused by the problem and the error codes don't make sense... Uninstall and reinstall XCode.

A shameful amount of times, this has worked for me. Very frustrated with Apple right now; tying their compilers to the health of your XCode installation is absolutely painful, especially since my download speeds suck.

Novo
May 13, 2003

Stercorem pro cerebro habes
Soiled Meat

Deus Rex posted:

Is ActiveResource really as goddamn slick as it seems? Automatically map REST resources from an external API to models in my application? :aaa:

I spend more time fighting with ActiveResource than any other part of Rails. Of course, I'm trying to make it do crazy things like use non-numeric IDs. I have enough trouble getting it to work between two Rails apps, I wouldn't even bother trying it against a third party API.

Cocoa Crispies
Jul 20, 2001

Vehicular Manslaughter!

Pillbug

Nybble posted:

A shameful amount of times, this has worked for me. Very frustrated with Apple right now; tying their compilers to the health of your XCode installation is absolutely painful, especially since my download speeds suck.

http://speakerdeck.com/u/bryce/p/getting-started-with-ruby-and-rails

The short version is: use http://git.io/osxgcc to install GCC, http://git.io/rbenv (and ruby-build) to install Ruby, Bundler to manage gems with your Rails projects, and http://pow.cx as your developer-mode app server.

Pardot
Jul 25, 2001




I've never understand why pow is useful :saddowns:

Cocoa Crispies
Jul 20, 2001

Vehicular Manslaughter!

Pillbug

Pardot posted:

I've never understand why pow is useful :saddowns:

My current customer has two apps that talk to each other. Whenever I cloned them from github, I just ln -s `pwd` ~/.pow in each one's folder, set the API_URL in the settings file of one of them, and that's pretty much it.

It's easier for me to set up on a new machine than Passenger, does the right thing with rbenv (and tried to with rvm but wayne :argh:), and tbqh I just like hitting a .dev url and having the app run.

Nybble
Jun 28, 2008

praise chuck, raise heck

BonzoESC posted:

http://speakerdeck.com/u/bryce/p/getting-started-with-ruby-and-rails

The short version is: use http://git.io/osxgcc to install GCC, http://git.io/rbenv (and ruby-build) to install Ruby, Bundler to manage gems with your Rails projects, and http://pow.cx as your developer-mode app server.

I love you. Awesome info, all of it.

Cocoa Crispies
Jul 20, 2001

Vehicular Manslaughter!

Pillbug

Nybble posted:

I love you. Awesome info, all of it.

I actually tested all that in Ubuntu too. Not my first choice ( supremacy), but easily my second.

Bob Morales
Aug 18, 2006


Just wear the fucking mask, Bob

I don't care how many people I probably infected with COVID-19 while refusing to wear a mask, my comfort is far more important than the health and safety of everyone around me!

Pardot posted:

I've never understand why pow is useful :saddowns:

I just use passenger plus the preference Pane. We have 20 apps and it's easier than starting whatever one I need to work on for five minutes. Drag and drop the folder of the project onto the pane and bam.

Pardot
Jul 25, 2001




I guess that's the answer, both to pow and passenger pref pane: You have several apps that you need running all the time. I just work on one at a time, so I don't need that.

Does either of them support Procfile to get your workers, clock, etc, up and running too?

Cocoa Crispies
Jul 20, 2001

Vehicular Manslaughter!

Pillbug

Pardot posted:

I guess that's the answer, both to pow and passenger pref pane: You have several apps that you need running all the time. I just work on one at a time, so I don't need that.

Does either of them support Procfile to get your workers, clock, etc, up and running too?

No, but if you know node.js ( :barf: ) it wouldn't be that hard in pow.

8ender
Sep 24, 2003

clown is watching you sleep
Does anyone know of a good gem for a mailing list?

Ideally i'd love something that can be a forum and mailing list at once, so the list can be searched, but that might be a pipedream. I have something already setup like that using vbulletin and a mailing list integration plugin but it is disgustingly hackly and i'd like to move this site to pure rails in the future.

Cocoa Crispies
Jul 20, 2001

Vehicular Manslaughter!

Pillbug

8ender posted:

Does anyone know of a good gem for a mailing list?

Ideally i'd love something that can be a forum and mailing list at once, so the list can be searched, but that might be a pipedream. I have something already setup like that using vbulletin and a mailing list integration plugin but it is disgustingly hackly and i'd like to move this site to pure rails in the future.

I'd just use MailChimp for the mailing list, and maybe use some crummy blog plugin to put it on your site with comments and such. MailChimp does RSS-to-email if you want to push mails out with your blog editor.

hmm yes
Dec 2, 2000
College Slice
There are plenty of mailchimp gems. One of them must let you poll your subscriber list for search.

Cocoa Crispies
Jul 20, 2001

Vehicular Manslaughter!

Pillbug

atastypie posted:

There are plenty of mailchimp gems. One of them must let you poll your subscriber list for search.

I suspect he meant having the posts searchable(?), so you could just write a 15-minute blog and point thinkingsphinx or pg_search at it for searching, and mailchimp at it for RSS-to-campaign.

8ender
Sep 24, 2003

clown is watching you sleep
I should clarify: I mean the type of mailing list where lots of people can contribute and it's mailed to everyone on the list. I know, old school, but these people are old and love their mailing lists.

I'm trying to put together a community type website for them and jam a mailing list/forum onto it without reinventing the wheel.

Mental Filler
May 5, 2007

She can ride or walk
either leave it or love it
Amateurish RoR Q here: I'm trying to include a module called ModuleTest (lib/module_test.rb) in my controller by using
pre:
include ModuleTest
but it is just giving me the NameError "uninitialized constant TestModule". Am I missing some obvious step? :(

hmm yes
Dec 2, 2000
College Slice

BonzoESC posted:

I suspect he meant having the posts searchable(?), so you could just write a 15-minute blog and point thinkingsphinx or pg_search at it for searching, and mailchimp at it for RSS-to-campaign.

I don't read threads, I only post in them

ZanderZ
Apr 7, 2011

by T. Mascis
Need a refresher in object oriented programing. When working with spec, when am I supposed to use an "end" statement? Here is what I've been doing.

describe "GET 'stuff'" do

it "should have some stuff" do
.
.
.
end

it "should have some more stuff" do
.
.
.
end

it "should have the rest of the stuff" do
.
.
.
end
end

Is this the right format for end statements? Each "it should do" statement has an end, and the final end statement ends the description. Do I have it right?

Pardot
Jul 25, 2001




Yes. While I love rspec, it's exceedingly complicated, so I'd focus learning OO not from how rspec works, but the code you're testing. Treat the rspec as incantations for now.

If you're interested though, the do..end placement doesn't have much to do with OO directly. Both describe and it are methods. They take one argument—a string that is the description—and a block. The block is code that is either surrounded by do...end or curly braces.

ZanderZ
Apr 7, 2011

by T. Mascis

Pardot posted:

Yes. While I love rspec, it's exceedingly complicated, so I'd focus learning OO not from how rspec works, but the code you're testing. Treat the rspec as incantations for now.

If you're interested though, the do..end placement doesn't have much to do with OO directly. Both describe and it are methods. They take one argument—a string that is the description—and a block. The block is code that is either surrounded by do...end or curly braces.

Ok, this clears things up a lot. I was overcomplicating rspec in my head as if, "It can't be this simple."

hepatizon
Oct 27, 2010

Mental Filler posted:

Amateurish RoR Q here: I'm trying to include a module called ModuleTest (lib/module_test.rb) in my controller by using
pre:
include ModuleTest
but it is just giving me the NameError "uninitialized constant TestModule". Am I missing some obvious step? :(

Is it ModuleTest or TestModule?

Mental Filler
May 5, 2007

She can ride or walk
either leave it or love it

hepatizon posted:

Is it ModuleTest or TestModule?

I was really hoping this was the case and I was just an idiot but sadly it's the post that went wrong, it really is TestModule (and test_module.rb if that makes any difference).

The Journey Fraternity
Nov 25, 2003



I found this on the ground!

Mental Filler posted:

I was really hoping this was the case and I was just an idiot but sadly it's the post that went wrong, it really is TestModule (and test_module.rb if that makes any difference).

You still need to explicitly require the module.

require 'lib/test_module' at the top of your controller.

Adbot
ADBOT LOVES YOU

Mental Filler
May 5, 2007

She can ride or walk
either leave it or love it

The Journey Fraternity posted:

You still need to explicitly require the module.

require 'lib/test_module' at the top of your controller.

So you have to require the file and then include the contents? That makes sense.

The require works but trying to include TestModule causes the baffling error "undefined method `include'". I mean that seems like a fairly fundamental method to be missing, surely?

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