RailsCasts Pro episodes are now free!

Learn more or hide this

Sijo K George's Profile

GitHub User: sijokg

Comments by Sijo K George

Avatar

Hi
Could you please share how you solved it? I have the same problem ie save additional field in join table.
Thanks

Avatar

Hi, I am using carrier wave for file upload

ruby
class ImageUploader < CarrierWave::Uploader::Base
  include CarrierWave::RMagick
  storage :file
  # This is a sensible default for uploaders that are meant to be mounted:
  def store_dir
    "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
  end
end

Here my question is how to specify the tenant.id like

"uploads/#{current_tenant.id}/#{model.class.to_s.underscore}
/#{mounted_as}/#{model.id}"

where current_tenant is a application controller helper method

Thanks

Avatar

Hi Ryan,
Thanks for this. I was trying to write a custom rake task , say sending email And this has to be run against each tenant schema. I wrote lib/tasks/mailer.rake

desc "send mail for conditions"
task send_email: :environment do
#conditions
puts 'HHHHHHHHHHHHHHHHhh'
end

But this gives me error: undefined method `strip' for :"Run db:migrate for each tenant":Symbol

I have the lib/tasks/multitenant.rake like below

`db_tasks = %w[db:migrate db:migrate:up db:migrate:down db:rollback db:forward]
namespace :multitenant do
db_tasks.each do |task_name|
desc :"Run #{task_name} for each tenant"
task task_name => %w[environment db:load_config] do
Tenant.find_each do |tenant|
puts "Running #{task_name} for tenant#{tenant.id} (#{tenant.subdomain})"
tenant.scope_schema {Rake::Task[task_name].execute}
end
end
end
end

db_tasks.each do |task_name|
Rake::Task[task_name].enhance(["multitenant:#{task_name}"])`

Please help

Avatar

Thanks Ryan for this episode. Yet to watch this. I would like to know whether this work with Ruby1.8.7?