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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T17:10:19+00:00 2026-05-29T17:10:19+00:00

In my calendar application the date is stored as a text_field = text_field :task_time,

  • 0

In my calendar application the date is stored as a text_field

  = text_field :task_time, :day, :value => display_date(@date), :id => "date-n"

I read this date in the controller’s index method but then am pre-generating default time as today in the model:

private

   def generate_task_time

   self.task_time = Time.now if self.task_time.nil?

   end

I need to change it and set default task_time to the time currently displayed in the calendar, but am getting undefined local variable or method `params’ error when trying to read it in the model: convert_to_string(params[:task_time]

Is it possible to do it in the model at all or is it better to remove generate_task_time and do everything in the controller?

Any suggestion on the syntax –

DateTime.strptime("#{params[:date]}")

or

convert_to_string(params[:task_time]) unless params[:task_time].nil?
  • 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-29T17:10:25+00:00Added an answer on May 29, 2026 at 5:10 pm

    params is an instance method on the controller, so you won’t have access to it in the model. You can pass the value of params[:task_time] to the model, though:

    task.task_time = convert_to_string(params[:task_time]) if params[:task_time]
    

    It’s perfectly valid to set attributes on the model from the controller. This is a common Rails pattern for updating the model attributes in a controller action:

    if model.update_attributes(params[:model])
      # do something success-y
    else
      # do something fail-y
    end
    

    But if you start doing too much in the controller, you get tied up with the request lifecycle and have a hard time testing your actual business logic. It’s always about balance!

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

Sidebar

Related Questions

I m using a rich:calendar to display Date in my application But some how
I have a calendar feed (.ics) available from my application, but it's quite large
I'm working on a stored procedure for a calendar application. Each event in the
On the iPhone and iPod Touch the calendar application changes the icon ever day
I have a Grails application I created a Gregorian Calendar GMT date. The time
Currently I am working on Calendar Application for iPhone. In this project i have
in my application i need to implement calendar concept.i found this site http://blog.webscale.co.in/?p=244&cpage=1#comment-827 and
I am developing an application which needs the current date from the device, but
I made an simple application using jquery fullcalender. But my today date is not
I am creating a calendar application. In the Events table, there are two columns,

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.