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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T20:08:56+00:00 2026-05-13T20:08:56+00:00

I am currently somewhat stuck figuring out an elegant solution to my following problem:

  • 0

I am currently somewhat stuck figuring out an elegant solution to my following
problem:

Let’s say I have the following classes:

class Event < ActiveRecord::Base
  belongs_to :reg_template, :class_name => "EmailTemplate"
  [...]
end

class EmailTemplate < ActiveRecord::Base
  has_many :events
  [...]
end

And a view that contains:

<%= f.collection_select(:reg_template_id, EmailTemplate.all, :id, :name) %>

What is the recommended way of processing this form field in an action
controller?

Having a 1:1 relationship between Event and EmailTemplate means that Rails
does not generate a reg_template_id and reg_template_id= method (as it would
do for a 1:n relationship), so attempts to read or assign this field will fail
with

unknown attribute: reg_template_id

when attempting to call

Event.update_attributes

Using

<%= f.collection_select(:reg_template, EmailTemplate.all, :id, :name) %>

instead also does not help much as it will fail with:

EmailTemplate(#70070455907700) expected, got String(#70070510199800)

I guess I must be missing something terribly obvious as I think is is rather
common to update a model instance with a reference to another object through a
collection_select.

  • 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-13T20:08:56+00:00Added an answer on May 13, 2026 at 8:08 pm

    If you have the column reg_template_id in the events table, then the following code should work:

    <%= f.collection_select(:reg_template_id, EmailTemplate.all, :id, :name) %>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Currently I have an algorithm which somewhat looks like web-spiders or file search systems
I'm currently writing a Rails app, and hit a somewhat strange quirk. I have
I am writing a somewhat complex game engine in Android. Currently I have a
I currently have a somewhat working version of what I need to be done,
Currently I have a service that downloads about 500 records of somewhat complex data,
I'm currently somewhat stuck getting a regular expression in Perl (taken from an earlier
I am currently following along with a somewhat questionable Django tutorial called A complete
I have a piece of Perl code somewhat like the following (strongly simplified): There
Currently, I'm working on a project where I have a server - client relationship
Currently I have 2 ways of displaying images in a cell, which way will

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.