how did you get the id of the record in a hidden field? Thanks! I'm using devise and trying to assign an association between a User and an Organization upon registration.
You can use either one, there is no reason to use one or the other. The key is the readability of your code. Personally, I prefer "if not" because I find it easier to understand.
There are some tangential security issues with this, but they are outside the scope (no pun intended) of multitenancy. The most obvious one is any user can create a resource in another scope by simply POSTing a tenant_id other than his own. To prevent this hole, simply make sure the controller does not accept a tenant_id parameter.
Regardless, this is awesome stuff, well thought out, and extremely helpful. Thanks Ryan!
I'm using the example at the end of the video that just uses jquery-file-upload to upload direct to S3. It's all working fine but now I want to make the upload a child of a parent object.
I'm uploading files on the parent's new page. How do I pass the parent_id to the child object?
How to copy an existing images into Rails project in Rails 2.3.5.
For example I have one item it has some images, I am copying same item but here problem is how to copy existing images.Internally I am using paper clip gem for saving images.
I want to use warden in my Sinatra app, but I am lost in one particular thing. How can I call specific route on Sinatra in failure_app lambda? I mean something like SessionsController.action(:new) but with Sinatra app. I know that I can use something like
ruby
[302, {'Location' => '/session/new'}, []]
but this solution don't send env variable, so env['warden'].message can't work.
Thanks. What I was trying to do is not possible with Heroku at the moment: Sub-sub domains aren't possible on Heroku default domain (yourappname.herokuapp.com), and you need to use the custom record for that
The directory path for store.js.coffee in the Show Notes has the wrong label. It should be in the right place if you generated it. If you placed it there based on the show notes, it might not work.
Hmm, nice. I'd like to know how I can keep on using belongs_to though. My tableless model is actually connected to ActiveRecord models, as in episode 193 with articles.
Any new way to do this with rails 4 for instance ?
I rant into this recently and it turned out that Webrick was the culprit. On every request it appears Webrick was trying to do DNS reverse resolution. Our solution was to switch it to using thin but you can also modify webrick/config.rb.
Just want to say how great this addition has been to a project! I am doing alot of work with a SOAP API and when things go wrong the "live shell" has been awesome.
If you are using a FormBuilder, maybe you can prefer use this for generate the checkbox name. For example, if we have a form with nested forms for a has_many association and each of these need a category_ids collection of checkboxes calculate the name of these checkboxes can be a problem. So, I suggest use the object_name method of the FormBuilder object:
I'm using Rails 4, and after trying to import other files after a successful setup of foundation I'm still getting an error with the mixings... "File to import not found or unreadable: foundation/variables." whenever I add "@import "foundation/variables";" to any of the sass style files
not sure if this is relevant but did you set heroku up to use subdomains such as ***.myapp.com. You can set it up by using wildcard domains as per herokus documentation
If you'r planning on using this plugin for the sole purpose of multiple uploads you may want to hold off for awhile. this plugin supports all modern browsers and IE10 up but IE8 and IE9 still total about 25% of browser usage across the globe.
Did you ever figure this out? I'm also looking for a non-devise authentication solution for mobile apps.
I ended up using:
Hope that helps.
How does this compare with a gem like https://github.com/dsaronin/milia? Is there a multi-tenancy gem that works with Mongoid?
Don't forget
.includes(:owner, :trackable)
Dude, thank you so much for commenting out the collection.fetch({reset: true}). I've been searching hours for this solution. Thank you so much :)
how did you get the id of the record in a hidden field? Thanks! I'm using devise and trying to assign an association between a User and an Organization upon registration.
Good One. Helped me a lot to get started with implementing authentication as I am a newbie to Ruby. Thanks a lot.
Agreed!
Very helpful screencast! There are several Rails 4 helper methods for this and similar form building: https://github.com/rails/rails/blob/master/actionview/lib/action_view/helpers/form_options_helper.rb
Though doing it using Ryan's way allows for infinite flexibility.
Both methods of setting hash values work the same, it's a matter of style preference.
Thanks for pointing this out, it helped me get this working in Rails 4.
Rails Guides have a short comment on this: http://guides.rubyonrails.org/association_basics.html#choosing-between-has-many-through-and-has-and-belongs-to-many
Thanks!!! The url shortener advice helped.
Great episode as usual. I love how you test everything. Moving the permissions into a model is definitely the way to go.
You can use either one, there is no reason to use one or the other. The key is the readability of your code. Personally, I prefer "if not" because I find it easier to understand.
Correct. Ryan has a typo in his code...it should be:
<%= image_tag painting.image.url(:thumb).to_s %>
NOT: <%= image_tag painting.image_url(:thumb).to_s %>
Related Post On Stack Overflow
Wonderful episode!
There are some tangential security issues with this, but they are outside the scope (no pun intended) of multitenancy. The most obvious one is any user can create a resource in another scope by simply POSTing a tenant_id other than his own. To prevent this hole, simply make sure the controller does not accept a tenant_id parameter.
Regardless, this is awesome stuff, well thought out, and extremely helpful. Thanks Ryan!
Thanks Wayne, really good gem. It's working great for me.
How would I use it when the upload objects are children another object?
I can't see a way to pass any kind of
parent_id
to the child on creation.I'm using the example at the end of the video that just uses jquery-file-upload to upload direct to S3. It's all working fine but now I want to make the upload a child of a parent object.
I'm uploading files on the parent's
new
page. How do I pass theparent_id
to thechild
object?It looks like he doesn't support it anymore.
Hey, Ryan, we need cancan for Rais 4. Update it, please!
Hi Ryan,
How to copy an existing images into Rails project in Rails 2.3.5.
For example I have one item it has some images, I am copying same item but here problem is how to copy existing images.Internally I am using paper clip gem for saving images.
Thanks in advance.
I want to use warden in my Sinatra app, but I am lost in one particular thing. How can I call specific route on Sinatra in failure_app lambda? I mean something like SessionsController.action(:new) but with Sinatra app. I know that I can use something like
but this solution don't send env variable, so env['warden'].message can't work.
Thanks. What I was trying to do is not possible with Heroku at the moment: Sub-sub domains aren't possible on Heroku default domain (yourappname.herokuapp.com), and you need to use the custom record for that
http://stackoverflow.com/questions/17994288/subdomain-with-rails-and-herokuapp
+1
The directory path for store.js.coffee in the Show Notes has the wrong label. It should be in the right place if you generated it. If you placed it there based on the show notes, it might not work.
It should be
Can you point me to any resources on how/why/when to do this?
Can you expound a bit as to why
respond_to
isn't all that great?This can help i guess:
http://railscasts.com/episodes/22-eager-loading-revised
Hmm, nice. I'd like to know how I can keep on using belongs_to though. My tableless model is actually connected to ActiveRecord models, as in episode 193 with articles.
Any new way to do this with rails 4 for instance ?
Foundation seems to interfere with TinyMCE 4.x, does anybody experienced that?
Thanks! This works great.
Here is a presentation that says instead of
use
But the >< operator is not recognized by PostgreSQL? (Version 9.2)
EDIT: ah, later on it says it's going to be a 9.3 feature
I rant into this recently and it turned out that Webrick was the culprit. On every request it appears Webrick was trying to do DNS reverse resolution. Our solution was to switch it to using thin but you can also modify webrick/config.rb.
Just want to say how great this addition has been to a project! I am doing alot of work with a SOAP API and when things go wrong the "live shell" has been awesome.
If you are using a
FormBuilder
, maybe you can prefer use this for generate the checkbox name. For example, if we have a form with nested forms for a has_many association and each of these need a category_ids collection of checkboxes calculate the name of these checkboxes can be a problem. So, I suggest use theobject_name
method of theFormBuilder
object:Note that I use
f.object
instead of@product
too. I think this way is better for use with aFormBuilder
.Finally, as you can see, I use an input hidden for be sure always send a category_ids array, so, I don't need setup this field in the controller.
I hope you find it useful :)
Anybody got an idea how to generate a histogram in PDF?
Chart is not shown in pdf file generated by pdfkit gem..... anyone who solve this problem??
thanks.
I'm using Rails 4, and after trying to import other files after a successful setup of foundation I'm still getting an error with the mixings... "File to import not found or unreadable: foundation/variables." whenever I add "@import "foundation/variables";" to any of the sass style files
I'm having the exact same problem. Did anyone find a solution?
This worked for me...
Does anyone know how to get this working with nested routes? I'm having a lot of issues in my link_to code
The gem is outdated for rails 4. Better try for an alternative
not sure if this is relevant but did you set heroku up to use subdomains such as ***.myapp.com. You can set it up by using wildcard domains as per herokus documentation
https://devcenter.heroku.com/articles/custom-domains#wildcard-domains
I think you need to add
attr_accessor :skill_ids to it.
Nice railscast! One of my favorites. Your site is the best. I am using this webcast as the basis for deploying servers. Thanks again
Would you still recommend this or Factory Girl? https://github.com/thoughtbot/factory_girl/
If you'r planning on using this plugin for the sole purpose of multiple uploads you may want to hold off for awhile. this plugin supports all modern browsers and IE10 up but IE8 and IE9 still total about 25% of browser usage across the globe.
Stats: http://gs.statcounter.com/#browser_version-ww-monthly-201207-201307-bar
i had same trouble in rspec-rails 2.14.0.
Because of rspec-mocks syntax changed. 'allow' matcher can't use.
Only rename
:allow
to:other_name
, then the code works well.Is named_scope deprecated now in Rails 4.0? 'scope' still seems to work though