Calling a non-default method of my controller in my views?

Hello everyone, I have a messages_controller, inside this controller,
among all the default methods I have a tweet method that sends the
message to twitter, and aside the ‘edit’ and ‘destroy’ links I want a
‘tweet’ one. However, I don’t know how invoke this method in my app/
views/messages/index.html.erb and I don’t know if I must add something
in config/routes.rb, if you know, please help me!

Thanks!

Rodrigo Alves V.!

On Tue, Sep 21, 2010 at 4:14 PM, rodrigo3n [email protected] wrote:

Hello everyone, I have a messages_controller, inside this controller,
among all the default methods I have a tweet method that sends the
message to twitter, and aside the ‘edit’ and ‘destroy’ links I want a
‘tweet’ one. However, I don’t know how invoke this method in my app/
views/messages/index.html.erb and I don’t know if I must add something
in config/routes.rb, if you know, please help me!

Thanks!

Rodrigo Alves V.!

Assuming you’re using Rails 3, read the guide on routing:
http://guides.rubyonrails.org/routing.html. It’s very helpful and will
explain how to connect a new action like you have here. The upshot is to
route it as a member action that can be invoked on a specific Message.
Then
you’ll have a nice named route you can use in your view, like
tweet_message_path(@message).

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs