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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T06:18:49+00:00 2026-05-31T06:18:49+00:00

Assume that there are Post and Comment models. class Post < ActiveRecord::Base has_many :comments

  • 0

Assume that there are Post and Comment models.

class Post < ActiveRecord::Base
  has_many :comments
end

class Comment < ActiveRecord::Base
  belongs_to :post
end

In config/routes.rb

resources posts do
  resources comments
end

In this situation, if we retrieve the comment id 12 of the post id 1, the proper restful routing path will be as follows:

post_comments_path(@comment.post, @comment)

and this will be displayed in the URL box of the client’s browser as follows:

post/1/comments/12 

What I am concerning in this context is whether there are ways to hide the above url string including ids and replace others expression excluding id data, for exmaple, “post/comments”, or not.

If this questions is not significant, although id data are exposed in the query string, I am curious about whether there is any security problem or not.

  • 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-31T06:18:50+00:00Added an answer on May 31, 2026 at 6:18 am

    You may want to checkout a Railscast on displaying model attributes in the url. However, its much more easy to manage your resources keeping the id in the url.

    http://railscasts.com/episodes/63-model-name-in-url

    Even on the Railscast, you’ll find Ryan Bates talking of tricky issues if you do not have the id in the url and simply have, say, name as posts/name-of-post instead of posts/1.

    To change the url, all you need to do is override the to_param method that Rails uses to convert the model to a url. However, without passing the id, you’ll need to modify your code in other places too.

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

Sidebar

Related Questions

Assume that the core project has a base entity and every plugin maybe extends
I have 3 model, User, Post, Comment with definition like below class Post <
When reading from a IO::Socket::INET filehandle it can not be assumed that there will
Let's assume I have a model called product. Let's assume that product has three
This question assumes there's a blessed central repository that members of a team clone
Assume that we have N erlang nodes, running same application. I want to share
Assume that you have a running SQL Server Express instance named (local)\SQLEXPRESS. Its database
Assume that I have this piece of code: @interface Foo : NSObject { Bar
Assume that the following Perl code is given: my $user_supplied_string = &retrieved_from_untrusted_user(); $user_supplied_string =~
Assume that I want to listen to a non-common port (9090 for example) 24/7

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.