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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T03:26:21+00:00 2026-06-04T03:26:21+00:00

I am relatively new to programming and to rails so please be indulgent:) I

  • 0

I am relatively new to programming and to rails so please be indulgent:)

I am building a website for myself which contains a blog. I have two models that are nested and I do not seem to understand how to use REST to perform certain actions on my articles and comments.

When I create a comment if the comment doesn’t pass validation I want it to render the page again so that the user can correct his mistakes and resubmit the comment. When I try to render, it gives me a missing template error.

Here is the code:

You can also find this code on github –> https://github.com/MariusLucianPop/mariuslp-

routes.rb

Mariuslp::Application.routes.draw do

  get "categories/new"

  root :to => "static_pages#index"

  match "login" => "visitors#login" # not rest
  match "logout" =>"visitors#logout" # not rest
  match "comment" => "articles#show"

  resources :articles do 
  resources :comments
end

  resources :tags, :taggings, :visitors, :categories, :comments


end

articles_controller.rb

def show
  @article = Article.find(params[:id])
  @comment = @article.comments.new
end

comments_controller.rb

def create
    article_id = params[:comment].delete(:article_id)
    @comment = Comment.new(params[:comment])
    @comment.article_id = article_id
    if @comment.save
      redirect_to article_path(@comment.article_id)
    else
      render article_path(@comment.article_id,@comment) ## This one doesn't work
    end
  end

  def new
    @comment = Comment.new
  end

 def destroy 
    Comment.find(params[:id]).destroy
    redirect_to articles_path()
 end

Views-articles:
_comment.html.erb

<div class="comment">
<%= comment.body %><br />
<%= link_to "Delete Comment", article_comment_path(@article), :method => :delete,    :confirm => "Are you sure you want to delete this comment?" %>
</div>

_comment_form.html.erb

<%= form_for @comment do |f|%>

    <%= f.hidden_field :article_id%>

    <%= f.label :body %><br />
    <%= f.text_area :body, :cols => 50, :rows => 6 %><br />

    <%= f.submit%>
<%end%>

show.html.erb

<p><%= link_to "<< Back to Articles", articles_path%></p>

<div class = "article_show">
    <%= label_tag :category_id %>
    <%= @article.category_id%> <br />

    <%= label_tag :title%>: 
    <%= @article.title%> <br />

    <%= label_tag :body%>: 
    <%= @article.body%> <br />

    <%= label_tag :tag_list%>:
    <%= @article.tag_list%><br />
</div>

<br />
<% if session[:username]== "marius"%>
<div class ="admin">
    <%= link_to "Edit", edit_article_path(@article)%>
    <%= link_to "Delete", article_path(@article), :method => :delete, :confirm => "Are you sure you want to delete this article ?"%>
</div>
<%end%>
<br />



<%= render :partial => 'comment', :collection => @article.comments %>

<%= render :partial => 'comment_form'%>
  • 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-04T03:26:22+00:00Added an answer on June 4, 2026 at 3:26 am

    Have you tried to use where you point the problem?

    render 'articles/show'
    

    You don’t need to use article_comment_path because that is a full path, not just the place where you store the view templates. In this case, you only need the view. Of couse you must be sure to get all instance variable which you use in this views.

    UPDATE:

    @article = Articles.find(article_id)
    render 'articles/show'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am relatively new to world of programming. I have a few performance questions:
I am relatively new to programming with PHP. I have created a simple Javascript
I'm relatively new to iPhone programming but have read my way through a hefty
I am relatively new to ASP.NET programming, and web programming in general. We have
I'm relatively new to web programming. New to Javascript, PHP, Ajax, etc. I have
I am relatively new to Android programming. So please, forgive me for writing or
I am relatively new to programming for Androids and I have a back ground
I'm relatively new to C# and programming, so please bear with me. I'm working
I am relatively new to programming, as you will soon see... I have 2
I am relatively new to iPhone programming, and I have a considerably complex app

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.