Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9269885
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T15:14:03+00:00 2026-06-18T15:14:03+00:00

I have been following Brandon Tilley’s instructions on creating a private message system and

  • 0

I have been following Brandon Tilley’s instructions on creating a private message system and want to modify the way the recipient of a private message is passed (from check-box to text-box).

In the view I have this:

<%= f.label :to %><br />
<%= f.text_field :to, placeholder: "Recip...(separated by commas)" %>

How can I accept input as a text input that passes an array of integers to the controller?

Extra Details:

Full View:

<h1>New Conversation</h1>

<%= form_for(@conversation) do |f| %>
  <div>
  <%= f.label :to %><br />
  <%= f.text_field :to, placeholder: "Recip...(separated by commas)" %>
  </div>
  <br />
  <%= f.fields_for :conversation do |c| %>
    <div>
      <%= c.label :subject %>
      <%= c.text_field :subject %>
    </div>
    <%= c.fields_for :messages do |m| %>
    <div>
    <%= m.label :body %><br />
    <%= m.text_area :body %>
    </div>
    <% end %>
  <% end %>

  <%= f.submit %>
<% end %>

Within the controller I have this:

def create
redirect_to users_path unless current_user
@conversation = UserConversation.new(params[:user_conversation])
@conversation.user = current_user
@conversation.conversation.messages.first.user = current_user
...

Within the model I have this:

  accepts_nested_attributes_for :conversation

  delegate :subject, :to => :conversation
  delegate :users, :to => :conversation

  attr_accessor :to
  *before_create :create_user_conversations*

private

def create_user_conversations
return if to.blank?

to.each do |recip|
  UserConversation.create :user_id => recip, :conversation => conversation
end
end
end

Edit: New Model:

def to
 to.map(&:user_id).join(", ") *stack too deep error*
end

def to=(user_ids)
  @to = user_ids.split(",").map do |recip|
  UserConversation.create :user_id => recip.strip, :conversation => conversation
end
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T15:14:04+00:00Added an answer on June 18, 2026 at 3:14 pm

    In the view:

    <%= f.label :to %><br />
    <%= f.text_field :to, placeholder: "Recip...(separated by commas)" %>
    

    In the model:

    attr_accessible :to
    attr_accessor :to
    
    before_create :create_user_conversations
    
    private
    
    to.split(",").each do |recip|
      UserConversation.create :user_id => recip, :conversation => conversation
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been following a HTML5 geolocation tutorial and want to modify the code
I am uploading a 24mb sql file and have been following the instructions to
I have been following this nice walkthrough for creating a grid using MVC contrib.
I have been following a tutorial on creating an iPhone app with multiple xibs.
I have been following the Operating System development tutorial on http://www.brokenthorn.com . Right now
I have been following this tutorial . Basically I want to take an address
I have been following a good tutorial about creating a Button skin that allows
I have been following along with the Aaron Skonnard videos on creating a WCF
I have been following the answer of this question: How to update existing object
I have been following the usage of JavaScript for the past few years, and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.