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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T01:55:39+00:00 2026-06-06T01:55:39+00:00

I have been working on this for few hours and got stuck, so how

  • 0

I have been working on this for few hours and got stuck, so
how to get menu selection using database, db using model ZigZagRotation?

<%= form_for([@user, @user.calories_journals.build]) do |f| %>
  <%= render 'shared/error_messages', object: f.object %>
  <%= f.label :cj_date, "Date Begins:" %>
  <%= f.text_field :cj_date %>
  <%= f.label :no_of_cycles, "Number of Cycles:" %>
  <%= f.text_field :no_of_cycles %>      
  <%= f.label :zig_zag_type, "Zig Zag Rotation Type:" %>
  <%= f.select :zig_zag_type, ZigZagRotation.all.collect {|z| [z.title, z.id ] } %> 
  <%= f.submit "Generate Calories Journals", class: "btn btn-large btn-primary" %>
<% end %>

The line below shows empty details in menu selection box instead of populated list.

<%= f.select :zig_zag_type, ZigZagRotation.all.collect {|z| [z.title, z.id ] } %> 

:zig_zag_type is attr_accessible under ZigZagRotation model and once it is selected I wish the value to be stored in :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-06-06T01:55:40+00:00Added an answer on June 6, 2026 at 1:55 am

    I am assuming that you are working with two different and related models (ZigZagRotation and AnotherModel for example).

    If you want to display the zig_zag_type attribute and save its id in the AnotherModel foreign key (zig_zag_id for example), creating the relationship between them, you can do something like the below:

    <%= f.collection_select(:zig_zag_id, ZigZagRotation.all, :id, :zig_zag_type , {:include_blank => 'Select Type'} ) %>
    

    You can find more information here.
    I hope it helps…

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

Sidebar

Related Questions

I've been trying to get this working for a few hours now. I have
I've been working on this problem for a few hours and have used many
i have been working on this sub-menu for 8 hours now, the last little
I have been stressing about this for a few hours and I cannot get
So I have been working on this for a few days now, and I
Have been working on this question for a couple hours and have come close
I have been working on this for days but I don't get it so
I have been working on this for 24 hours now, trying to optimize it.
I've been trying to get this horizontal navigation sorted for the past few hours
I have been working on this for the past 5 hours. For some reason

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.