Newbie wanting to understand controller action relationship


#1

I still getting my feet wet with rails and I’m trying to learn some good
ways of working with link_to_remote.

I’m using the user and login engines and I have in my layout this…
link_to_remote( ‘Login’, :update => ‘main-query’,
:url =>{:action => ‘login’},
:complete =>
“javascript:toggle(‘main-query’);
new Effect.SlideDown(‘main-query’,
{duration: .5})”)

which is used to slide open a login window. It works well, however
depending on the page I have loaded I will sometimes get a NoMethod
Error when the link is clicked.

Do I need to add a :controller => ‘user’ to the :url line somehow? (If
so, I’m doing it wrong because that dosn’t work either). How does rails
interpret this?


#2

This is what I thought, however when I specify to use the ‘user’
controller I get an error.


#3

Do I need to add a :controller => ‘user’ to the :url line somehow? (If
so, I’m doing it wrong because that dosn’t work either). How does rails
interpret this?

Hello. If no controller specified Rails thinks that it should use
current controller. So, you have to specify your controller to access
it from any other place.


#4

In fact, If I specify the controller to be “application” I will be
directed to the login page. And if I navigate to
localhost:3000/user/login I am shown the login page, however when I
generate a link with :controller set to ‘user’ I only get a
NoMethodError return.