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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T01:42:01+00:00 2026-05-22T01:42:01+00:00

Basically whats happening is I can create a new item that gets saved to

  • 0

Basically whats happening is I can create a new item that gets saved to my table in my db. but when I go to edit the item, the form opens up, I make the change and then when I go to submit, it takes me to the same url as the edit page and gives me Routing Error No route matches “/support/14/edit” although if you enter that in the address bar it opens the edit form just fine, but doesn’t have any of my changes saved. So here is my code.

routes.rb

resources :support

support_controller.rb

def new
  @support_item = Support.new

  respond_to do |format|
    format.html # new.html.erb
    format.xml  { render :xml => @support_item }
  end
end

# GET /support/1/edit
def edit
  @support_item = Support.find(params[:id])
end

# POST /support
# POST /support.xml
def create
  @support_item = Support.new(params[:support_item])

  respond_to do |format|
    if @support_item.save
      format.html { redirect_to("/support", :notice => 'Question was successfully created.') }
    else
      format.html { render :action => "new" }
    end
  end
end

# PUT /support/1
# PUT /support/1.xml
def update
  @support_item = Support.find(params[:id])

  respond_to do |format|
    if @support_item.update_attributes(params[:support_item])
      format.html { redirect_to("/", :notice => 'Question was successfully updated.') }
      format.xml  { head :ok }
    else
      format.html { render :action => "edit" }
      format.xml  { render :xml => @support_item.errors, :status => :unprocessable_entity }
    end
  end
end

support.rb

class Support < ActiveRecord::Base
  belongs_to :role

  scope :admin_available, order("role_id ASC") do
      Support.all
  end

  def self.available(user)
    questions =   where(:role_id => 1)
    questions +=  where(:role_id => user.roles)
    questions
  end
end

_form.html.erb

  <% if @support_item.errors.any? %>
    <div id="error_explanation">
      <h2><%= pluralize(@support_item.errors.count, "error") %> prohibited this question from being saved:</h2>

      <ul>
      <% @support_item.errors.full_messages.each do |msg| %>
        <li><%= msg %></li>
      <% end %>
      </ul>
    </div>
  <% end %>

  <div class="field">
    <%= f.label "Support item for:" %><br />
    <%= f.collection_select :role_id, Role.find_by_max(5), :id, :name, {:default => 'everyone'} %>
  </div>
  <div class="field">
    <%= f.label :question %><br />
    <%= f.text_field :question, :class => 'genForm_question'%>
  </div>
  <div class="field">
    <%= f.label :answer %><br />
    <%= f.text_area :answer, :class => 'genForm_textarea' %>
  </div>
  <div class="field">
    <%= f.label :url %><br />
    <%= f.text_field :url, :class => 'genForm_question' %>
  </div>
  <div class="actions">
    <%= f.submit %>
  </div>

new.html.erb

<h1>New Support Item</h1>

<% form_for @support_item, :url => { :action => "create" }, :html => { :method => :post } do |f| %>
    <%= render 'form', :f => f %>
<% end %>

edit.html.erb

<h1>Editing Support Item</h1>

<% form_for @support_item, :url => { :action => "edit" }, :html => { :method => :post } do |f| %>
        <%= render 'form', :f => f %>
<% end %>

I believe thats all the relavent code.

  • 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-22T01:42:02+00:00Added an answer on May 22, 2026 at 1:42 am
    <h1>Editing Support Item</h1>
    
    <% form_for @support_item do |f| %>
            <%= render 'form', :f => f %>
    <% end %>
    

    You are overriding the URL. It should be able to be auto-generated like that if you are doing everything with standard rest. If that doesn’t work out, just know you don’t want to submit to /support_items/1/edit, you want to submit to /support_items/1.

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

Sidebar

Related Questions

I'm having a problem using UpdateModel(theModelToUpdate) causing concurrency issues. Basically whats happening is, there
Basically what the title says... I need to have an image that when clicked,
Basically what I need to do is write a function that takes in a
I'm having a weird issue that I can't track down... For context, I have
CREATE TABLE [dbo].[MembershipModule]( [Id] [uniqueidentifier] ROWGUIDCOL NOT NULL, [ParentId] [uniqueidentifier] NULL, [TargetId] [int] NULL,
OK, so I do suck at MySQL, but here is basically what I want
Basically just pulling a date out in YYYYMMDD and I can do this fine
I think that this is a newbie type question but I have quite understood
I've been attempting to create a task that writes to a database without blocking
I have a simple controller called list_controller with an index that basically does def

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.