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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T07:14:20+00:00 2026-06-18T07:14:20+00:00

I want the next thing: when the button is clicked, I want to print

  • 0

I want the next thing:
when the button is clicked, I want to print the params[:id] of the welcome controller.

this is my java script code:

$(".btn_skip").click(function() {
    $.ajax({
        url: '/welcome',
        type: 'PUT',
        data: {show_msg: $("#mycheckbox").is(":checked")}
    });
});

and this is my welcome_controller.rb:

class WelcomeController < ApplicationController
def update
    @user = User.find(params[:id])
    puts params[:id]
    end
end

when I ran: rails s and pressed the button (btn_skip), I got:

Started PUT "/welcome" for 127.0.0.1 at 2013-02-05 12:18:26 +0200

ActionController::RoutingError (No route matches [PUT] "/welcome"):

routes.rb:

resources :welcome

rake routes:

welcome_index GET    /welcome(.:format)          welcome#index
              POST   /welcome(.:format)          welcome#create
new_welcome   GET    /welcome/new(.:format)      welcome#new
edit_welcome  GET    /welcome/:id/edit(.:format) welcome#edit
welcome       GET    /welcome/:id(.:format)      welcome#show
              PUT    /welcome/:id(.:format)      welcome#update
              DELETE /welcome/:id(.:format)      welcome#destroy

maybe, should I pass the id in url: '/welcome'?

if so, how can I get the id? maybe by: url: ‘/welcome/#{:id}’?

any help appreciated!

  • 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-18T07:14:22+00:00Added an answer on June 18, 2026 at 7:14 am

    I would recommend you to use rails form helper instead of plain html. Anyways Its your choice, with the current implementation you can add a hidden field to the form. I am assuming you want to pass the current_user’s id to update action.

    <input type="hidden" id="current_user" value="<%= current_user.id %>" />
    

    Now in your javascript code:

    $("#submit").click(function() {
      user_id = $('#current_user').val();
      $.ajax({
        ## the url is the controller
        url: '/welcome' + user_id,
        type: 'PUT',
        data: {show_msg: $("#mycheckbox").is(":checked")}
      });
    });
    

    Thats it! It will fetch the user id and will pass to update action auto-magically. 🙂

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

Sidebar

Related Questions

I want to create updated URL when Next 1000 button is clicked on the
I want to show a jquery dialog next to a button when its clicked.
This is my buttons: <button id=add>Add</button> <button id=remove>Remove</button> this is my JavaScript code: <script
I have one link button with a click event. When Clicked I want to
I want to hide the Next button on my ASP.NET Wizard control using JavaScript.
I have got push notification working but the next thing I want to do
When button is clicked in my script it brings back an image file (#mypic),
My script loads an iframe when the user clicks a button. I want to
In this basic jQuery, AJAX, PHP form I want to display errors next to
I want a good solution for next and previous in a php script. The

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.