Note that there are some explanatory texts on larger screens.

plurals
  1. PORails + Ember.js + Devise freelance journalist app - data scoping
    primarykey
    data
    text
    <p>Apologies, I have been in ember.js-land for so long, I'm fumbling Rails + active_model_serializers JSON api basics. </p> <p>So let's say I'm a freelance journalist and am building an app where a writer can publish Articles to different Company-specific sites through a single user account. </p> <pre><code>Rails Relationships User has_many :company_memberships User has_many :companies, :through =&gt; :company_memberships Company has_many :company_memberships Company_membership belongs_to :user Company_membership belongs_to :company Article belongs_to :company_membership Article has_many :comments Comment belongs_to :article </code></pre> <p>I am using Rails 3+, Devise, Active_Model_Serializers, Ember-Data and Ember.js. </p> <p>I want to set up a flow where the user comes to the site, logs in (very easy using devise) and is redirected to a rails page where he can select which Company's dashboard he wants to go to (by just clicking on a link). </p> <p>Now comes the tricky part. When he clicks on a specific company's link, he should be directed to a Rails view that contains an ember app whose serialization scope is set to the current_company_membership or current_company and not just the current_user.</p> <p>How do I create a rails or active_model_serializers method that scopes data to just the current_company as dictated by current_company_membership, and then passes along this data to the ember app?</p> <hr> <p>Also, as a bonus, I need the name and email address of the current_user - how do I pass this information along to the ember app as well? I have seen <a href="http://say26.com/using-rails-devise-with-ember-js" rel="nofollow">this dude's</a> article, but have not been able to get it working when trying to scope data through just company_membership and not current_user. </p> <p>Any help would be awesome! I'll add more detail and code if need be, but I have a feeling I'm forgetting something pretty simple here. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload