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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T19:29:23+00:00 2026-05-20T19:29:23+00:00

I have cobbled together a form due to some oddities in my code and

  • 0

I have cobbled together a form due to some oddities in my code and routes. Things work for adding data to the database, but I can’t quite seem to figure out how to update data. Here is some code.

new.html.erb

<% form_tag '/list' do %>
    Episodes Completed: 
    <%= text_field_tag "completed"  %>
    Watch Status
    <%= collection_select(nil, 'id', @show_status, :id, :state) %>
    <%= hidden_field_tag('show_id', @show.id) %>
    <%= submit_tag 'Add' %>
<% end %>

edit.html.erb

<% form_tag("/list/#{@show_completion.show.id}", :method => :put ) do %>
    Episodes Completed: 
    <%= text_field_tag "completed", @show_completion.episodes_completed  %>
    Watch Status
    <%= collection_select(nil, 'id', @show_status, :id, :state) %>
    <%= hidden_field_tag('show_id', @show_completion.show.id) %>
    <%= submit_tag 'Edit' %>
<% end %>

Here is the controller’s Create and Update methods

def create
  @show_completetion = ShowCompletionStatus.new
  @show_completetion.user_id = current_user.id
  @show_completetion.episodes_completed = params[:completed]
  @show_completetion.status_state_id = params[:id]
  @show_completetion.show_id = params[:show_id]
  @show_completetion.save
end

def update
  @show_completion = ShowCompletionStatus.find(params[:id])

  @show_completion.episodes_completed = params[:completed]
  @show_completion.status_state_id = params[:id]
  @show_completion.show_id = params[:show_id]

  if @show_completion.update_attribute('episodes_completed', params[:completed])
    redirect_to "/list/#{current_user.username}"
  else
     redirect_to "/list/#{params[:id]}/edit"
  end
end

Here are my routes for these:

match "list/" => "list#create", :via => :post
match "list/new/:show_id" => "list#new", :constraints => { :show_id => /[0-9]+/ }
match "list/:id/edit" => "list#edit", :constraints => { :id => /[0-9]+/ }, :via => :get
match "list/:id" => "list#update", :constraints => { :id => /[0-9]+/ }, :via => :put

I have been trying different things to get this to work for the better part of 4 hours now. I think I am just missing something, but I just can’t see it.

Is there a better way to do the form that makes it work better?

Any help is appreciated.

  • 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-20T19:29:24+00:00Added an answer on May 20, 2026 at 7:29 pm

    I solved this issue by making a hash and passing it to the update attributes with the key value pairs of what the objects attributes would be. Since updates_attributes takes a hash and not an object it was a simple solution once the connection was made.

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

Sidebar

Related Questions

I have cobbled together some scripts from various internet sources to get a form
Using the code below (from a console app I've cobbled together), I add seven
i have a input tag which is non editable, but some times i need
This much I have already cobbled together (thanks to Stack Overflowers): I have a
Have you guys had any experiences (positive or negative) by placing your source code/solution
Have you managed to get Aptana Studio debugging to work? I tried following this,
In my database I have certain tables that have confidential information. Each of these
Outline OK, I have Google'd this and already expecting a big fat NO!! But
I have a script that appends some rows to a table. One of the
I have a login.jsp page which contains a login form. Once logged in the

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.