Be careful not to cache pages which might be common to users with different timezones. Or use javascript to change the times on the client side.
@ryanb, can you please elaborate a bit more about the leaky before filter? It's convenient that time accepts a block so around filter fits in perfectly, but i was just curious about the leaky before filter comment.
There is a small issue with the caching mechanism you showed. If the user details is modified by another session , then the cache would not fetch the latest information. In short, there should be a way to invalidate this cache.
How to give size storage of tenant? Is it possible to check the actual size of the tenant through the Rails application? If so, can i get a detailed view such as how many size of tenant?
Authorisation:
and you should take a look to authorisation from scratch. it works perfectly for me,
but i'm still very interested to see what cancan2 will bring :)
I'm trying to set up Sidekiq to work with Monit, but it seems to be needing to cd to current_path before executing bundle exec. Does anyone know how to tell Monit to cd to my app's directory before executing the start command? The commands in Monit also fail if I try to start them without /usr/bin/env
check process sidekiq
with pidfile <%= current_path %>/tmp/pids/sidekiq.pid
start program = "/usr/bin/env bundle exec sidekiq -C <%= current_path %>/config/sidekiq.yml -P <%= current_path %>/tmp/pids/sidekiq.pid" as uid deployer and gid admin with timeout 90 seconds
stop program = "/usr/bin/env kill -s INT `cat <%= current_path %>/tmp/pids/sidekiq.pid`" as uid deployer and gid admin with timeout 90 seconds
if totalmem is greater than 800 MB for 2 cycles then restart # eating up memory?
group sidekiq
I figured it out. in my nginx.conf file, I didn't change "blog" to "myapp" in the upstream command - but i had done so in the second place in that file that needed editing. Thanks again, Ryan!!
@cpuguy83 You're absolutely right, that's one big advantage of clint-side MVC.'s
But after spending a year battling with Backbone, I'm just not a big fan. Backbone and javascript is a lot of fun, but I find sticking to mainly Ruby/Rails to be where I'm most productive.
By sticking with mostly Rails, you can avoid having to test/debug lots of JS, devising a strategy for sharing views between Rails and JS, logic duplication in Backbone models and Rails models, etc.
I think caching + utilizing Rails UJS + RJS (rails js templates) is a winning combo for many apps. That's why cache digests is sweet :-)
The screencast adn everyone's comments have really helped me through setting up the server. I feel a lot better about server setup, now.
Everything is working great - went through the whole screencast - the only difference for me is that I'm using mysql. Mysql is installed properly, and upon deploy, running the db migrations works and results in the tables being created in the database. So I know it's connected properly.
However, when I go to one of the URLs for that scaffolding (for me it was /users), I'm getting a "we're sorry, something went wrong" error.
The routes work perfectly locally. Not sure what the issues is because MySQL seems to be working and connected based on the migrations?
If anyone has any suggestions (or pointers to help debug these server errors), i would very much appreciate them.
Once again your provide timely info. Thanks!
I have a project with two sister schools. The sites are almost identical except for some small cosmetic changes, and they have different dynamic content. The users of each site should be able to login to the other site (but of course privileged accounts should only be privileged in the home site). I can see how to implement this based on your Railscast.
My question is can this be done with two domains instead of sub-domains? I would like to have siteA.com and siteB.com instead of siteA.domain.com and siteB.domain.com. Is this possible? How would I start? Or should I just maintain two sites and have some sort of joint login system (and how would I do that?)
One last possible thing might be a way to restrict users to specific tenants. So that a use can only log into one tenant. Maybe with some kind of authorizaton system like cancan??
Something's not working. Heroku outputs the "looking for faye" messages, but not my messages. Have followed your debug tips, but they don't help to solve the problem. Are you sure, the port
9292 on heroku is correct? I get:
Thanks Ryan, great as usual! I wonder if Heroku or Appfog have any issues around using Postgres Schemas e.g. limitations on the dev databases therein? I used scopes 2 years ago when I last did a multi-tenant app but at the time I wanted to make use of Schemas I have to say - it seems less fussy and more secure plus less likely to forget to scope data etc. Maybe I'll migrate the old site to this method (only 3 subdomains including www) if Heroku supports it...
Hi guys, It seems that Capistrano has in fact now removed the cap deploy:web:[action] tasks. Being that I'm very new to Capistrano, could anyone point me to some info on how to get that functionality back?
This is actually the problem caching is trying to solve. Instead of reading from your DB and rendering partials rails is smart enough to look for a cached file, which, if it exists, will be used for the response.
Only if information critical for the request has changed, will a new version be created.
Another good gem to check out is Settingslogic. While Figaro is easier to set up, Settingslogic allows nested configurations which feels for cleaner code.
Thanks Ryan!! this was exceptionally useful. The fact that you took the time to figure out how to this gem run server side was just great.
It would be good to see a follow up casts using custom css formatting and other interesting tricks. (ie how to handle timeouts, ignoring searching on specific columns).
But what is really useful in the casts are the gems we never heard of used in ways we did not realize were possible. ie charting was a great example
Had a sneaky error on the last step with the re-direct. All the parameters updated my record properly, but got the following error: wrong number of arguments (1 for 0), _steps_controller.rb:57:in `redirect_to_finish_wizard'.
I kept getting this when I tried to update my password:
ArgumentError in PasswordResetsController#update
comparison of Date with ActiveSupport::TimeWithZone failed
If you are interested in getting private_pub running on Heroku, consider heroku_private_pub on Github. Just configure and push it. And the readme includes some handy debugging tips at the end.
Don't forget that if you are going to use something like this in a secure environment (SSL) then you should get a wildcard certificate. Otherwise your clients will get certificate errors.
Hi I have a problem, only the first row of my table is the right chosen dropdown and the next rows are not.
Thank you for refactoring this code. The associated objects are especially useful rather than masking each attribute behind a method.
I was having the same thoughts as Travis!
Postgres isn't the only database that provides Schemas. You can achieve the same thing in Oracle with Schemas and Public Synonyms.
Be careful not to cache pages which might be common to users with different timezones. Or use javascript to change the times on the client side.
@ryanb, can you please elaborate a bit more about the leaky before filter? It's convenient that time accepts a block so around filter fits in perfectly, but i was just curious about the leaky before filter comment.
Hi Ryan,
There is a small issue with the caching mechanism you showed. If the user details is modified by another session , then the cache would not fetch the latest information. In short, there should be a way to invalidate this cache.
FYI, the & shortcut syntax for merging has been deprecated. Just use .merge instead.
https://github.com/rails/rails/commit/66003f596452aba927312c4218dfc8d408166d54
I've corrected the show notes, thanks for letting us know!
How to give size storage of tenant? Is it possible to check the actual size of the tenant through the Rails application? If so, can i get a detailed view such as how many size of tenant?
Any thoughts?
Notice if you deploy to heroku now, you'll receive a mail said "The database contains 24,706 rows, exceeding the plan limit of 10,000"...
I solve the problem. Thank you
still didn't found a way to do it, but the multi tenancy casts are a great help to succeed with my goals.
thanks so much to ryan for all the great episodes!
@4awre
there are several ways, look at this:
for Devise:
https://github.com/plataformatec/devise/wiki/How-To:--Isolate-users-to-log-into-a-single-subdomain
http://blog.plataformatec.com.br/tag/subdomain/
http://blog.plataformatec.com.br/tag/subdomain/
Authorisation:
and you should take a look to authorisation from scratch. it works perfectly for me,
but i'm still very interested to see what cancan2 will bring :)
great video, thanks!
One question though, how to display a standard message for "no results found"?
This doesn't seem to work if you are already redefining the logger.
I use the following in the configuration file in order to cycle log files...
Either of the following two lines will cause errors, the first on webrick startup the second on the first call to the logger
Seems the 'log_tags' method isn't defined
Hi, when I try to call the send_password_reset I get this error:
Does anyone can help me, please?
I'm trying to set up Sidekiq to work with Monit, but it seems to be needing to
cd
tocurrent_path
before executingbundle exec
. Does anyone know how to tell Monit tocd
to my app's directory before executing the start command? The commands in Monit also fail if I try to start them without/usr/bin/env
+1
I figured it out. in my nginx.conf file, I didn't change "blog" to "myapp" in the upstream command - but i had done so in the second place in that file that needed editing. Thanks again, Ryan!!
@cpuguy83 You're absolutely right, that's one big advantage of clint-side MVC.'s
But after spending a year battling with Backbone, I'm just not a big fan. Backbone and javascript is a lot of fun, but I find sticking to mainly Ruby/Rails to be where I'm most productive.
By sticking with mostly Rails, you can avoid having to test/debug lots of JS, devising a strategy for sharing views between Rails and JS, logic duplication in Backbone models and Rails models, etc.
I think caching + utilizing Rails UJS + RJS (rails js templates) is a winning combo for many apps. That's why cache digests is sweet :-)
The screencast adn everyone's comments have really helped me through setting up the server. I feel a lot better about server setup, now.
Everything is working great - went through the whole screencast - the only difference for me is that I'm using mysql. Mysql is installed properly, and upon deploy, running the db migrations works and results in the tables being created in the database. So I know it's connected properly.
However, when I go to one of the URLs for that scaffolding (for me it was /users), I'm getting a "we're sorry, something went wrong" error.
The routes work perfectly locally. Not sure what the issues is because MySQL seems to be working and connected based on the migrations?
If anyone has any suggestions (or pointers to help debug these server errors), i would very much appreciate them.
Once again your provide timely info. Thanks!
I have a project with two sister schools. The sites are almost identical except for some small cosmetic changes, and they have different dynamic content. The users of each site should be able to login to the other site (but of course privileged accounts should only be privileged in the home site). I can see how to implement this based on your Railscast.
My question is can this be done with two domains instead of sub-domains? I would like to have siteA.com and siteB.com instead of siteA.domain.com and siteB.domain.com. Is this possible? How would I start? Or should I just maintain two sites and have some sort of joint login system (and how would I do that?)
What to force cache to expire? for example when the list of items are updated?
There is a typo in the show notes, it's missing the underscore:
rake refinery:override view=refinery/_head
You question regarding heroku is answered here:
https://devcenter.heroku.com/articles/postgres-multiple-schema-support
Cheers, Kai
One last possible thing might be a way to restrict users to specific tenants. So that a use can only log into one tenant. Maybe with some kind of authorizaton system like cancan??
Something's not working. Heroku outputs the "looking for faye" messages, but not my messages. Have followed your debug tips, but they don't help to solve the problem. Are you sure, the port
9292 on heroku is correct? I get:
When I leave the port number off, there is no failure message anymore. (Still doesn't work though…)
Got it working on IE8/9 ?
Anyboy got this working on IE?
Thanks Ryan, great as usual! I wonder if Heroku or Appfog have any issues around using Postgres Schemas e.g. limitations on the dev databases therein? I used scopes 2 years ago when I last did a multi-tenant app but at the time I wanted to make use of Schemas I have to say - it seems less fussy and more secure plus less likely to forget to scope data etc. Maybe I'll migrate the old site to this method (only 3 subdomains including www) if Heroku supports it...
Ryan,
Did you know about (or borrow from) this?
https://github.com/yardstick/ssl_requirement
Hi guys, It seems that Capistrano has in fact now removed the cap deploy:web:[action] tasks. Being that I'm very new to Capistrano, could anyone point me to some info on how to get that functionality back?
Hi Luke,
This is actually the problem caching is trying to solve. Instead of reading from your DB and rendering partials rails is smart enough to look for a cached file, which, if it exists, will be used for the response.
Only if information critical for the request has changed, will a new version be created.
Hope this helps.
Nice, thanks Mark. Does anyone else have any other examples?
Another good gem to check out is Settingslogic. While Figaro is easier to set up, Settingslogic allows nested configurations which feels for cleaner code.
Have you managed to solve this problem Faraz? I'm having the same issue..
Thanks Ryan!! this was exceptionally useful. The fact that you took the time to figure out how to this gem run server side was just great.
It would be good to see a follow up casts using custom css formatting and other interesting tricks. (ie how to handle timeouts, ignoring searching on specific columns).
But what is really useful in the casts are the gems we never heard of used in ways we did not realize were possible. ie charting was a great example
Never mind I figured it out :)
Change:
$("#products").html("<%= escape_javascript(render("products")) %>");
To:
$("#products").hide();
$("#products").html("<%= escape_javascript(render("products")) %>").fadeIn(500);
Had a sneaky error on the last step with the re-direct. All the parameters updated my record properly, but got the following error: wrong number of arguments (1 for 0), _steps_controller.rb:57:in `redirect_to_finish_wizard'.
Using the Finish Wizard Path definition at: https://github.com/schneems/wicked it worked fine.
Thanks for a great tutorial!!
I kept getting this when I tried to update my password:
ArgumentError in PasswordResetsController#update
comparison of Date with ActiveSupport::TimeWithZone failed
Fixed it by doing this:
it's even better
unless I'm missing something important ^^
If you are interested in getting private_pub running on Heroku, consider heroku_private_pub on Github. Just configure and push it. And the readme includes some handy debugging tips at the end.
@chewmanfoo, I'm not sure but I'm guessing you're missing the css style and instantiating the behavior:
And then instantiate add the behavior to elements with the
.chzn-select
css class:Don't forget that if you are going to use something like this in a secure environment (SSL) then you should get a wildcard certificate. Otherwise your clients will get certificate errors.
Can someone explain how to get this working with mongoid?
many many thanks
anyone know what formtastic needs in the form to replace the collection_select for the first example (using Chosen). I have this:
f.input :change_set_revisions, :as => :select, :collection => ChangeSetRevision.all.sort_by(&:name).reverse
but it sticks with the normal multiple-select drop-down box. I do not get the javascript decoration.
The pdf mime type is added by default in Rails 3.2: http://edgeguides.rubyonrails.org/3_2_release_notes.html
So you no longer need to tell Rails about the PDF MIME type with the following line:
Mime::Type.register "application/pdf", :pdf
+1
Forgive a newbie. In ryans examples where do you put that code?
Thanks Ira..Time Saver
You either have to change the Facebook Site URL or you hosts file. To edit your hosts file when you want to work on your app locally:
sudo nano /etc/hosts
Add:
127.0.0.1 www.yourdomain.com
Save the hosts file
Restart your browser.
Restart rails using port 80:
rvmsudo rails s -p 80
Now when you go to www.yourdomain.com it should be hitting your local dev machine.