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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T20:10:42+00:00 2026-05-26T20:10:42+00:00

Question : How do I turn a calendar into a form where the dateselect

  • 0

Question: How do I turn a calendar into a form where the dateselect is rendered to match the calendar day instead of the current date?


What I’m trying to do:
I’d like to create a calendar that displays the cyclist’s workouts.

  • Create workouts within each calendar day, automatically rendering the workoutdate that matches the given day in the form

Each workout has many intervals. Each calendar day has one workout.

Plugins:
Extracted the table_builder.rb and calendar_helper.rb from https://github.com/p8/table_builder (both gem and plugin do not deploy with rails 3.1)

class WorkoutsController.rb

  def new
    @workout = Workout.new
    @date = params[:month] ? Date.parse(params[:month].gsub('-', '/')) : Date.today
    3.times do
      @workout.intervals.build
    end
  end

Workout.rb

  attr_accessible :workoutdate, :intervals_attributes
  has_many :intervals, :dependent => :destroy
  accepts_nested_attributes_for :intervals, :reject_if => lambda { |a| a[:interval_name].blank? }, :allow_destroy => true

Interval.rb

attr_accessible :interval_name, :workout_id
belongs_to :workout

views/workouts/new.html.erb

<div id ="calendar">
  <%= calendar_for @workouts, :year => @date.year, :month => @date.month do |calendar| %>
    <%= calendar.head('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday') %>
    <% calendar.day(:day_method => :workoutdate) do |date, workouts| %>
      <%= date.day %>
      <%= render 'form' %>
    <% end %>
  <% end %>
</div>

views/workouts/_form.html.erb

<%= nested_form_for @workout do |f| %>
  <%= f.error_messages %>
  <p>
    <%= f.label :workoutdate %><br />
    <%= f.date_select :workoutdate %>
  </p>
  <%= f.fields_for :intervals %>
  <p><%= f.link_to_add "Add interval", :intervals %></p>
  <p><%= f.submit "Submit" %></p>
<% end %>

views/workouts/_interval_fields.html.erb

<p>
  <%= f.label :interval_name, "Interval" %>
  <%= f.text_field :interval_name %>
  <%= f.link_to_remove "remove" %>
</p>

currently up on heroku http://billeee.herokuapp.com/workouts

  • 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-26T20:10:42+00:00Added an answer on May 26, 2026 at 8:10 pm

    Since you have the date available in the block of the day method, you should be able to pass it on to the partial like so:

    <% calendar.day(:day_method => :workoutdate) do |date, workouts| %>
      <%= date.day %>
      <%= render 'form', :date => date %>
    <% end %>
    

    Then you can make use of it within the form partial and set the date of the date select via the local variable you have just passed in:

    <%= f.date_select :workoutdate, :default => date %>
    

    As a note: this method seems a bit funny, since you’re rendering this form always for a particular day anyways. Why not send the date e.g. via a hidden input field? Is the user supposed to change the date? And if so, doesn’t that break the UI logic?

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

Sidebar

Related Questions

Simple question. What is the best way to turn a CGPoint into a GLKVector?
EDIT: Let me turn this into a straight SQL question... I have a varbinary(max)
Short question: I need to turn a dynamic image pulled from a database into
I asked a related question here: Clojure: How do I turn clojure code into
Like the question says, I wanted to know if it's possible to turn off
In this question I asked for a regex to turn /abc/def/ghi into { /abc/def/ghi
I have seen many versions of this question but the answers always turn into
the format can turn any type into a string, e.g (define lam-form (list `lambda
My question is related to Turn off buffering in pipe albeit concerning Windows rather
This may turn out to be an embarrassingly stupid question, but better than potentially

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.