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

  • Home
  • SEARCH
  • 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 6242543
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T11:58:26+00:00 2026-05-24T11:58:26+00:00

I have a controller named Projects. When I click on a button on the

  • 0

I have a controller named Projects. When I click on a button on the show page I execute a method which is in Projects. I want to find the ID of the current Project in this method.
Here is the controller

class ProjectsController < ApplicationController
  #add idea from projects/show
  def add_idea

    @data = JSON.parse(params[:data])
    data_splited = @data["get_idea"].split('|')
    @idea = Idea.new
    @idea.title = data_splited[0]
    @idea.description = data_splited[1]
    @idea.nb_of_votes = 0

    project = Project.find(params[:id]) #this doesn't work
  end

And this is the coffeescript code corresponding to the button :

adding_idea_to_project = -> 
  $("#add_idea").click -> get_idea_title()   

get_idea_title = ->
  title = document.getElementById("title").value
  description = document.getElementById("description").value
  bank_check = document.getElementById("bank")
  if bank_check.checked == true
    data = "{\"get_idea\": \"#{title}|#{description}|#{bank_check}\"}"
  else
    data = "{\"get_idea\": \"#{title}|#{description}\"}"
  $.ajax({
  type: "POST",
  url: "projectss/idea.json",
  data: "data=" + data
  })
  location.reload(true);

The routing is correct and is working, I just can’t find the ID of the Project in the given method.
Any Ideas

  • 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-24T11:58:28+00:00Added an answer on May 24, 2026 at 11:58 am

    Wild guess: You need to provide the ID as part of your AJAX request:

     url: "projects/add_idea/#{projectId}.json"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a controller named Content, which has an Index action, which is associated
I am using the Zend Framework. I have a controller named 'UserController' that has
I have a controller/model hypothetically named Pets. Pets has the following declarations: belongs_to :owner
I have the following controller: public ActionResult Search(string Name, int? Friend, int? Page) It
I'm running into an error with T4MVC and named parameters. I have a controller:
I am working on a project which adopted ASP.NET MVC3(Razor) tech. Now, I have
I have a simple mvc project consisting of one table named Persons and that
I have an upload function in an MVC 3 project which store the files
In Zend project named pro1 I have one module named Admin.In this module I
I have an application that was in a folder named project, I moved all

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.