Hi David,

but what if you have a User with id #10 and a BizUser with id #10? I don't 
know much more about your app, but why don't you send an additional param 
like params["user_type"], that will provide an "user" or a "biz"? Or why 
don't you use a global unique identificator instead of rely on the "id" 
field? Or why don't you add an "U" or "B" before the id on your view (on 
the form, the "recipients" html field) - so at "create" you can dismember 
the id from the user type and use the correct model?

I got it. 
>
> def create 
>     recipients = User.where(id: params['recipients']) || 
> BizUser.where(id: params['recipients']) 
>     conversation = current_user.send_message(recipients, 
> params[:message][:body], params[:message][:subject]).conversation 
>     flash[:success] = "Message has been sent!" 
>     redirect_to conversations_index_path(conversation) 
>   end  
>

--
Daniel Loureiro
http://www.learnwithdaniel.com 

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/e13579a7-1248-4bd5-88ee-c202ef32c1d2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to