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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T10:47:20+00:00 2026-06-13T10:47:20+00:00

I’m trying to set up a simple edit feature for an object in one

  • 0

I’m trying to set up a simple edit feature for an object in one of my tables. Here is my current code which I’ve seen online and in books but it doesn’t work

def edit
    @fire_chief = FireChief.find(params[:id])
 end

All I have to do is figure out how to edit a specific Fire Chief in list view and I can keep programming, but I’m stuck.

The error I’m recieving is “Couldn’t find FireChief without an ID”

If I use this little snippet of code it finds the edit form fine

def edit
    @fire_chief = FireChief.last
 end

But it always pulls up the last entry to be edited. I need it to pull the entry that i click…might be the 1st, 3rd, or 5th, etc. I know a lot of this is redundant, but I just want to be clear on what I’m trying to do.

This is my routes file:

resource :timesheet do
    resource :command_officer
    resources :fire_chief
    resources :fire_fighters
    resource :safety_officer
    resources :emts
    resources :hazmat_specialists
    resources :command_vehicles
    resources :engines
    resources :emergency_supports
    resources :hazmat_units
    resources :field_units
    resources :pumpers
    resources :tankers
    resources :rescue_units
end
end

I just changed the resource :fire_chief to be plural, so now its this resources :fire_chief

But I’m getting this error now:

Routing Error

uninitialized constant FireChiefController

  • 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-06-13T10:47:21+00:00Added an answer on June 13, 2026 at 10:47 am

    To get an id or any other data you need from params you have to pass the data inside the url like this example:

    /firechief/2/edit

    This way your edit method will know the id and the method will work. You can set this manually inside your routes, making a route like this:

    get  "/firechief/:firechief_id/edit" => "firechiefs#edit", as => :edit_firechief
    

    Or if you are using resources inside your routes, it shall work by default.

    If you actually does not want to pass any data inside your url, you could implement a session based solution. Create a method to store the id of the firechief inside a controller that fits your needs, or just add this line if you want to create the session inside a method (like firechief#create) you already has:

    session[:firechief] = #here you add the id of the firechief you want to store
    

    Now on your controller you can do this:

    def edit
        @fire_chief = FireChief.find(session[:firechief])
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
I'm trying to select an H1 element which is the second-child in its group
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm making a simple page using Google Maps API 3. My first. One marker
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I have this code to decode numeric html entities to the UTF8 equivalent character.

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.