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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T16:20:56+00:00 2026-06-17T16:20:56+00:00

I am using Rails Inherited_resource gem in my comments controller, and comments is a

  • 0

I am using Rails Inherited_resource gem in my comments controller, and comments is a nested resource so:
resources :projects do
  resources :comments do
end

I also have a belongs_to in the comments controller:
belongs_to :project, :finder => :find_by_project_uuid!, :class_name => “Thfz::Project”, :polymorphic => true

  1. How can I set the comment’s user association to the current_user(user_id) when its created? As user_id is not suppose to be massive assigned.

  2. I tried following:
    def begin_of_association_chain
         current_user
    end
    This does set the user id correctly, but I cannot get nested resource working for Project with this.

  3. Same question come when destroy a comment, I will need to find the comment through current_user, so how to achieve this?

So do I have to write my own create and destroy actions?

Thanks 🙂

  • 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-17T16:20:58+00:00Added an answer on June 17, 2026 at 4:20 pm

    Have you tried the following inside comments_controller?

    class CommentsController < InheritedResources::Base
      before_filter :authenticate_user! # Assuming you are using Devise for authentication
      respond_to :html, :xml, :json
    
      belongs_to :project, :finder => :find_by_project_uuid!, :class_name => "Thfz::Project"
    
      def create
        @comment = build_resource
        @comment.author = current_user
    
        create!
      end
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using Rails 3.1.3 for a project with Inherited Resources 1.3.0. When I have
Using Rails 3.2. I have an individual Shop post, and each shop has reviews.
I using rails 3.0.9. My Gemfile: gem 'ajaxful_rating', :git => 'git://github.com/edgarjs/ajaxful-rating.git', :branch => rails3
I am using Rails with MongoDB and MongoMapper. My problem is that I have
I have a simple rails app using devise--as such (and being a new rails
I'm creating a message-board website using Rails. I have a Topic class and Post
I have inherited a rails application however the tables aren't using the standard rails
I'm using the Rails gem SimpleForm, but I think my question may be applicable
I am using ruby 1.9.2-p180, rails 3.0.7. I have used validates_acceptance_of since the user
I have a Rails 3 app that is packed into a war file using

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.