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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T20:03:17+00:00 2026-05-30T20:03:17+00:00

For my project i need to have custom urls that should not be easy

  • 0

For my project i need to have custom urls that should not be easy to guess as it is with increasing integer ids of objects. To solve this problem i gave my objects a unique_id attribute which is a string and wrote the seven actions that would be generated by resources :objects myself, which looks like:

  get '/objects' => 'objects#index', as: :objects 
  post '/objects' => 'objects#create'
  get '/objects/new' => 'objects#new', as: :new_object
  get '/:unique_id/edit' => 'objects#edit', as: :edit_object
  get '/:unique_id' => 'objects#show', as: :object
  put '/:unique_id' => 'objects#update'
  delete '/:unique_id' => 'objects#destroy'

It all works out great, I simply had to tell the controller to find the Objects via Object.find_by_unique_id(params[:unique_id]) instead of Object.find(params[:id])
I can create, read and delete perfect, but i can not update.

When I open the edit_object_path it renders the form correctly, but when i click on “Update Object” it screws up.
From the WEBrick output i can see that it creates a PUT request, but it requests for the id of the object and not the unique_id. So for instance, instead of requesting PUT /osefushe7398hr9 it states PUT /26. The update method is not even called, but instead it asks to create a new object with unique_id of 26.

I really don’t know where to change that behavior or how to pass along the unique_id instead of the id.

  • 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-30T20:03:18+00:00Added an answer on May 30, 2026 at 8:03 pm

    Okay the solution was to add

    def to_param
      unique_id
    end
    

    to the Object model without parameterize or the #{} syntax.
    I actually found that out on accident trying to pass the unique_id to the form as mentioned in the second solution. It turns out that i did not have to change the form_for tag like it was suggested in solution two. The parameterize was the reason why the unique_id was made to lower case.

    Now everything works as intended (and still is restful)

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

Sidebar

Related Questions

I need to have an at-home project now that I'm working on Python/Django at
I have a some custom views that need to be reuse at diffrent projects,
I have a setup project in which I have a custom action that is
This project is in c# under .net 4. I have a custom object that
For a project I'm working on, I need to make a custom button that
I have an upcoming project that requires me to make a custom layout. I
We have a custom software project that's database driven (MySQL) and is built with
I am working on a Java project and need to have a keypress simulate
The Junits I have in my project need to load property files from the
i need to have one project on asp.net mvc 1 but i want to

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.