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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T00:15:48+00:00 2026-06-05T00:15:48+00:00

I am using the gem postmarkdown to create a blog in RoR. The Post

  • 0

I am using the gem postmarkdown to create a blog in RoR. The Post model in the gem is not backed by a database (it uses ActiveModel). How would I go about relating a Comment model to the Post model for a blog that does not utilize a database for the blog posts?

For example, with a typical blog backed by an ActiveRecord database, I could set up the relations (such as)

class Post < ActiveRecord::Base
has_many :comments

However, in this case, I don’t know the best way to create a comment model.

  • 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-05T00:15:50+00:00Added an answer on June 5, 2026 at 12:15 am

    If Post is an activemodel, you can’t setup relations using methods in activerecord. You can check out the README at github. It doesn’t have that functionality.

    One way you could to is simply define your own methods inside Post model.

    class Post
      def comments
        Comment.where(:post_id => id)
      end
    end
    
    class Comment < ActiveRecord::Base
      def post
        Post.find_by_id(post_id)
      end
    end
    

    Edit:
    Ah, I just find a similar question, Ruby on Rails 3 (3.1) ActiveModel Associations (tableless nested models). You can check out that as well.

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

Sidebar

Related Questions

I'm trying to insert some binary data into database using 'mysql' gem in ruby.
I'm using the Neography gem to interact with a Neo4j database through the REST
i was told that using config.gem alongside :path => path/to/dir would work. on server
I am using spreadsheet gem to generate native Excel file. This is not CSV,
I am using gem 'linkedin', :git => git://github.com/pengwynn/linkedin.git when i create client and get
I've installed rails using 'gem install rails', but when I try to create a
When I download something using gem I'd like to be able to just download
I'm using gem bundler (v.0.9.6) and Rails 2.3.5, rubygems 1.3.6 and ruby 1.8.7 (On
I am using Devise gem and I want to change the redirect path after
I'm using VCR gem to record http interactions and replay them in future. I

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.