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 4617258
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T02:05:56+00:00 2026-05-22T02:05:56+00:00

Users have many websites, and Websites have many Keywords. (Keywords being nested resources of

  • 0

Users have many websites, and Websites have many Keywords. (Keywords being nested resources of the Websites resource)

Right now, with the default scaffolding setup, it’s very tedious to add many keywords at once. I’d like a text area instead of a text field that allows users to type many keywords, each on their own line, and submit them all at once. The only input on the form is for the keyword’s “text” column.

How can I do this?

I can figure out things like params[:keyword][:text].split("\r\n").each do |text|, but I’m not sure how to interact it with the Rails form.

<%= form_for [@website, @keyword] do |f| %>
  <% if @keyword.errors.any? %>
    <div id="error_explanation">
      <h2><%= pluralize(@keyword.errors.count, "error") %> prohibited this keyword from being saved:</h2>

      <ul>
      <% @keyword.errors.full_messages.each do |msg| %>
        <li><%= msg %></li>
      <% end %>
      </ul>
    </div>
  <% end %>

  <div class="field">
    <%= f.label :text %><br />
    <%= f.text_area :text %>
  </div>

  <div class="actions">
    <%= f.submit %>
  </div>
<% 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-05-22T02:05:57+00:00Added an answer on May 22, 2026 at 2:05 am

    (Note: I originally stuck this on the original post as an edit, so I’ve instead copy and pasted it so it’s the best answer)

    Here’s what I ended up doing in the meanwhile. It’s sloppy (I’m a Ruby noob), but it saves the keywords that are valid and renders back “new” with a list of the failed keywords:

    # keywords_controller
    def create
        invalid_keywords = []
        valid_keywords = []
        params[:keyword][:text].split("\r\n").map(&:strip).delete_if {|text| text == ""}.each do |text|
          keyword = @website.keywords.new(:text => text.downcase)
          if keyword.save
            valid_keywords << keyword
          else
            invalid_keywords << keyword
          end
        end
    
        if invalid_keywords.empty? # All keywords saved
          redirect_to @website, :notice => "Keyword(s) added"
        else # These keywords didn't save
          @keyword = @website.keywords.new(:text => invalid_keywords.map(&:text).join("\r\n"))
          @errors = invalid_keywords.first.errors
          flash[:success] = "#{valid_keywords.count} keywords were saved"
          flash[:alert] = "#{invalid_keywords.count} keywords did not save (shown below)"
          render :action => "new"
        end
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my domain: Users have many Bills Bills have many BillItems (and therefore Users
I have an application with Users, Machines, and Tests. Users have many Machines and
In my web application we have many users.I want to set permission for each
I have 3 tables users(id,name),groups(id,name) and users_groups(user_id,group_id). users and groups have many to many
I am creating a web application that will have many users. Each user has
The following sql will return a count of how many users have played a
I've an application in the market and many users have reported that the app
Idea: I want to make smth like real time electronic blackboard. Many users have
I see many MVC implementations for websites have a single-entry point such as an
On my local setup I have a load of different CakePHP websites. I'm using

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.