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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T17:55:53+00:00 2026-05-24T17:55:53+00:00

I am looking to allow a user to update a model’s attributes through the

  • 0

I am looking to allow a user to update a model’s attributes through the model’s show page, then submit, to display updated attributes. :startdate and :enddate are in my attr_accesible list for the cart.rb model. Based on the log it looks like it is taking the enddate and startdate but isn’t setting it. Any thoughts? Thanks so much.

carts_controller.rb

def show
  @cart = Cart.find(params[:id])
end

def update
@cart = Cart.find(params[:id])
 respond_to do |format|
    if @cart.update_attributes(params[:cart])
      format.html { redirect_to(@cart, :notice => 'Dates Set.') }
      format.xml  { head :ok }
    end
  end
end

carts/show.html.erb

    <%= form_for @cart do %>
       From <%= text_field_tag :startdate %> </br>
       To <%= text_field_tag :enddate %>
       <%= submit_tag "Set Dates", :method => :put %>
    <% end %> 

    Rental Dates: <%= @cart.startdate %> <%= @cart.enddate %>

development.log

Started POST "/carts/42" for 127.0.0.1 at 2011-08-10 14:27:10 -0400
DEPRECATION WARNING: Setting filter_parameter_logging in ActionController 
is deprecated and has no longer effect, please set 'config.filter_parameters' 
in config/application.rb instead. (called from <class:ApplicationController> at
/Users/willdennis/rails_projects/spinlister/app/controllers/application_controller.rb:8)
Processing by CartsController#update as HTML
Parameters: {"utf8"=>"✓",   
"authenticity_token"=>"2RC9jfvbdUWtlT3OWnVd1OhW7WigUPYVoS5Quuwv2hQ=", 
"startdate"=>"08/10/2011", "enddate"=>"08/18/2011", "commit"=>"Set Dates", "id"=>"42"}
 [1m[35mCart Load (1.1ms)[0m  SELECT "carts".* FROM "carts" WHERE ("carts"."id" = 42)   
 LIMIT 1 Redirected to http://localhost:3000/carts/42 Completed 302 Found in 82ms


  Started GET "/carts/42" for 127.0.0.1 at 2011-08-10 14:27:10 -0400
  DEPRECATION WARNING: Setting filter_parameter_logging in ActionController is       
  deprecated and has no longer effect, please set 'config.filter_parameters' in  
  config/application.rb instead. (called from <class:ApplicationController> at 
/Users/willdennis/rails_projects/spinlister/app/controllers/application_controller.rb:8)
   Processing by CartsController#show as HTML
   Parameters: {"id"=>"42"}
   [1m[36mCart Load (1.3ms)[0m  [1mSELECT "carts".* FROM "carts" WHERE ("carts"."id" = 42) LIMIT 1[0m
   [1m[35mLineItem Load (0.4ms)[0m  SELECT "line_items".* FROM "line_items" WHERE ("line_items".cart_id = 42)
   [1m[36mBike Load (1.6ms)[0m  [1mSELECT "bikes".* FROM "bikes" WHERE ("bikes"."id" = 86) ORDER BY bikes.created_at DESC LIMIT 1[0m

Rendered layouts/_stylesheets.html.erb (1.5ms)
[1m[35mUser Load (2.4ms)[0m SELECT “users”.* FROM “users” WHERE (“users”.”id” = 1) LIMIT 1
Rendered layouts/_header.html.erb (116.3ms)
Rendered layouts/_footer.html.erb (1.3ms)
Rendered carts/show.html.erb within layouts/application (398.2ms)
Completed 200 OK in 431ms (Views: 399.6ms | ActiveRecord: 6.7ms)

   Started GET "/stylesheets/application.css" for 127.0.0.1 at 2011-08-10 14:27:11 -0400

   ActionController::RoutingError (No route matches "/stylesheets/application.css"):


   Rendered /Users/willdennis/.rvm/gems/ruby-1.9.2-p180@rails3tut/gems/actionpack-  3.0.1/lib/action_dispatch/middleware/templates/rescues/routing_error.erb within rescues/layout (1.3ms)
  • 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-24T17:55:54+00:00Added an answer on May 24, 2026 at 5:55 pm

    The problem is that you’re not using form_for correctly. This is how the form should be generated:

    <%= form_for @cart do |f| %>
      From <%= f.text_field :startdate %> <br>
      To <%= f.text_field :enddate %>
      <%= f.submit "Set Dates" %>
    <% end %>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm looking for a way to allow the user of my iPhone application to
I am looking for a way to allow a user on my web site
I'm looking for a WPF textarea component that would allow the user to search
I have been looking for a way to allow the user to easily change
I'm trying to display a simple ModelForm for a user's profile and allow the
I am wanting to allow a user to update their twitter status from my
I am looking to allow users to control of subdomain of an app I
I am looking to allow reordering of UITableViewCell s and deleting via swipe to
Looking for a Rails validation that will only allow letters, numbers, and spaces. This
Looking for a Linux application (or Firefox extension) that will allow me to scrape

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.