I created a scaffold class, now i want to add another method in the controller to it and provide a button link to it to call the method.
How do i do this.
Say the method is called ‘new_method’, what do i put in the erb and routes files in order to call this get method?
Suppose your scaffold class is called
Post, then in your routes you should have:You then want to add a
new_method, you have to choose whether this will work on thecollectionor on a single object.On a collection
In your routes you write
And in your
erbyou would writeNote, if you want to you could also use
button_toinstead oflink_toif you prefer to have a button instead.On a single object (member)
In your routes you write
And in your
erbyou would writeHope this helps.