On 4 September 2015 at 15:32, Николай Спелый wrote:
> There are no errors given. Instead rails puts result of Chat.find_by(id:
> 6).chatusers, not result of "each", that's strange.
Now I look again that is not surprising. The method inspect outputs
to the server terminal
Hi.
I write
<%= Chat.find_by(id: 6).chatusers.each { |chat_user| chat_user.user.inspect
} %>
(There are three models: Chat, Chatuser, User)
Chat.find_by(id: 6).chatusers returns collection of table "chats_users" and
this is fine working.
But i can not get model user by each element of
On 4 September 2015 at 14:46, Николай Спелый wrote:
> Hi.
> I write
> <%= Chat.find_by(id: 6).chatusers.each { |chat_user| chat_user.user.inspect
> } %>
>
> (There are three models: Chat, Chatuser, User)
>
> Chat.find_by(id: 6).chatusers returns collection of table
There are no errors given. Instead rails puts result of Chat.find_by(id:
6).chatusers, not result of "each", that's strange.
class Chatuser < ActiveRecord::Base
self.table_name = "chats_users"
belongs_to :chat
belongs_to :user
validates :chat_id, presence: true
validates :user_id,
Great !
I already try write this logic but it not works. But when i copy-paste your
variant it's work.
So difference is in formating code, i write in one line, you write in three
lines.
That's nice for resolving problem, but why it's works in divided style of
ruby and not works in one-line
> On 2015-Sep-4, at 15:56 , Николай Спелый wrote:
>
> Great !
> I already try write this logic but it not works. But when i copy-paste your
> variant it's work.
> So difference is in formating code, i write in one line, you write in three
> lines.
> That's nice for
6 matches
Mail list logo