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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T13:02:53+00:00 2026-05-22T13:02:53+00:00

I have a form I’m trying to set up … Users can have many

  • 0

I have a form I’m trying to set up …
Users can have many posts, and each post can have many people watching it.

The Watch model is set up polymorphically as ‘watchable’ so it can apply to different types of models. It has a user_id, watchable_id, watchable_type and timestamps as attributes/fields.

This is soley so that when people comment on a post, users watching the post can get an email about it.

What I’m trying to do is show the user a list of users that they can tag on each post, which is not problem. This is what I’m using right now

http://pastie.org/940421

<% semantic_form_for @update do |f| %>
      <%= f.input :subject, :input_html => { :class => 'short' } %>
      <%= f.input :site, :include_blank => false, :input_html => { :class => 'short' } %>
      <label>Tag Users (they will get notified of this update)</label>
       <%= f.input :user, :as => :check_boxes, :label => '&nbsp;', :wrapper_html => { :class => "radiolist clearfix" }, :for => :watch, :name => "Watch" %>

      <%= f.input :note, :label => 'Update'%>
      <% f.buttons do %>
        <%= f.commit_button :button_html => { :class => 'submit' } %>
      <% end %>
    <% end %>

The problem with this, is that when you go to edit an update/post … all the checkboxes are prechecked … I want it to pre-check only users who are currently watching the post.

To further clarify … this is the hacky way I’m getting it to do what I want right now

<ul class="radiolist clearfix">
<% @users.each do |user| %>
    <li>
    <%= check_box_tag 'user_ids[]', user.id, @watches.include?(user.id) ? true : false -%>
    <%= h user.name -%>
    </li>
<% end %>
</ul>

where @watches is just an array of user ids

@watches = @update.watches.map{|watcher| watcher.user_id}
  • 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-22T13:02:54+00:00Added an answer on May 22, 2026 at 1:02 pm

    For anyone else having the same issue:

    <%= f.input :some_input, :as => :boolean, :input_html => { :checked => 'checked' } %>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have form that displays several keywords (standard set of choice lists that changes
I have a form with many input fields. When I catch the submit form
I have a form in which people will be entering dollar values. Possible inputs:
I have a form element that contains multiple lines of inputs. Think of each
I have form with 2 radio buttons but both of the radio buttons can
I have form that uploads file's perfectly, with a post-page-refresh-form. However I have ajaxiefied
I have form submission doing a post back. The controller action accepts the values
I have Form as <form name=selectdoctype method=post action= id=selectdoctype> <table style=border:none;> <tr><td colspan=2> (<span
I' have form that user can select a color. I'm writing that color to
I have Form Designer web application, in which I need to post the controls

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.