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

  • Home
  • SEARCH
  • 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 9187863
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T19:52:40+00:00 2026-06-17T19:52:40+00:00

So basically I have a Book model that contains information like book title (string)

  • 0

So basically I have a Book model that contains information like

  • book title (string)
  • author (string)
  • description (text)
  • etc.

Now on the front end I added the capability of dynamically adding more author fields. In the form I named it book[coauthor], so if I add a second author, I’d have a field book[coauthor][name_0].

What I’d like to achieve is combine book[author] and all book[coauthor][name_i] to one big string and separate each name with ,. (i.e. so with book[author] being “Alice” and book[coauthor][name_0] being “Bob” I should get “Alice,Bob” saved in book[author] in DB)

First Question: At this point is it better to do it with Javascript or with Rails (in controller)?

Second Questiion: Currently I’m doing it in the Rails controller but got Can't mass-assign protected attribute 'coauthor'. However I don’t want to make it a real attribute since all I need is some processing before saving all the information to the author field. What should I do?

Thanks guys.

  • 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-17T19:52:41+00:00Added an answer on June 17, 2026 at 7:52 pm

    The first question is a bit loaded, and you might get some heated disagreements but the way I look at it is this. Not everybody runs with Javascript enabled, so I make sure I have a way to do everything through Rails myself.

    In this case, it’s actually quite easy.

    The first thing I recommend is to not send the coauthors as part of the params[:book]. Instead, send them separately as a params[:coauthors]. Then in your controller you can do this:

    @book = Book.new(params[:book])
    @book.author = ([@book.author] + [params[:coauthors]]).join(",")
    @book.save
    

    Actually, it may be better to update params[:book][:author] since that would work for both create and update. Either way, I hope that helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a phone-book program written in C++, that uses the MVC model, now
Basically I have a proof-of-concept application that is a digital recipe book. Each Recipe
So basically I have two classes, Book and Author . Books can have multiple
I have the following model: class Book(models.Model): title = models.CharField(max_length=100) quantity = models.IntegerField() in_stock
I have a model that contains an IEnumerable of a list of custom objects.
I basically have a program that filters records from one excel file to another
I basically have three tables, posts, images and postimages (this simply contains the ids
I basically have the following string in the format: A,B,C:D,E,F What I am trying
I basically have 7 select statements that I need to have the results output
I have a web page that has multiple tabs, which all do basically the

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.