Send parameter from html to method in controller

Ayrat Badykov

I have table and I show contents of this table in html. Every record that is showed has button. I want to send id of the record on button click to the method of my controller. What am I doing wrong?

my_controller.rb

class MyController < ApplicationController
  skip_authorization_check

def index
  @contacts = Mytable.all
end

def add
  byebug
  ap params[:id]
end
end

index.html.slim

- debug(params) if Rails.env.development?
body
center
  p
    |
      Contacts.
  p.contact-list
     - @contacts.each do |a|
          .name
              p.fname
                = a['fname']
          .surname
              p.lname
                = a['lname']
      .phone
          p.phone
            = a['phone']

          .rocknroll
                    p.rock
               = link_to 'Add', method: add, class: 'icon', value: a['id ']

routes.rb

get 'my/' => 'my#index', as: 'my'
get 'my/add'

error

NameError: undefined local variable or method `add'
Pavan

NameError: undefined local variable or method `add'

I believe the error is from this line

= link_to 'Add', method: add, class: 'icon', value: a['id ']

There isn't a method add. The available methods are get, post, put etc

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Angular js Controller method from HTML with a parameter

From Dev

Send Html as parameter from javascript to asp.net mvc controller

From Dev

angularJS send parameter from template to controller

From Dev

How to send HTML geolocation latitude and longitude values from view to controller action method

From Dev

How to get parameter from Controller method in codeigniter?

From Dev

Trying to send the values from HTML to controller

From Dev

How to send a parameter to the controller?

From Dev

Send parameter from view to controller via link in Grails

From Dev

Send a method implementation as parameter

From Dev

Using SignalR Core to send messages from a Controller Method to Angular

From Dev

How to receive data from ajax send() method in a controller

From Dev

Send Parameter to Controller in Routes Laravel

From Dev

How to append Query parameter in the URL from the controller method in Grails?

From Dev

passing parameter values from view to controller action method?

From Dev

Get any parameter from a Post Method in a Web Api controller

From Dev

Trouble getting parameter from AJAX post method on the controller

From Dev

Access View Controller method from App Delegate in Swift - asking for parameter

From Dev

how to pass parameter to show() method in resource controller from another function

From Java

Access to Controller's method parameter values from Spring MVC interceptor

From Dev

Send value from controller to controller

From Dev

How to send object or data to controller from html file?

From Dev

How to send php variable from view(html) to controller

From Dev

Ajax calling controller to send a html table of objects form from view

From Dev

JQuery: Send date to controller method

From Dev

how to send a parameter from an html page to another with angularjs

From

Pass parameter to controller from @Html.ActionLink MVC 4

From Dev

How to send method name as parameter

From Dev

Send call back method as parameter

From Dev

Java send parameter to method paint

Related Related

  1. 1

    Angular js Controller method from HTML with a parameter

  2. 2

    Send Html as parameter from javascript to asp.net mvc controller

  3. 3

    angularJS send parameter from template to controller

  4. 4

    How to send HTML geolocation latitude and longitude values from view to controller action method

  5. 5

    How to get parameter from Controller method in codeigniter?

  6. 6

    Trying to send the values from HTML to controller

  7. 7

    How to send a parameter to the controller?

  8. 8

    Send parameter from view to controller via link in Grails

  9. 9

    Send a method implementation as parameter

  10. 10

    Using SignalR Core to send messages from a Controller Method to Angular

  11. 11

    How to receive data from ajax send() method in a controller

  12. 12

    Send Parameter to Controller in Routes Laravel

  13. 13

    How to append Query parameter in the URL from the controller method in Grails?

  14. 14

    passing parameter values from view to controller action method?

  15. 15

    Get any parameter from a Post Method in a Web Api controller

  16. 16

    Trouble getting parameter from AJAX post method on the controller

  17. 17

    Access View Controller method from App Delegate in Swift - asking for parameter

  18. 18

    how to pass parameter to show() method in resource controller from another function

  19. 19

    Access to Controller's method parameter values from Spring MVC interceptor

  20. 20

    Send value from controller to controller

  21. 21

    How to send object or data to controller from html file?

  22. 22

    How to send php variable from view(html) to controller

  23. 23

    Ajax calling controller to send a html table of objects form from view

  24. 24

    JQuery: Send date to controller method

  25. 25

    how to send a parameter from an html page to another with angularjs

  26. 26

    Pass parameter to controller from @Html.ActionLink MVC 4

  27. 27

    How to send method name as parameter

  28. 28

    Send call back method as parameter

  29. 29

    Java send parameter to method paint

HotTag

Archive