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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T19:18:21+00:00 2026-05-23T19:18:21+00:00

I have a discussions controller for which I would like to have an edit

  • 0

I have a discussions controller for which I would like to have an edit action that is linked to remotely, allowing for an AJAX call to render a partial on a page (rather than rerouting to a completely new “edit” page.

My problem is that I have set up the actions in the controller, and all the files (i think are) necessary. But the link on the discussion show page redirects the browser to a new page, rather than linking through to the action on the controller and the corresponding edit.js.erb file. I am wondering where in my code I went wrong..

Here is the code for the discussions controller:

 class DiscussionsController < ApplicationController
   include DiscussionsHelper

   def create
     ...
   end

   def show 
      ...
   end

   def edit
     respond_to do | format |  
        format.js
     end
   end 
 end

Which i would hope would call the js.erb file edit.js.erb (which I have filled just with an alert, for now — once this links through properly I intend to fill it with jquery code to render the edit partial I would like.:

 alert("hello");

The link_to that I have put on the show page is:

 <div class="discussion_overview">
   <h1><%= @discussion.title %></h1>
   <div class="edit_disc">
<%= link_to "Edit", :url => {:action => "edit", :id => @discussion}, :remote => true %>
   </div><br>

As I said, I thought that this would call the edit.js.erb file, which I could then fill with the appropriate code. However, the link_to links instead to :

 http://localhost:3000/discussions/54?remote=true&url[action]=edit&url[id]=54

Any ideas as to what I did wrong?

UPDATE dropping the url => {} to become:

 <%= link_to "Edit", :action => "edit", :id => @discussion, :remote => true %>

Does not solve the solution, instead just changes the redirect to :

http://localhost:3000/discussions/54/edit?remote=true

rather than doing an AJAX call to the edit action..

  • 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-23T19:18:22+00:00Added an answer on May 23, 2026 at 7:18 pm

    It’s just a syntax issue in the link_to line.

    <%= link_to "Edit", {:action => "edit", :id => @discussion}, :remote => true %>
    

    The second param in the link_to() method is the url. By prepending with :url => {} your url hash is within another hash. Just drop the :url =>. 🙂

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

Sidebar

Related Questions

I have a Visualforce page using a custom controller that is used to edit
I would like to make a bot that can carry on a simple conversation.
I have two views which will both use the same Controller method: //webServiceController.cs //The
I have built mini widgets that consist of a model, a controller a couple
I have a controller with 2 actions that each return the response from the
We have a lot of open discussions with potential clients, and they ask frequently
I have seen a lot of discussions going on and people asking about DataGrid
I have seen the GUID Collisons discussions but just wanted your thoughts on whether
I have looked on the web and the discussions/examples appear to be for traditional
This discussion started over here but I thought it would be nice to have

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.