0

NodeController:

    def show
        def toggle
            run some stuff here
        end
        other random show stuff
    end

I want to call the "toggle" function using a link on my show.html.erb view. How would I go about creating a link_to for this?

<%= link_to "Toggle", :controller=>"node", :action=>"show:toggle" %>????

wolf2600
  • 5
  • 2
  • why not just use a `checkbox_tag`? – dax Oct 19 '13 at 21:53
  • I'm using the SNMP gem to query/set values on a Cisco switch. I want to be able to call a function to send a "set" message to the Cisco to set an interface's Administratively up/down status. – wolf2600 Oct 19 '13 at 22:04
  • So the "toggle" function will check the current status of the specified interface, and then send a set command to change the status to the opposite. – wolf2600 Oct 19 '13 at 22:24
  • 1
    In Ruby, you cannot have a method inside a method. http://stackoverflow.com/questions/4864191/is-it-possible-to-have-methods-inside-methods Perhaps you wish to do nested resources? In that case, see http://stackoverflow.com/questions/11273069/rails-custom-nested-controller-actions or http://stackoverflow.com/questions/7583898/grouping-controller-in-subdirectories-for-nested-resources – Aaron Gray Oct 20 '13 at 01:50

0 Answers0